-
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP][l10n_br_nfe] Import Product JSON
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
@@ -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") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
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 = { | ||
"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 | ||