Skip to content

Commit

Permalink
[IMP][l10n_br_nfe] Import Product JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
mileo committed Jan 31, 2025
1 parent ffd5801 commit aaa0bc6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion l10n_br_nfe/models/document_line.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 Akretion (Raphaël Valyi <[email protected]>)
# Copyright 2020 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import json
import sys
from enum import Enum

Expand Down Expand Up @@ -1057,6 +1057,8 @@ def _prepare_import_dict(
values = super()._prepare_import_dict(
values, model, parent_dict, defaults_model
)
values["line_import_json"] = json.dumps(values)

if not values.get("name"):
values["name"] = values.get("nfe40_xProd")
values["default_code"] = values.get("nfe40_cProd")
Expand Down
1 change: 1 addition & 0 deletions l10n_br_nfe/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import l10n_br_account_nfe_export_invoice
from . import l10n_br_account_nfe_export
from . import document_import_wizard
from . import document_line_import_wizard
34 changes: 34 additions & 0 deletions l10n_br_nfe/wizards/document_line_import_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2025 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models

from odoo.addons.l10n_br_fiscal.constants.fiscal import (
MODELO_FISCAL_NFCE,
MODELO_FISCAL_NFE,
)


class L10n_br_fiscalDocumentLineImportWizard(models.TransientModel):
_inherit = "l10n_br_fiscal.document.line.import.wizard"

def _prepare_onchange_document_line_id(self):
res = super()._prepare_onchange_document_line_id()

Check warning on line 16 in l10n_br_nfe/wizards/document_line_import_wizard.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfe/wizards/document_line_import_wizard.py#L16

Added line #L16 was not covered by tests
if self.document_line_id.document_id.document_type in [
MODELO_FISCAL_NFE,
MODELO_FISCAL_NFCE,
]:
if self.document_line_id.line_import_json:
line_json = self.document_line_id.line_import_json
vals = {

Check warning on line 23 in l10n_br_nfe/wizards/document_line_import_wizard.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfe/wizards/document_line_import_wizard.py#L22-L23

Added lines #L22 - L23 were not covered by tests
"document_code": line_json.get("nfe40_cProd"),
"document_ean": line_json.get("nfe40_cEAN"),
"document_name": line_json.get("nfe40_xProd"),
"document_qty": line_json.get("nfe40_qCom"),
"document_uom": line_json.get("nfe40_uCom"),
"document_uom_trib": line_json.get("nfe40_uTrib"),
# "document_ncm_id": document_line.ncm_id.id,
# "document_cfop_id": document_line.cfop_id.id,
}
self.update(vals)
return res

Check warning on line 34 in l10n_br_nfe/wizards/document_line_import_wizard.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfe/wizards/document_line_import_wizard.py#L33-L34

Added lines #L33 - L34 were not covered by tests

0 comments on commit aaa0bc6

Please sign in to comment.