Skip to content

Commit

Permalink
[MIG] account_move_reconcile_forbid_cancel: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ACheung-FactorLibre committed Jul 26, 2023
1 parent abed5c1 commit fb7e9d2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion account_move_reconcile_forbid_cancel/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
11 changes: 2 additions & 9 deletions account_move_reconcile_forbid_cancel/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@
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.")
)
Expand All @@ -30,7 +24,6 @@ def button_cancel(self):
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()
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,31 @@ def setUpClass(cls):
{
"name": "Receivable Account",
"code": "REC",
"user_type_id": cls.env.ref("account.data_account_type_receivable").id,
"account_type": "asset_receivable",
"reconcile": True,
}
)
payable_account = cls.env["account.account"].create(
{
"name": "Payable Account",
"code": "PAY",
"user_type_id": cls.env.ref("account.data_account_type_payable").id,
"account_type": "liability_payable",
"reconcile": True,
}
)
income_account = cls.env["account.account"].create(
{
"name": "Income Account",
"code": "INC",
"user_type_id": cls.env.ref(
"account.data_account_type_other_income"
).id,
"account_type": "income",
"reconcile": False,
}
)
expense_account = cls.env["account.account"].create(
{
"name": "Expense Account",
"code": "EXP",
"user_type_id": cls.env.ref("account.data_account_type_expenses").id,
"account_type": "expense",
"reconcile": False,
}
)
Expand Down

0 comments on commit fb7e9d2

Please sign in to comment.