From a97c4ecd29bf55bd8d0184d6517c901569c1fd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Thu, 23 May 2024 08:57:48 -0300 Subject: [PATCH] [REF] l10n_br_nfe: lint fixes --- l10n_br_nfe/__init__.py | 1 - l10n_br_nfe/models/document.py | 8 ++++++-- l10n_br_nfe/models/mde.py | 24 ++++++++++++++---------- l10n_br_nfe/models/res_partner.py | 1 - l10n_br_nfe/wizards/import_document.py | 6 +++--- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/l10n_br_nfe/__init__.py b/l10n_br_nfe/__init__.py index 3ac01099642d..6adde652187c 100644 --- a/l10n_br_nfe/__init__.py +++ b/l10n_br_nfe/__init__.py @@ -2,5 +2,4 @@ from .hooks import post_init_hook from . import models -from . import tests from . import wizards diff --git a/l10n_br_nfe/models/document.py b/l10n_br_nfe/models/document.py index df2ef8a350fe..711e9bad8434 100644 --- a/l10n_br_nfe/models/document.py +++ b/l10n_br_nfe/models/document.py @@ -844,7 +844,11 @@ def _document_number(self): record.nfe40_cDV = chave.digito_verificador except Exception as e: raise ValidationError( - _("{}:\n {}").format(record.document_type_id.name, e) + _( + "%(name)s:\n %(error)s", + name=record.document_type_id.name, + error=e, + ) ) from e return result @@ -986,7 +990,7 @@ def _exec_after_SITUACAO_EDOC_AUTORIZADA(self, old_state, new_state): # Se der problema que apareça quando # o usuário clicar no gerar PDF novamente. _logger.error("DANFE Error \n {}".format(e)) - super()._exec_after_SITUACAO_EDOC_AUTORIZADA(old_state, new_state) + return super()._exec_after_SITUACAO_EDOC_AUTORIZADA(old_state, new_state) def _generate_key(self): for record in self.filtered(filter_processador_edoc_nfe): diff --git a/l10n_br_nfe/models/mde.py b/l10n_br_nfe/models/mde.py index 5537b4e26a98..58236a5bfaf6 100644 --- a/l10n_br_nfe/models/mde.py +++ b/l10n_br_nfe/models/mde.py @@ -35,7 +35,7 @@ class MDe(models.Model): key = fields.Char(string="Access Key", size=44) - serie = fields.Char(string="Serie", size=3, index=True) + serie = fields.Char(size=3, index=True) number = fields.Float(string="Document Number", index=True, digits=(18, 0)) @@ -44,7 +44,7 @@ class MDe(models.Model): string="Fiscal Document", ) - emitter = fields.Char(string="Emitter", size=60) + emitter = fields.Char(size=60) cnpj_cpf = fields.Char(string="CNPJ/CPF", size=18) @@ -52,7 +52,6 @@ class MDe(models.Model): operation_type = fields.Selection( selection=OPERATION_TYPE, - string="Operation Type", ) document_value = fields.Float( @@ -84,16 +83,15 @@ class MDe(models.Model): cancellation_datetime = fields.Datetime(string="Cancellation Date", index=True) - digest_value = fields.Char(string="Digest Value", size=28) + digest_value = fields.Char(size=28) - inclusion_mode = fields.Char(string="Inclusion Mode", size=255) + inclusion_mode = fields.Char(size=255) - authorization_protocol = fields.Char(string="Authorization protocol", size=60) + authorization_protocol = fields.Char(size=60) - cancellation_protocol = fields.Char(string="Cancellation protocol", size=60) + cancellation_protocol = fields.Char(size=60) document_state = fields.Selection( - string="Document State", selection=SITUACAO_NFE, index=True, ) @@ -148,7 +146,11 @@ def validate_event_response(self, result, valid_codes): if not valid: raise ValidationError( - _("Error on validating event: %s - %s" % (code, message)) + _( + "Error on validating event: %(code)s - %(msg)s", + code=code, + msg=message, + ) ) def import_document(self): @@ -161,7 +163,9 @@ def import_document(self): document = self.dfe_id._download_document(self.key) document_id = self.dfe_id._parse_xml_document(document) except Exception as e: - self.dfe_id.message_post(body=_("Error importing document: \n\n %s") % e) + self.dfe_id.message_post( + body=_("Error importing document: \n\n %(error)s", error=e) + ) return if document_id: diff --git a/l10n_br_nfe/models/res_partner.py b/l10n_br_nfe/models/res_partner.py index f214a5d89b7a..8eaeb55c744f 100644 --- a/l10n_br_nfe/models/res_partner.py +++ b/l10n_br_nfe/models/res_partner.py @@ -179,7 +179,6 @@ def _prepare_import_dict( ) is_anonymous_consumer = fields.Boolean( - string="Is Anonymous Consumer", help="Indicates that the partner is an anonymous consumer", ) diff --git a/l10n_br_nfe/wizards/import_document.py b/l10n_br_nfe/wizards/import_document.py index 598dece28815..463fba2926ac 100644 --- a/l10n_br_nfe/wizards/import_document.py +++ b/l10n_br_nfe/wizards/import_document.py @@ -261,7 +261,7 @@ class NfeImportProducts(models.TransientModel): _name = "l10n_br_nfe.import_xml.products" _description = "Import XML NFe Products" - product_name = fields.Char(string="Product Name") + product_name = fields.Char() uom_com = fields.Char(string="UOM Comercial") @@ -271,11 +271,11 @@ class NfeImportProducts(models.TransientModel): uom_trib = fields.Char(string="UOM Fiscal") - quantity_trib = fields.Float(string="Fiscal Quantity") + quantity_trib = fields.Float() price_unit_trib = fields.Float(string="Fiscal Price Unit") - total = fields.Float(string="Total") + total = fields.Float() import_xml_id = fields.Many2one(comodel_name="l10n_br_nfe.import_xml")