-
-
Notifications
You must be signed in to change notification settings - Fork 250
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][RFC] l10n_br_nfe: refactor nfce qrcode methods #3542
Open
DiegoParadeda
wants to merge
5
commits into
OCA:14.0
Choose a base branch
from
kmee:fix/nfce-qrcode
base: 14.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b13c722
[RFC] l10n_br_nfe: refactor nfce qrcode methods
marcelsavegnago dac4511
[FIX] l10n_br_nfe: unlink nfesupl before reassigning
DiegoParadeda 32e7c19
[FIX] l10n_br_nfe: nfce test csc vars have strict pattern
DiegoParadeda 31f8b6d
[FIX] l10n_br_nfe: nfce test contingency
DiegoParadeda 2fb1c1a
[FIX] l10n_br_nfe: NFCE contingencia processador
DiegoParadeda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,6 +1,7 @@ | ||
# Copyright 2023 KMEE (Felipe Zago Rodrigues <[email protected]>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields | ||
from odoo.tests import TransactionCase | ||
|
||
|
||
|
@@ -54,8 +55,24 @@ def prepare_account_move_nfce(self): | |
"payment_mode_id": payment_mode.id, | ||
"company_id": self.env.ref("base.main_company").id, | ||
"line_ids": [ | ||
(0, 0, {"account_id": receivable_account_id.id, "credit": 10}), | ||
(0, 0, {"account_id": payable_account_id.id, "debit": 10}), | ||
( | ||
0, | ||
0, | ||
{ | ||
"date_maturity": fields.Date.today(), | ||
"account_id": receivable_account_id.id, | ||
"credit": 10, | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"date_maturity": fields.Date.today(), | ||
"account_id": payable_account_id.id, | ||
"debit": 10, | ||
}, | ||
), | ||
], | ||
} | ||
) | ||
|
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 |
---|---|---|
|
@@ -896,10 +896,17 @@ def _serialize(self, edocs): | |
for record in self.with_context(lang="pt_BR").filtered( | ||
filter_processador_edoc_nfe | ||
): | ||
processor = record.processador_edoc | ||
|
||
# TODO: Avaliar a possibilidade de remover esse flush e invalidate | ||
record.flush() | ||
record.invalidate_cache() | ||
inf_nfe = record._build_binding("nfe", "40") | ||
|
||
if hasattr(record, "move_ids") and record.move_ids: | ||
record.move_ids.processador_edoc = processor | ||
record.processador_edoc = processor | ||
|
||
Comment on lines
+899
to
+909
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. poderia explicar um pouco qual a necessidade desse código? |
||
inf_nfe_supl = None | ||
if record.nfe40_infNFeSupl: | ||
inf_nfe_supl = record.nfe40_infNFeSupl._build_binding("nfe", "40") | ||
|
@@ -1226,14 +1233,25 @@ def _is_nfe_found(c_stat): | |
|
||
def _prepare_nfce_send(self): | ||
self.ensure_one() | ||
self._prepare_payments_for_nfce() | ||
self.nfe40_infNFeSupl = self.env["l10n_br_fiscal.document.supplement"].create( | ||
{ | ||
"nfe40_qrCode": self.get_nfce_qrcode(), | ||
"nfe40_urlChave": self.get_nfce_qrcode_url(), | ||
} | ||
self.nfe40_detPag.filtered(lambda p: p.nfe40_tPag == "99").write( | ||
{"nfe40_xPag": "Outros"} | ||
) | ||
|
||
def _document_qrcode(self): | ||
super()._document_qrcode() | ||
|
||
for record in self.filtered(lambda d: d.document_type == MODELO_FISCAL_NFCE): | ||
if record.nfe40_infNFeSupl: | ||
record.nfe40_infNFeSupl.unlink() | ||
record.nfe40_infNFeSupl = self.env[ | ||
"l10n_br_fiscal.document.supplement" | ||
].create( | ||
{ | ||
"qrcode": record.get_nfce_qrcode(), | ||
"url_key": record.get_nfce_qrcode_url(), | ||
} | ||
) | ||
|
||
def _eletronic_document_send(self): | ||
super()._eletronic_document_send() | ||
for record in self.filtered(filter_processador_edoc_nfe): | ||
|
@@ -1517,6 +1535,8 @@ def get_nfce_qrcode(self): | |
processador = self._edoc_processor() | ||
if self.nfe_transmission == "1": | ||
return processador.monta_qrcode(self.document_key) | ||
if not self.serialize() or not len(self.serialize()): | ||
return | ||
|
||
serialized_doc = self.serialize()[0] | ||
xml = processador.assina_raiz(serialized_doc, serialized_doc.infNFe.Id) | ||
|
@@ -1525,15 +1545,11 @@ def get_nfce_qrcode(self): | |
def get_nfce_qrcode_url(self): | ||
if self.document_type != MODELO_FISCAL_NFCE: | ||
return | ||
if self._edoc_processor() is None: | ||
return | ||
|
||
return self._edoc_processor().consulta_qrcode_url | ||
|
||
def _prepare_payments_for_nfce(self): | ||
for rec in self.filtered(lambda d: d.document_type == MODELO_FISCAL_NFCE): | ||
rec.nfe40_detPag.filtered(lambda p: p.nfe40_tPag == "99").write( | ||
{"nfe40_xPag": "Outros"} | ||
) | ||
|
||
def action_danfe_nfce_report(self): | ||
return ( | ||
self.env["ir.actions.report"] | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Porque pular linhas antes e depois? Não me parece que essas duas linhas seriam um bloco logico espcial, logo não acho bom pular linhas antes e depois. Eu perdi algo?