[IMP] account_reconcile_oca: Add Reconcile action
parent
5c0e421517
commit
f545c1e4a0
|
@ -2,3 +2,4 @@ from . import account_reconcile_abstract
|
||||||
from . import account_journal
|
from . import account_journal
|
||||||
from . import account_bank_statement_line
|
from . import account_bank_statement_line
|
||||||
from . import account_account_reconcile
|
from . import account_account_reconcile
|
||||||
|
from . import account_move_line
|
||||||
|
|
|
@ -84,6 +84,13 @@ class AccountAccountReconcile(models.Model):
|
||||||
def _compute_reconcile_data_info(self):
|
def _compute_reconcile_data_info(self):
|
||||||
data_obj = self.env["account.account.reconcile.data"]
|
data_obj = self.env["account.account.reconcile.data"]
|
||||||
for record in self:
|
for record in self:
|
||||||
|
if self.env.context.get("default_account_move_lines"):
|
||||||
|
data = {
|
||||||
|
"data": [],
|
||||||
|
"counterparts": self.env.context.get("default_account_move_lines"),
|
||||||
|
}
|
||||||
|
record.reconcile_data_info = self._recompute_data(data)
|
||||||
|
continue
|
||||||
data_record = data_obj.search(
|
data_record = data_obj.search(
|
||||||
[("user_id", "=", self.env.user.id), ("reconcile_id", "=", record.id)]
|
[("user_id", "=", self.env.user.id), ("reconcile_id", "=", record.id)]
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Copyright 2023 Dixmit
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import _, models
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class AccountMoveLine(models.Model):
|
||||||
|
|
||||||
|
_inherit = "account.move.line"
|
||||||
|
|
||||||
|
def action_reconcile_manually(self):
|
||||||
|
if not self:
|
||||||
|
return {}
|
||||||
|
self.mapped("account_id").ensure_one()
|
||||||
|
partner = self.mapped("partner_id")
|
||||||
|
if partner:
|
||||||
|
partner.ensure_one()
|
||||||
|
if self.filtered(lambda r: r.partner_id != partner):
|
||||||
|
raise ValidationError(
|
||||||
|
_("You must reconcile information on the same partner")
|
||||||
|
)
|
||||||
|
action = self.env["ir.actions.act_window"]._for_xml_id(
|
||||||
|
"account_reconcile_oca.account_account_reconcile_act_window"
|
||||||
|
)
|
||||||
|
action["domain"] = [
|
||||||
|
("account_id", "=", self.mapped("account_id").id),
|
||||||
|
("partner_id", "=", partner.id),
|
||||||
|
]
|
||||||
|
action["context"] = self.env.context.copy()
|
||||||
|
action["context"]["default_account_move_lines"] = self.filtered(
|
||||||
|
lambda r: not r.reconciled
|
||||||
|
).ids
|
||||||
|
return action
|
|
@ -101,4 +101,13 @@
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="action_reconcile" model="ir.actions.server">
|
||||||
|
<field name="name">Reconcile</field>
|
||||||
|
<field name="model_id" ref="account.model_account_move_line" />
|
||||||
|
<field name="binding_model_id" ref="account.model_account_move_line" />
|
||||||
|
<field name="binding_view_types">list</field>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">action = records.action_reconcile_manually()</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue