Skip to content

Commit

Permalink
[FIX] l10n_br_fiscal: selection_add 'product'
Browse files Browse the repository at this point in the history
Some modules of the repo depend on stock and have
demo products of type 'product' (this type is added to
product.template in the stock module).
For some reason when running the tests, some inverse method fields
then fail when reading 'product' value for the product type.
It seems it is because l10n_br_fiscal doesn't depend on stock.
But we don't want such a dependency.
So to avoid the bug we add the 'product' value to the selection
which seems like an acceptable workaround.
  • Loading branch information
rvalyi committed Mar 24, 2024
1 parent d66f576 commit aa84dc8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions l10n_br_fiscal/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ def _get_default_ncm_id(self):
if fiscal_type == PRODUCT_FISCAL_TYPE_SERVICE:
return self.env.ref(NCM_FOR_SERVICE_REF)

# Some modules of the repo depend on stock and have
# demo products of type 'product' (this type is added to product.template
# in the stock module).
# For some reason when running the tests, some inverse method fields then fail when
# reading 'product' value for the product type. It seems it is because l10n_br_fiscal
# doesn't depend on stock. But we don't want such a dependency.
# So a workaround to avoid the bug we add the 'product' value to the selection.
type = fields.Selection(
selection_add=[("product", "Storable Product")],
ondelete={"product": "set consu"},
)

fiscal_type = fields.Selection(
selection=PRODUCT_FISCAL_TYPE,
company_dependent=True,
Expand Down

0 comments on commit aa84dc8

Please sign in to comment.