From 19e8dae698be9285924cfab913104c01cf9a1bc4 Mon Sep 17 00:00:00 2001 From: Carlos Date: Tue, 29 Oct 2024 13:47:37 -0300 Subject: [PATCH] [FIX] l10n_br_fiscal: ncm starting with 09 conflicts with service type --- l10n_br_fiscal/models/product_mixin.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/l10n_br_fiscal/models/product_mixin.py b/l10n_br_fiscal/models/product_mixin.py index 05ebe1aeeec1..5e5b87c88561 100644 --- a/l10n_br_fiscal/models/product_mixin.py +++ b/l10n_br_fiscal/models/product_mixin.py @@ -24,7 +24,7 @@ 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: @@ -32,5 +32,9 @@ def _onchange_ncm_id(self): [("code", "=", r.ncm_id.code[0:2])] ) - if r.fiscal_genre_id.code == 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