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][WIP] l10n_br_fiscal, nfe: Adição da tag cBenef no XML #3561

Draft
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions l10n_br_fiscal/data/l10n_br_fiscal_comment_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,14 @@
<field name="comment_type">fiscal</field>
<field name="object">l10n_br_fiscal.document.mixin</field>
</record>

<record
id="fiscal_comment_codigo_do_beneficio_fiscal"
model="l10n_br_fiscal.comment"
>
<field name="name">Código de benefício fiscal</field>
<field name="comment"> cBenef: ${benefit_code}</field>
<field name="comment_type">fiscal</field>
<field name="object">l10n_br_fiscal.document.line.mixin</field>
</record>
</odoo>
20 changes: 19 additions & 1 deletion l10n_br_fiscal/models/document_line_mixin_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,20 @@ def _get_product_price(self):

self.price_unit = price.get(self.fiscal_operation_id.default_price_unit, 0.00)

def _get_benefit_code(self):
self.ensure_one()
document_lines = self.env["l10n_br_fiscal.document.line"].search(
[("document_id", "=", self.document_id.id)]
)

unique_benefit_codes = set()

for line in document_lines:
if line.icms_tax_benefit_id and line.icms_tax_benefit_id.code:
unique_benefit_codes.add(line.icms_tax_benefit_id.code)

return "|".join(unique_benefit_codes)

def __document_comment_vals(self):
self.ensure_one()
return {
Expand All @@ -351,8 +365,12 @@ def __document_comment_vals(self):

def _document_comment(self):
for d in self:
benefit_code = d._get_benefit_code()

comment_vals = d.__document_comment_vals()
comment_vals["benefit_code"] = benefit_code
d.additional_data = d.comment_ids.compute_message(
d.__document_comment_vals(), d.manual_additional_data
comment_vals, d.manual_additional_data
)

def _get_fiscal_partner(self):
Expand Down
Loading