Skip to content

Commit

Permalink
account_fiscal_product_rule: have constraint when create new fiscal p…
Browse files Browse the repository at this point in the history
…roduct rule in the fiscal position
  • Loading branch information
chafique-delli committed Sep 8, 2022
1 parent 2fd3dc9 commit b9b6906
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class AccountFiscalPositionProductRule(models.Model):
)
company_id = fields.Many2one(related="fiscal_position_id.company_id")

@api.constrains("product_tmpl_ids")
def _check_no_duplicate_fiscal_position_on_product(self):
self.product_tmpl_ids._check_no_duplicate_fiscal_position()

@api.constrains("product_category_ids")
def _check_no_duplicate_fiscal_position_on_category(self):
self.product_category_ids._check_no_duplicate_fiscal_position()


class ProductRuleMixin(models.AbstractModel):
_name = "product.rule.mixin"
Expand All @@ -35,7 +43,6 @@ class ProductRuleMixin(models.AbstractModel):
def _check_no_duplicate_fiscal_position(self):
for record in self:
fps = []
# import pdb;pdb.set_trace()
for rule in record.fiscal_position_product_rule_ids:
if rule.fiscal_position_id in fps:
raise ValidationError(
Expand Down

0 comments on commit b9b6906

Please sign in to comment.