Skip to content

Commit

Permalink
product_expiry_simple: use_expiry_date converted to computed field
Browse files Browse the repository at this point in the history
Field 'use_expiry_date' on product.template is now a computed field, like
the native 'tracking' field.
  • Loading branch information
alexis-via committed Sep 26, 2024
1 parent 9cc142d commit e0522c4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion product_expiry_simple/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
class ProductTemplate(models.Model):
_inherit = "product.template"

use_expiry_date = fields.Boolean()
use_expiry_date = fields.Boolean(
compute="_compute_use_expiry_date", store=True, readonly=False, precompute=True
)

@api.depends("tracking")
def _compute_use_expiry_date(self):
self.filtered(lambda pt: pt.tracking == "none").use_expiry_date = False

@api.constrains("tracking", "use_expiry_date")
def _check_use_expiry_date(self):
Expand Down

0 comments on commit e0522c4

Please sign in to comment.