diff --git a/beesdoo_account/__init__.py b/beesdoo_account/__init__.py index 9a7e03e..0650744 100644 --- a/beesdoo_account/__init__.py +++ b/beesdoo_account/__init__.py @@ -1 +1 @@ -from . import models \ No newline at end of file +from . import models diff --git a/beesdoo_account/models/account_invoice.py b/beesdoo_account/models/account_invoice.py index 458ff29..886cfa5 100644 --- a/beesdoo_account/models/account_invoice.py +++ b/beesdoo_account/models/account_invoice.py @@ -8,22 +8,31 @@ class AccountInvoice(models.Model): @api.multi def action_invoice_open(self): if self.user_has_groups( - 'beesdoo_account.' - 'group_validate_invoice_negative_total_amount'): + "beesdoo_account." "group_validate_invoice_negative_total_amount" + ): return self.action_invoice_negative_amount_open() return super(AccountInvoice, self).action_invoice_open() @api.multi def action_invoice_negative_amount_open(self): """Identical to action_invoice_open without UserError on an invoice with a negative total amount""" - to_open_invoices = self.filtered(lambda inv: inv.state != 'open') + to_open_invoices = self.filtered(lambda inv: inv.state != "open") if to_open_invoices.filtered(lambda inv: not inv.partner_id): - raise UserError(_("The field Vendor is required, please complete it to validate the Vendor Bill.")) - if to_open_invoices.filtered(lambda inv: inv.state != 'draft'): - raise UserError(_("Invoice must be in draft state in order to validate it.")) + raise UserError( + _( + "The field Vendor is required, please complete it to validate the Vendor Bill." + ) + ) + if to_open_invoices.filtered(lambda inv: inv.state != "draft"): + raise UserError( + _("Invoice must be in draft state in order to validate it.") + ) if to_open_invoices.filtered(lambda inv: not inv.account_id): raise UserError( - _('No account was found to create the invoice, be sure you have installed a chart of account.')) + _( + "No account was found to create the invoice, be sure you have installed a chart of account." + ) + ) to_open_invoices.action_date_assign() to_open_invoices.action_move_create() return to_open_invoices.invoice_validate() diff --git a/beesdoo_account/models/res_config.py b/beesdoo_account/models/res_config.py index 4d91f6d..3b078e8 100644 --- a/beesdoo_account/models/res_config.py +++ b/beesdoo_account/models/res_config.py @@ -6,6 +6,7 @@ class ResConfigSettings(models.TransientModel): group_validate_invoice_negative_total_amount = fields.Boolean( """Allow validating an invoice with a negative total amount""", - implied_group="beesdoo_account." "group_validate_invoice_negative_total_amount", + implied_group="beesdoo_account." + "group_validate_invoice_negative_total_amount", help="""Allows you to validate an invoice with a negative total amount""", - ) \ No newline at end of file + )