From be7773353e32286b328facee584a2935ca9cd5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Mon, 4 May 2020 11:14:27 +0200 Subject: [PATCH] [FIX] sale_timesheet: Consider NULL as a False value A NULL value in the database column is considered as a False value for boolean fields in Odoo. Hence the sql constraint should reflect this semantic. Otherwise, the constraint might not be applicable when installing the sale_timesheet module. Task 2192763 --- addons/sale_timesheet/models/project.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index f9df7e809c7..42ceb21ff93 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -47,7 +47,14 @@ class Project(models.Model): default=_default_timesheet_product_id) _sql_constraints = [ - ('timesheet_product_required_if_billable_and_timesheets', "CHECK((allow_billable = 't' AND allow_timesheets = 't' AND timesheet_product_id IS NOT NULL) OR (allow_billable = 'f') OR (allow_timesheets = 'f'))", 'The timesheet product is required when the task can be billed and timesheets are allowed.'), + ('timesheet_product_required_if_billable_and_timesheets', """ + CHECK( + (allow_billable = 't' AND allow_timesheets = 't' AND timesheet_product_id IS NOT NULL) + OR (allow_billable = 'f') + OR (allow_timesheets = 'f') + OR (allow_billable IS NULL) + OR (allow_timesheets IS NULL) + )""", 'The timesheet product is required when the task can be billed and timesheets are allowed.'), ] @api.depends('billable_type', 'allow_billable', 'sale_order_id', 'partner_id')