From dc77b35f9fc9f577dfb582bf9f4d3b90c28c761b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Sun, 20 Nov 2022 12:17:00 +0100 Subject: [PATCH] [IMP]pms: change product_pricelist.availability_plan_id from required to constrain --- pms/models/product_pricelist.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pms/models/product_pricelist.py b/pms/models/product_pricelist.py index 1f2f57067..87ff8b5eb 100644 --- a/pms/models/product_pricelist.py +++ b/pms/models/product_pricelist.py @@ -164,6 +164,17 @@ class ProductPricelist(models.Model): ) ) + @api.constrains("is_pms_available", "availability_plan_id") + def _check_is_pms_available(self): + for record in self: + if record.is_pms_available and not record.availability_plan_id: + raise ValidationError( + _( + "If the pricelist is available in the PMS, " + "you must select an availability plan" + ) + ) + # Action methods # Constraints and onchanges # @api.constrains("pricelist_type", "pms_property_ids")