You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
739 B

  1. # License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0
  2. from odoo import models, fields, api, _
  3. from odoo.exceptions import ValidationError
  4. class ProductProduct(models.Model):
  5. _inherit = "product.product"
  6. @api.constrains("lst_price", "initial_discount", "fixed_discount")
  7. def check_discount_fixed(self):
  8. for product in self:
  9. if (
  10. product.initial_discount == "fixed"
  11. and product.lst_price <= product.initial_discount
  12. ):
  13. raise ValidationError(
  14. _(
  15. "Fixed discount for 1st membership must be less than the product template or any of its variants sale price."
  16. )
  17. )