Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][ADD] l10n_br_mdfe: add new module #3445

Open
wants to merge 14 commits into
base: 14.0
Choose a base branch
from

Conversation

marcelsavegnago
Copy link
Member

@marcelsavegnago marcelsavegnago commented Oct 16, 2024

This pull request introduces support for the Manifesto Eletrônico de Documentos Fiscais (MDFe) in the Brazilian fiscal module. The changes include adding new constants, updating data files, and creating new models and views to handle MDFe documents.

Major Changes:

MDFe Support:

  • Added MODELO_FISCAL_MDFE constant to l10n_br_fiscal/constants/fiscal.py.
  • Included MDFe document type in l10n_br_fiscal/data/l10n_br_fiscal.document.type.csv.
  • Created MDFe operation records in l10n_br_fiscal/data/operation_data.xml.

New Models and Fields:

  • Added document_supplement import in l10n_br_fiscal/models/__init__.py.
  • Introduced new fields key_random_code, key_check_digit, and total_weight in l10n_br_fiscal/models/document_mixin_fields.py.
  • Added currency_id, document_total_weight, and document_total_amount fields to l10n_br_fiscal/models/document_related.py.

MDFe Module:

  • Created l10n_br_mdfe module with initial setup and dependencies in l10n_br_mdfe/__manifest__.py.
  • Defined MDFe constants in l10n_br_mdfe/constants/mdfe.py.

Views and UI Enhancements:

  • Updated l10n_br_fiscal/views/document_related_view.xml to include total fields for MDFe.
  • Added total_weight field to delivery page in l10n_br_fiscal/views/document_view.xml.

@OCA-git-bot
Copy link
Contributor

Hi @mileo, @renatonlima, @rvalyi,
some modules you are maintaining are being modified, check this out!

@@ -7,13 +7,10 @@
class MdfeSpecMixin(models.AbstractModel):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pode renomear o arquivo spec_mixin.py ? Eu fiz isso no PR do multi-esquemas, reflete mais o que tem dentro.

Pois o spec.mixin.schema eh algo que extende TODOS modelos geridos pro XSD, enquanto que o SpecModel e StackedModel sao apenas pro objetos Odoo nativos que tem que ser extendido por algum mixin do esquemas. Ja tem uma certa complexidade entao melhor ajudar com o nome das coisas.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch from 2be2b5c to cbf090a Compare October 16, 2024 17:33

def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
env["mdfe.30.tmdfe_infnfe"]._register_hook()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eu acho que pode tirar isso agora.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@rvalyi
Copy link
Member

rvalyi commented Oct 16, 2024

@marcelsavegnago o _register_hook não foi chamado pros objetos da mdfe. Esse problema foi depois de vc remover o hook apenas? Ele deveria fazer sozinho mas talvez ele cai naquele problema que eu comentei mais cedo de precisar de um loop para cada esquema no #3431.

Para as tabelas desses objetos existirem o _register_hook precisa ser chamado pelo menos uma vez para aquele esquema da mdfe. Normalmente ele deveria fazer sozinho, mas talvez caiu no caso que aquele mro() trouxe apenas as extensões da nfe e que ele parou apenas na primeira extensão "spec" da nfe no caso. Na pior se resolver de chamar o _register_hook em cima de um objeto da mdfe no hook.py, seria um workaround aceitável até fazer aquele loop no spec_driven_model.

@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch 5 times, most recently from 46cbd92 to a4727ac Compare October 17, 2024 18:27
@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch 3 times, most recently from 3bbd0a7 to d9bcf20 Compare October 19, 2024 18:50
@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch from 86c8bbe to 027a274 Compare October 20, 2024 19:40
Copy link
Member

@rvalyi rvalyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcelsavegnago eu tinha errado no summary do manifest do modulo l10n_br_mdfe_spec (ta como CTe). Pode aproveitar para alterar o summary por algo do tipo: "MDF-e abstract models generated by xsdata-odoo from the oficial xsd" ou algo do tipo que achar melhor por favor? (eu acabei de ajustar dessa forma no summary do l10n_br_nfe_spec em #3461)

@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch 5 times, most recently from 32a5ba0 to ad38578 Compare October 21, 2024 12:58
Copy link
Member

@rvalyi rvalyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nos logs eu vi esse warning: "2024-10-21 13:08:15,686 535 WARNING odoo odoo.modules.registry: res.partner: inconsistent 'compute_sudo' for computed fields: mdfe30_CNPJ, mdfe30_idEstrangeiro, mdfe30_CPF, mdfe30_choice6, mdfe30_CEP, mdfe30_fone, mdfe30_IE, mdfe30_choice8, mdfe30_choice9, mdfe30_choice10, mdfe30_choice11, mdfe30_choice12 " Na NFe a gente conseguiu corrigir isso.

Tb é ruim usar esses padrões mdfe30_choiceXY, seria melhor botar um nome mdfe30_choice_<alguma coisa explicita> assim como foi feito nos campos choice da NFe.

@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch 2 times, most recently from 714f1be to 23879d9 Compare October 21, 2024 13:28
@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch 5 times, most recently from 82c5121 to f2346a1 Compare October 21, 2024 18:12
@marcelsavegnago
Copy link
Member Author

nos logs eu vi esse warning: "2024-10-21 13:08:15,686 535 WARNING odoo odoo.modules.registry: res.partner: inconsistent 'compute_sudo' for computed fields: mdfe30_CNPJ, mdfe30_idEstrangeiro, mdfe30_CPF, mdfe30_choice6, mdfe30_CEP, mdfe30_fone, mdfe30_IE, mdfe30_choice8, mdfe30_choice9, mdfe30_choice10, mdfe30_choice11, mdfe30_choice12 " Na NFe a gente conseguiu corrigir isso.

Tb é ruim usar esses padrões mdfe30_choiceXY, seria melhor botar um nome mdfe30_choice_<alguma coisa explicita> assim como foi feito nos campos choice da NFe.

Done

@marcelsavegnago
Copy link
Member Author

@marcelsavegnago eu tinha errado no summary do manifest do modulo l10n_br_mdfe_spec (ta como CTe). Pode aproveitar para alterar o summary por algo do tipo: "MDF-e abstract models generated by xsdata-odoo from the oficial xsd" ou algo do tipo que achar melhor por favor? (eu acabei de ajustar dessa forma no summary do l10n_br_nfe_spec em #3461)

Done

@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch 3 times, most recently from 9220390 to 1a7defd Compare October 21, 2024 19:05
@marcelsavegnago marcelsavegnago marked this pull request as ready for review October 21, 2024 19:32
@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch from 1a7defd to 29d7794 Compare October 21, 2024 21:09
@marcelsavegnago marcelsavegnago force-pushed the 14.0-add-l10n_br_mdfe_rebased-escodoo-wip-withothercommits-spec-nfe-and-others3 branch from 29d7794 to 7796978 Compare October 21, 2024 21:12
@rvalyi
Copy link
Member

rvalyi commented Oct 21, 2024

@marcelsavegnago parabéns pelo trabalho!! Ficou OK para revisar?

def _build_attr(self, node, fields, vals, path, attr):
if attr[0] == "enderEmit" and self.env.context.get("edoc_type") == "in":
# we don't want to try build a related partner_id for enderEmit
# when importing an NFe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrigir NFe -> MDFe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants