Skip to content

Commit

Permalink
[ADD] custom NFE DI class
Browse files Browse the repository at this point in the history
  • Loading branch information
renatonlima committed Dec 10, 2024
1 parent 1206a6e commit 4a20dca
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
1 change: 1 addition & 0 deletions l10n_br_nfe/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# Views
"views/res_company_view.xml",
"views/nfe_document_view.xml",
"views/nfe_di_view.xml",
"views/res_config_settings_view.xml",
"views/mde/mde_views.xml",
"views/dfe/dfe_views.xml",
Expand Down
1 change: 1 addition & 0 deletions l10n_br_nfe/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from . import document
from . import document_line
from . import document_supplement
from . import nfe_di
from . import res_city
from . import res_config_settings
from . import cfop
Expand Down
60 changes: 60 additions & 0 deletions l10n_br_nfe/models/nfe_di.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2021 Akretion (Renato Lima <[email protected]>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models

TPVIATRANSP_DI = [
("1", "1 - Maritima"),
("2", "2 - Fluvial"),
("3", "3 - Lacustre"),
("4", "4 - Aerea"),
("5", "5 - Postal"),
("6", "6 - Ferroviaria"),
("7", "7 - Rodoviaria"),
("8", "8 - Conduto/Rede Transmissão"),
("9", "9 - Meios Próprios"),
("10", "10 - Entrada/Saída Ficta"),
("11", "11 - Courier"),
("12", "12 - Em mãos"),
("13", "13 - Por reboque"),
]

TPINTERMEDIO_DI = [
("1", "1 - Por conta própria"),
("2", "2 - Por conta e ordem"),
("3", "3 - Encomenda"),
]


class NFeDI(models.AbstractModel):
_inherit = "nfe.40.di"

state_clearance_id = fields.Many2one(
comodel_name="res.country.state",
string="State Clearance",
)

nfe40_UFDesemb = fields.Char(
related="state_clearance_id.code",
)

nfe40_tpViaTransp = fields.Selection(
selection=TPVIATRANSP_DI,
)

nfe40_tpIntermedio = fields.Selection(
selection=TPINTERMEDIO_DI,
)

partner_acquirer_id = fields.Many2one(
comodel_name="res.partner",
string="Partner Acquirer"
)

nfe40_CNPJ = fields.Char(
related="partner_acquirer_id.nfe40_CNPJ",
)

nfe40_UFTerceiro = fields.Char(
related="partner_acquirer_id.state_id.code",
)
66 changes: 66 additions & 0 deletions l10n_br_nfe/views/nfe_di_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="nfe_di_tree" model="ir.ui.view">
<field name="name">nfe.40.di.tree</field>
<field name="model">nfe.40.di</field>
<field name="arch" type="xml">
<tree string="Declaração de Importação">
<field name="nfe40_nDI" />
<field name="nfe40_dDI" />
<field name="nfe40_UFDesemb" />
<field name="nfe40_xLocDesemb" />
<field name="nfe40_dDesemb" />
<field name="nfe40_tpViaTransp" />
<field name="nfe40_tpIntermedio" />
<field name="partner_acquirer_id" />
</tree>
</field>
</record>

<record id="nfe_di_form" model="ir.ui.view">
<field name="name">nfe.40.di.form</field>
<field name="model">nfe.40.di</field>
<field name="arch" type="xml">
<form string="Declaração de Importação">
<group>
<group>
<field name="nfe40_nDI" />
<field name="nfe40_dDI" />
<field name="nfe40_tpViaTransp" />
<field name="nfe40_tpIntermedio" />
<field name="partner_acquirer_id" />
<field name="nfe40_CNPJ" invisible="1" />
<field name="nfe40_UFTerceiro" invisible="1" />
<field name="nfe40_cExportador" invisible="1" />
<field name="nfe40_vAFRMM" />
</group>
<group>
<field name="nfe40_UFDesemb" />
<field name="nfe40_xLocDesemb" />
<field name="nfe40_dDesemb" />
</group>
</group>
<field name="nfe40_adi">
<tree>
<field name="nfe40_nAdicao" />
<field name="nfe40_nSeqAdic" />
<field name="nfe40_cFabricante" />
<field name="nfe40_vDescDI" />
<field name="nfe40_nDraw" />
</tree>
<form>
<group>
<field name="nfe40_nAdicao" />
<field name="nfe40_nSeqAdic" />
<field name="nfe40_cFabricante" />
<field name="nfe40_vDescDI" />
<field name="nfe40_nDraw" />
</group>
</form>
</field>
</form>
</field>
</record>

</odoo>

0 comments on commit 4a20dca

Please sign in to comment.