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