From 47fe2b8b52d0618986194208a702cbbfc27a21dd Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Wed, 16 Jun 2021 11:47:48 -0300 Subject: [PATCH] [FIX] Pre commit issues --- l10n_br_account/models/account_invoice.py | 65 ++++++++++++------- .../wizards/account_invoice_refund.py | 9 ++- .../wizards/account_invoice_refund_view.xml | 2 +- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/l10n_br_account/models/account_invoice.py b/l10n_br_account/models/account_invoice.py index 5e063d059411..154275765a92 100644 --- a/l10n_br_account/models/account_invoice.py +++ b/l10n_br_account/models/account_invoice.py @@ -486,22 +486,23 @@ def view_pdf(self): def _get_refund_common_fields(self): fields = super()._get_refund_common_fields() fields += [ - 'fiscal_operation_id', - 'document_type_id', - 'document_serie_id', + "fiscal_operation_id", + "document_type_id", + "document_serie_id", ] return fields @api.multi - @api.returns('self') + @api.returns("self") def refund(self, date_invoice=None, date=None, description=None, journal_id=None): new_invoices = super(AccountInvoice, self).refund( - date_invoice, date, description, journal_id) + date_invoice, date, description, journal_id + ) force_fiscal_operation_id = False - if self.env.context.get('force_fiscal_operation_id'): - force_fiscal_operation_id = self.env['l10n_br_fiscal.operation'].browse( - self.env.context.get('force_fiscal_operation_id') + if self.env.context.get("force_fiscal_operation_id"): + force_fiscal_operation_id = self.env["l10n_br_fiscal.operation"].browse( + self.env.context.get("force_fiscal_operation_id") ) my_new_invoices = self.browse(new_invoices.ids) @@ -509,31 +510,45 @@ def refund(self, date_invoice=None, date=None, description=None, journal_id=None for r in my_new_invoices: if not r.document_type_id: continue - if (not force_fiscal_operation_id and - not r.fiscal_operation_id.return_fiscal_operation_id): + if ( + not force_fiscal_operation_id + and not r.fiscal_operation_id.return_fiscal_operation_id + ): raise UserError( - _("""Document without Return Fiscal Operation! \n Force one!""")) + _("""Document without Return Fiscal Operation! \n Force one!""") + ) r.fiscal_operation_id = ( - force_fiscal_operation_id or - r.fiscal_operation_id.return_fiscal_operation_id) + force_fiscal_operation_id + or r.fiscal_operation_id.return_fiscal_operation_id + ) for line in r.invoice_line_ids: - if (not force_fiscal_operation_id and - not line.fiscal_operation_id.return_fiscal_operation_id): + if ( + not force_fiscal_operation_id + and not line.fiscal_operation_id.return_fiscal_operation_id + ): raise UserError( - _("""Line without Return Fiscal Operation! \n - Please force one! \n{}""".format(line.name))) + _( + """Line without Return Fiscal Operation! \n + Please force one! \n{}""".format( + line.name + ) + ) + ) line.fiscal_operation_id = ( - force_fiscal_operation_id or - line.fiscal_operation_id.return_fiscal_operation_id) + force_fiscal_operation_id + or line.fiscal_operation_id.return_fiscal_operation_id + ) line._onchange_fiscal_operation_id() refund_invoice_id = my_new_invoices.refund_invoice_id - if (refund_invoice_id.fiscal_document_id and - my_new_invoices.fiscal_document_id): + if ( + refund_invoice_id.fiscal_document_id + and my_new_invoices.fiscal_document_id + ): refund_invoice_id.fiscal_document_id._prepare_referenced_subsequent( new_document_id=my_new_invoices.fiscal_document_id ) @@ -543,12 +558,12 @@ def refund(self, date_invoice=None, date=None, description=None, journal_id=None def _refund_cleanup_lines(self, lines): result = super(AccountInvoice, self)._refund_cleanup_lines(lines) for _a, _b, vals in result: - if vals.get('fiscal_document_line_id'): - vals.pop('fiscal_document_line_id') + if vals.get("fiscal_document_line_id"): + vals.pop("fiscal_document_line_id") for i, line in enumerate(lines): - for name, field in line._fields.items(): - if name == 'fiscal_tax_ids': + for name, _field in line._fields.items(): + if name == "fiscal_tax_ids": result[i][2][name] = [(6, 0, line[name].ids)] return result diff --git a/l10n_br_account/wizards/account_invoice_refund.py b/l10n_br_account/wizards/account_invoice_refund.py index 9f3e3acb54fc..c370f35a00f7 100644 --- a/l10n_br_account/wizards/account_invoice_refund.py +++ b/l10n_br_account/wizards/account_invoice_refund.py @@ -18,9 +18,12 @@ class AccountInvoiceRefund(models.TransientModel): ) def invoice_refund(self): - return super(AccountInvoiceRefund, self.with_context( - force_fiscal_operation_id=self.force_fiscal_operation_id.id - )).invoice_refund() + return super( + AccountInvoiceRefund, + self.with_context( + force_fiscal_operation_id=self.force_fiscal_operation_id.id + ), + ).invoice_refund() @api.model def fields_view_get( diff --git a/l10n_br_account/wizards/account_invoice_refund_view.xml b/l10n_br_account/wizards/account_invoice_refund_view.xml index 37f240ca6c01..e3211d969ada 100644 --- a/l10n_br_account/wizards/account_invoice_refund_view.xml +++ b/l10n_br_account/wizards/account_invoice_refund_view.xml @@ -7,7 +7,7 @@ - +