Skip to content

Commit

Permalink
[FIX] l10n_br_fiscal: ncm starting with 09 conflicts with service type
Browse files Browse the repository at this point in the history
  • Loading branch information
crsilveira authored and CristianoMafraJunior committed Oct 28, 2024
1 parent 9f53a24 commit cb52f1b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions l10n_br_fiscal/models/product_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ def _onchange_fiscal_type(self):
else:
r.tax_icms_or_issqn = TAX_DOMAIN_ICMS

@api.onchange("ncm_id", "fiscal_genre_id")
@api.onchange("ncm_id")
def _onchange_ncm_id(self):
for r in self:
if r.ncm_id:
r.fiscal_genre_id = self.env["l10n_br_fiscal.product.genre"].search(
[("code", "=", r.ncm_id.code[0:2])]
)

if r.fiscal_genre_id.code == PRODUCT_FISCAL_TYPE_SERVICE:
if r.fiscal_type == PRODUCT_FISCAL_TYPE_SERVICE:
r.ncm_id = self.env.ref(NCM_FOR_SERVICE_REF)

@api.onchange("fiscal_genre_id")
def _onchange_fiscal_genre_id(self):
for r in self:
if r.fiscal_genre_id and r.ncm_id:
if r.fiscal_genre_id.code != r.ncm_id.code[0:2]:
r.ncm_id = False

Check warning on line 43 in l10n_br_fiscal/models/product_mixin.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_fiscal/models/product_mixin.py#L43

Added line #L43 was not covered by tests

0 comments on commit cb52f1b

Please sign in to comment.