From a85ec9b97ebbb3426f20db87bbc8a3f87e63b684 Mon Sep 17 00:00:00 2001 From: miguelpadin Date: Fri, 4 Jun 2021 13:03:58 +0200 Subject: [PATCH] [FIX] pms constraint pricelist items daily & consumption dates --- pms/models/product_pricelist.py | 5 +---- pms/tests/test_pms_pricelist.py | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pms/models/product_pricelist.py b/pms/models/product_pricelist.py index e1c36e30b..db3811c9b 100644 --- a/pms/models/product_pricelist.py +++ b/pms/models/product_pricelist.py @@ -146,13 +146,10 @@ class ProductPricelist(models.Model): for record in self: if record.item_ids: for item in record.item_ids: - days_diff = ( - item.date_end_consumption - item.date_start_consumption - ).days if record.pricelist_type == "daily" and ( item.compute_price != "fixed" or len(record.pms_property_ids) != 1 - or days_diff > 1 + or item.date_end_consumption != item.date_start_consumption ): raise ValidationError( _( diff --git a/pms/tests/test_pms_pricelist.py b/pms/tests/test_pms_pricelist.py index 47633b4cf..7e04d8386 100644 --- a/pms/tests/test_pms_pricelist.py +++ b/pms/tests/test_pms_pricelist.py @@ -870,9 +870,8 @@ class TestPmsPricelist(common.SavepointCase): "compute_price": "fixed", "applied_on": "0_product_variant", "product_id": self.room_type.product_id.id, - "date_start_consumption": datetime.datetime.now(), - "date_end_consumption": datetime.datetime.today() - + datetime.timedelta(days=1), + "date_start_consumption": datetime.date.today(), + "date_end_consumption": datetime.date.today(), } ) self.pricelist_test = self.env["product.pricelist"].create(