[MIG] account_move_reconcile_forbid_cancel: Migration to 16.0
parent
abed5c17ce
commit
fb7e9d2ac1
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Account Move Reconcile Forbid Cancel",
|
"name": "Account Move Reconcile Forbid Cancel",
|
||||||
"version": "15.0.1.0.0",
|
"version": "16.0.1.0.0",
|
||||||
"category": "Finance",
|
"category": "Finance",
|
||||||
"website": "https://github.com/OCA/account-reconcile",
|
"website": "https://github.com/OCA/account-reconcile",
|
||||||
"author": "Tecnativa, Odoo Community Association (OCA)",
|
"author": "Tecnativa, Odoo Community Association (OCA)",
|
||||||
|
|
|
@ -8,18 +8,12 @@ from odoo.exceptions import ValidationError
|
||||||
class AccountMove(models.Model):
|
class AccountMove(models.Model):
|
||||||
_inherit = "account.move"
|
_inherit = "account.move"
|
||||||
|
|
||||||
def _get_receivable_payable_lines(self):
|
|
||||||
return self.line_ids.filtered(
|
|
||||||
lambda l: l.account_internal_type in ["receivable", "payable"],
|
|
||||||
)
|
|
||||||
|
|
||||||
def button_draft(self):
|
def button_draft(self):
|
||||||
if not self.env.context.get("skip_reconcile_forbid_cancel") and (
|
if not self.env.context.get("skip_reconcile_forbid_cancel") and (
|
||||||
not tools.config["test_enable"]
|
not tools.config["test_enable"]
|
||||||
or self.env.context.get("test_reconcile_forbid_cancel")
|
or self.env.context.get("test_reconcile_forbid_cancel")
|
||||||
):
|
):
|
||||||
rec_pay_lines = self._get_receivable_payable_lines()
|
if self._get_reconciled_amls():
|
||||||
if rec_pay_lines.matched_debit_ids or rec_pay_lines.matched_credit_ids:
|
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_("You cannot reset to draft reconciled entries.")
|
_("You cannot reset to draft reconciled entries.")
|
||||||
)
|
)
|
||||||
|
@ -30,7 +24,6 @@ class AccountMove(models.Model):
|
||||||
not tools.config["test_enable"]
|
not tools.config["test_enable"]
|
||||||
or self.env.context.get("test_reconcile_forbid_cancel")
|
or self.env.context.get("test_reconcile_forbid_cancel")
|
||||||
):
|
):
|
||||||
rec_pay_lines = self._get_receivable_payable_lines()
|
if self._get_reconciled_amls():
|
||||||
if rec_pay_lines.matched_debit_ids or rec_pay_lines.matched_credit_ids:
|
|
||||||
raise ValidationError(_("You cannot cancel reconciled entries."))
|
raise ValidationError(_("You cannot cancel reconciled entries."))
|
||||||
return super().button_cancel()
|
return super().button_cancel()
|
||||||
|
|
|
@ -17,7 +17,7 @@ class TestAccountMoveReconcileForbidCancel(TransactionCase):
|
||||||
{
|
{
|
||||||
"name": "Receivable Account",
|
"name": "Receivable Account",
|
||||||
"code": "REC",
|
"code": "REC",
|
||||||
"user_type_id": cls.env.ref("account.data_account_type_receivable").id,
|
"account_type": "asset_receivable",
|
||||||
"reconcile": True,
|
"reconcile": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -25,7 +25,7 @@ class TestAccountMoveReconcileForbidCancel(TransactionCase):
|
||||||
{
|
{
|
||||||
"name": "Payable Account",
|
"name": "Payable Account",
|
||||||
"code": "PAY",
|
"code": "PAY",
|
||||||
"user_type_id": cls.env.ref("account.data_account_type_payable").id,
|
"account_type": "liability_payable",
|
||||||
"reconcile": True,
|
"reconcile": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -33,9 +33,7 @@ class TestAccountMoveReconcileForbidCancel(TransactionCase):
|
||||||
{
|
{
|
||||||
"name": "Income Account",
|
"name": "Income Account",
|
||||||
"code": "INC",
|
"code": "INC",
|
||||||
"user_type_id": cls.env.ref(
|
"account_type": "income",
|
||||||
"account.data_account_type_other_income"
|
|
||||||
).id,
|
|
||||||
"reconcile": False,
|
"reconcile": False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -43,7 +41,7 @@ class TestAccountMoveReconcileForbidCancel(TransactionCase):
|
||||||
{
|
{
|
||||||
"name": "Expense Account",
|
"name": "Expense Account",
|
||||||
"code": "EXP",
|
"code": "EXP",
|
||||||
"user_type_id": cls.env.ref("account.data_account_type_expenses").id,
|
"account_type": "expense",
|
||||||
"reconcile": False,
|
"reconcile": False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue