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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
72941aa
[ADD] l10n_br_mdfe: add new module
felipezago Sep 25, 2024
a46865c
[IMP] l10n_br_fiscal: mdfe serie, demo and others
felipezago Sep 25, 2024
ba6079e
[IMP] l10n_br_fiscal_edi: add MODELO_FISCAL_MDFE on workflow
felipezago Sep 25, 2024
abf5c10
[RFC] l10n_br_mdfe: refactor, fixes and others
marcelsavegnago Sep 25, 2024
8c277c5
[RFC] l10n_br_mdfe: refactor for multi-schema support
marcelsavegnago Oct 7, 2024
91908a8
[IMP] l10n_br_mdfe: add akretion and escodoo on contributors file
marcelsavegnago Oct 7, 2024
f0975c6
[IMP] l10n_br_fiscal: add manifesto fiscal operation and operation line
marcelsavegnago Oct 7, 2024
b86552c
[IMP] l10n_br_nfe: set product.product _nfe40_odoo_module
marcelsavegnago Oct 16, 2024
cf4c438
[FIX] l10n_br_nfe: add super on _generate_key, _document_export and _…
marcelsavegnago Oct 16, 2024
b7f0411
[RFC] l10n_br_mdfe_spec: refactor for multi-schema support
marcelsavegnago Oct 15, 2024
96a4a4c
[FIX] l10n_br_mdfe_spec: fix summary and module description file
marcelsavegnago Oct 21, 2024
3118530
[FIX] l10n_br_nfse_focus: fix tests
marcelsavegnago Oct 19, 2024
2dd6d50
[IMP] l10n_br_mdfe: add ROADMAP.rst file
marcelsavegnago Oct 21, 2024
d3e094d
[RFC] l10n_br_nfe: document.supplement refactor to stackedmodel
marcelsavegnago Oct 23, 2024
1673ed0
[IMP] l10n_br_mdfe: add co-author and maintainer
marcelsavegnago Oct 23, 2024
2ba211b
[RFC] l10n_br_fiscal_edi: rename method _valida_xml
marcelsavegnago Oct 23, 2024
8380926
[RFC] l10n_br_mdfe: rename method _valida_xml
marcelsavegnago Oct 23, 2024
d4b9e83
[RFC] l10n_br_nfe: rename method _valida_xml
marcelsavegnago Oct 23, 2024
b2eea00
[RFC] l10n_br_fiscal_edi: rename method _processador
marcelsavegnago Oct 23, 2024
37553d9
[RFC] l10n_br_mdfe: rename method _processador
marcelsavegnago Oct 23, 2024
461a526
[RFC] l10n_br_nfe: rename method _processador
marcelsavegnago Oct 23, 2024
724a7df
[RFC] l10n_br_mdfe: remove unnecessary code
marcelsavegnago Oct 23, 2024
08b37f9
[IMP] l10n_br_fiscal: bump minor version
marcelsavegnago Oct 23, 2024
0abf424
[IMP] l10n_br_fiscal_edi: bump minor version
marcelsavegnago Oct 23, 2024
b8e3412
[IMP] l10n_br_mdfe_spec: bump minor version
marcelsavegnago Oct 23, 2024
762d56e
[IMP] l10n_br_nfe: bump minor version
marcelsavegnago Oct 23, 2024
e5b6e88
[IMP] l10n_br_nfse_focus: bump patch version
marcelsavegnago Oct 23, 2024
d787a49
[IMP] l10n_br_mdfe: add module usage information
marcelsavegnago Oct 23, 2024
ecd6eb3
[FIX] l10n_br_mdfe: change kmee maintainer
marcelsavegnago Oct 23, 2024
b4151ed
[RFC] l10n_br_mdfe: refactor methods name
marcelsavegnago Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l10n_br_fiscal/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"maintainers": ["renatonlima"],
"website": "https://github.com/OCA/l10n-brazil",
"development_status": "Production/Stable",
"version": "14.0.23.6.0",
"version": "14.0.23.7.0",
"depends": [
"product",
"l10n_br_base",
Expand Down
2 changes: 2 additions & 0 deletions l10n_br_fiscal/constants/fiscal.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,12 @@
MODELO_FISCAL_CFE = "59"
MODELO_FISCAL_CUPOM_FISCAL_ECF = "2D"
MODELO_FISCAL_CTE = "57"
MODELO_FISCAL_MDFE = "58"
MODELO_FISCAL_RL = "04" # Produto Rural
MODELO_FISCAL_01 = "01"
MODELO_FISCAL_04 = "04"


MODELO_FISCAL_EMISSAO_PRODUTO = [
MODELO_FISCAL_NFE,
MODELO_FISCAL_NFCE,
Expand Down
1 change: 1 addition & 0 deletions l10n_br_fiscal/data/l10n_br_fiscal.document.type.csv
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"document_30","30","Bilhete/Recibo do Passageiro","False",,,"icms"
"document_55","55","Nota Fiscal Eletrônica","True","NFe","nf-e","icms"
"document_57","57","Conhecimento de Transporte Eletrônico – CT-e","True","CTe","ct-e","icms"
"document_58","58","Manifesto Eletrônico de Documentos Fiscais","True","MDFe","mdf-e","icms"
"document_59","59","Cupom Fiscal Eletrônico - CF-e","True","CFe","cf-e","icms"
"document_60","60","Cupom Fiscal Eletrônico CF-e-ECF","True",,,"icms"
"document_65","65","Nota Fiscal Eletrônica ao Consumidor Final – NFC-e","True","NFe","nfc-e","icms"
Expand Down
18 changes: 18 additions & 0 deletions l10n_br_fiscal/data/operation_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,24 @@
<field name="state">approved</field>
</record>

<record id="fo_manifesto" model="l10n_br_fiscal.operation">
<field name="code">Manifesto</field>
<field name="name">Manifesto</field>
<field name="fiscal_operation_type">out</field>
<field name="fiscal_type">other</field>
<field name="default_price_unit">sale_price</field>
<field name="state">approved</field>
</record>

<record id="fo_manifesto_manifesto" model="l10n_br_fiscal.operation.line">
<field name="fiscal_operation_id" ref="l10n_br_fiscal.fo_manifesto" />
<field name="name">Manifesto</field>
<field name="ind_ie_dest">1</field>
<field name="add_to_amount">False</field>
<field name="document_type_id" ref="l10n_br_fiscal.document_58" />
<field name="state">approved</field>
</record>

<!-- l10n_br_fiscal.operation relations -->
<record id="fo_venda" model="l10n_br_fiscal.operation">
<field name="return_fiscal_operation_id" ref="fo_devolucao_venda" />
Expand Down
16 changes: 16 additions & 0 deletions l10n_br_fiscal/demo/company_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@
<field name="active">True</field>
</record>

<record id="empresa_lc_document_58_serie_1" model="l10n_br_fiscal.document.serie">
<field name="code">1</field>
<field name="name">Série 1</field>
<field name="document_type_id" ref="l10n_br_fiscal.document_58" />
<field name="company_id" ref="l10n_br_base.empresa_lucro_presumido" />
<field name="active">True</field>
</record>

<record id="empresa_lc_document_65_serie_1" model="l10n_br_fiscal.document.serie">
<field name="code">1</field>
<field name="name">Série 1</field>
Expand Down Expand Up @@ -194,6 +202,14 @@
<field name="active">True</field>
</record>

<record id="empresa_sn_document_58_serie_1" model="l10n_br_fiscal.document.serie">
<field name="code">1</field>
<field name="name">Série 1</field>
<field name="document_type_id" ref="l10n_br_fiscal.document_58" />
<field name="company_id" ref="l10n_br_base.empresa_simples_nacional" />
<field name="active">True</field>
</record>

<record
id="icms_tax_definition_empresa_simples_nacional"
model="l10n_br_fiscal.tax.definition"
Expand Down
4 changes: 4 additions & 0 deletions l10n_br_fiscal/models/document_mixin_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,7 @@ def _operation_domain(self):
copy=False,
index=True,
)

key_random_code = fields.Char(string="Document Key Random Code")
key_check_digit = fields.Char(string="Document Key Check Digit")
total_weight = fields.Float(string="Total Weight")
11 changes: 11 additions & 0 deletions l10n_br_fiscal/models/document_related.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@

document_date = fields.Date(string="Data")

currency_id = fields.Many2one(
comodel_name="res.currency",
default=lambda self: self.env.company.currency_id,
)
document_total_weight = fields.Float(string="Peso Total")
document_total_amount = fields.Monetary(
string="Valor Total", currency_field="currency_id"
)

@api.constrains("document_key")
def _check_key(self):
for record in self:
Expand Down Expand Up @@ -92,6 +101,8 @@
return False

self.document_type_id = related.document_type_id
self.document_total_amount = related.amount_total
self.document_total_weight = related.total_weight

Check warning on line 105 in l10n_br_fiscal/models/document_related.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_fiscal/models/document_related.py#L104-L105

Added lines #L104 - L105 were not covered by tests

if related.document_type_id.electronic:
self.document_key = related.document_key
Expand Down
10 changes: 10 additions & 0 deletions l10n_br_fiscal/views/document_related_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@
attrs="{'invisible': [('document_type_code', '!=', '04')]}"
/>
</group>
<group
string="Totais"
attrs="{'invisible': [('document_type_code', 'not in', ('55', '57', '58'))]}"
>
<field name="document_total_weight" />
<field
name="document_total_amount"
attrs="{'invisible': [('document_related_id', '!=', False)]}"
/>
</group>
</form>
</field>
</record>
Expand Down
1 change: 1 addition & 0 deletions l10n_br_fiscal/views/document_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@
<page name="delivery" string="Delivery">
<group>
<field name="force_compute_delivery_costs_by_total" />
<field name="total_weight" />
</group>
</page>
<page name="amounts" string="Amounts">
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_fiscal_edi/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"maintainers": ["renatonlima", "rvalyi", "mileo"],
"website": "https://github.com/OCA/l10n-brazil",
"development_status": "Beta",
"version": "14.0.1.1.1",
"version": "14.0.1.2.0",
"depends": [
"l10n_br_fiscal",
],
Expand Down
14 changes: 14 additions & 0 deletions l10n_br_fiscal_edi/models/document_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from odoo.addons.l10n_br_fiscal.constants.fiscal import (
DOCUMENT_ISSUER_COMPANY,
MODELO_FISCAL_CTE,
MODELO_FISCAL_MDFE,
MODELO_FISCAL_NFCE,
MODELO_FISCAL_NFE,
MODELO_FISCAL_NFSE,
Expand Down Expand Up @@ -236,6 +237,7 @@
MODELO_FISCAL_NFE,
MODELO_FISCAL_NFCE,
MODELO_FISCAL_CTE,
MODELO_FISCAL_MDFE,
):
date = fields.Datetime.context_timestamp(record, record.document_date)
chave_edoc = ChaveEdoc(
Expand All @@ -252,6 +254,9 @@
numero_serie=record.document_serie or "",
validar=False,
)
record.key_random_code = chave_edoc.codigo_aleatorio
record.key_check_digit = chave_edoc.digito_verificador

Check warning on line 258 in l10n_br_fiscal_edi/models/document_workflow.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_fiscal_edi/models/document_workflow.py#L257-L258

Added lines #L257 - L258 were not covered by tests

# TODO: Implementar campos no Odoo
# record.key_number = chave_edoc.campos
# record.key_formated = ' '.joint(chave_edoc.partes())
Expand Down Expand Up @@ -385,3 +390,12 @@
"this fical document you are not the document issuer"
)
)

def _document_qrcode(self):
pass

Check warning on line 395 in l10n_br_fiscal_edi/models/document_workflow.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_fiscal_edi/models/document_workflow.py#L395

Added line #L395 was not covered by tests

def _edoc_processor(self):
pass

Check warning on line 398 in l10n_br_fiscal_edi/models/document_workflow.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_fiscal_edi/models/document_workflow.py#L398

Added line #L398 was not covered by tests

def _validate_xml(self, xml_file):
pass

Check warning on line 401 in l10n_br_fiscal_edi/models/document_workflow.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_fiscal_edi/models/document_workflow.py#L401

Added line #L401 was not covered by tests
marcelsavegnago marked this conversation as resolved.
Show resolved Hide resolved
144 changes: 144 additions & 0 deletions l10n_br_mdfe/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
====
MDFe
====

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c7c356eef2c69c2d36d3dfea44bca958c3353c323f95319f8ec7f3e3022b7098
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_mdfe
:alt: OCA/l10n-brazil
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-brazil-14-0/l10n-brazil-14-0-l10n_br_mdfe
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Este módulo permite a emissão de MDF-e.

Mais especificamente ele:
* mapea os campos de MDF-e do módulo ``l10n_br_mdfe_spec`` com os campos Odoo.
* usa a logica do módulo ``spec_driven_model`` para realizar esse mapeamento de forma dinâmica, em especial ele usa o sistema de modelos com várias camadas, ou ``StackedModel``, com os modelos ``l10n_br_fiscal.document`` e ``l10n_br_fiscal.document.related`` que tem varios niveis hierarquicos de elementos XML que estão sendo denormalizados dentro desses modelos Odoo 
* tem wizards para implementar a comunicação SOAP de MDF-e com a SEFAZ (Autorização, Cancelamento, Encerramento...)

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module you need to set a digital certificate on the company, and also set the company edoc processor.

Usage
=====

Para utilizar o módulo `l10n_br_mdfe` em conjunto com o módulo `l10n_br_account`, é necessário configurar uma linha de operação fiscal que não adicione valor ao montante do documento, uma vez que o MDF-e (Manifesto Eletrônico de Documentos Fiscais) não possui valor financeiro.

**Passo a Passo:**

1. **Criar uma Fatura:**
- Defina o tipo de documento como **58 (MDFe)**.

2. **Configurar o Parceiro da Fatura:**
- Configure o parceiro para ser o mesmo da empresa emissora do MDF-e.

3. **Adicionar uma Linha na Aba Produtos:**
- Adicione uma linha de fatura com a operação fiscal previamente configurada.
- **Não recomedamos que informe um produto** ou utilize um produto que **não possua CFOP** (Código Fiscal de Operações e Prestações), ou que o CFOP esteja configurado para **não gerar valor financeiro** e esteja atento a dados como impostos e afins.

4. **Acesse os detalhes fiscais da fatura e informe os demais dados necessário para emissão do MDF-e:**
- Preencha os campos obrigatórios para emissão do MDF-e, como UF de descarregamento, município de descarregamento, etc.

5. **Valide o MDF-e, verifique os dados do XML e envie para a SEFAZ:**
- Após preencher todos os dados necessários, valide o MDF-e e envie para a SEFAZ.

**Considerações Adicionais**

- **Operação Fiscal:** Certifique-se de que a operação fiscal esteja parametrizada corretamente para evitar a adição de valores financeiros ao documento.
- **CFOP:** No caso de utilização de um produto cadastrado e que carregue o CFOP para a linha da fatura, verifique a configuração do CFOP para garantir que ele não gere impacto financeiro no montante da fatura.

Seguindo esses passos, o módulo `l10n_br_mdfe` funcionará corretamente em conjunto com o `l10n_br_account`, permitindo a emissão de MDF-e sem valores financeiros associados.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-brazil/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-brazil/issues/new?body=module:%20l10n_br_mdfe%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* KMEE
* Escodoo

Contributors
~~~~~~~~~~~~

* `KMEE <https://kmee.com.br>`_:

* Felipe Zago Rodrigues <[email protected]>
* Ygor Carvalho <[email protected]>

* `ESCODOO <https://escodoo.com.br>`_:

* Marcel Savegnago <[email protected]>

* `AKRETION <https://akretion.com/pt-BR/>`_:

* Raphaël Valyi <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-mileo| image:: https://github.com/mileo.png?size=40px
:target: https://github.com/mileo
:alt: mileo
.. |maintainer-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px
:target: https://github.com/marcelsavegnago
:alt: marcelsavegnago

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-mileo| |maintainer-marcelsavegnago|

This module is part of the `OCA/l10n-brazil <https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_mdfe>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions l10n_br_mdfe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_init_hook
48 changes: 48 additions & 0 deletions l10n_br_mdfe/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2023 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "MDFe",
"summary": """Brazilian Eletronic Invoice MDF-e""",
"version": "14.0.1.0.0",
"category": "Localisation",
"license": "AGPL-3",
"author": "KMEE,Escodoo,Odoo Community Association (OCA)",
"maintainers": ["mileo", "marcelsavegnago"],
"website": "https://github.com/OCA/l10n-brazil",
"development_status": "Alpha",
"depends": [
"l10n_br_fiscal_edi",
"l10n_br_fiscal_certificate",
"l10n_br_mdfe_spec",
"spec_driven_model",
],
"data": [
"security/ir.model.access.csv",
"data/ir_config_parameter.xml",
"views/document.xml",
"views/mdfe_action.xml",
"views/mdfe_menu.xml",
"views/res_company.xml",
"views/transporte.xml",
"views/res_partner.xml",
"views/product_product.xml",
"views/modal/modal_aquaviario.xml",
"views/modal/modal_rodoviario.xml",
"views/modal/modal_ferroviario.xml",
],
"demo": [
"demo/fiscal_document_demo.xml",
"demo/company_demo.xml",
],
"post_init_hook": "post_init_hook",
"installable": True,
"auto_install": False,
"external_dependencies": {
"python": [
"nfelib<=2.0.7",
"erpbrasil.transmissao>=1.1.0",
"erpbrasil.edoc>=2.5.2",
]
},
}
Loading
Loading