Skip to content

Commit

Permalink
[FIX] pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocorato committed Jan 16, 2024
1 parent 853a59b commit 0970bdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
7 changes: 3 additions & 4 deletions res_partner_forbid_archive_with_invoice/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
"category": "Accounting & Finance",
"author": "Sergio Corato",
"summary": "This module stop the user to deactivate partners that have "
"invoices or moves. This would make impossible to find the "
"invoices/moves without knowing their exact number.",
"invoices or moves. This would make impossible to find the "
"invoices/moves without knowing their exact number.",
"website": "https://github.com/sergiocorato/e-account",
"license": "AGPL-3",
"depends": [
"account",
],
"data": [
],
"data": [],
"installable": True,
}
23 changes: 13 additions & 10 deletions res_partner_forbid_archive_with_invoice/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ class ResPartner(models.Model):
_inherit = "res.partner"

move_line_ids = fields.One2many(
comodel_name='account.move.line',
inverse_name='partner_id',
string='Move Lines',
comodel_name="account.move.line",
inverse_name="partner_id",
string="Move Lines",
)

def toggle_active(self):
if any(x.invoice_ids or x.move_line_ids for x in self.filtered(
lambda x: x.active)):
raise UserError(_(
"Some selected partner has registered invoices or moves! \n"
"You cannot deactivate these partners: %s") % (
" - ".join(self.mapped("name"))
))
if any(
x.invoice_ids or x.move_line_ids for x in self.filtered(lambda x: x.active)
):
raise UserError(
_(
"Some selected partner has registered invoices or moves! \n"
"You cannot deactivate these partners: %s"
)
% (" - ".join(self.mapped("name")))
)
super().toggle_active()

0 comments on commit 0970bdd

Please sign in to comment.