From 1d0b5072f83f765ff2443d752b98dacb7e8be2bb Mon Sep 17 00:00:00 2001 From: jdoutreloux Date: Wed, 11 Mar 2020 15:06:46 +0000 Subject: [PATCH] [FIX] sale_timesheet : fix the default value for timesheet_product_id The timesheet_product_id is required if allow_billable is True and it should have a default value. Task-2199650 closes odoo/odoo#48028 Signed-off-by: Yannick Tivisse (yti) --- addons/sale_timesheet/models/project.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index 2049780ecc6..6e70d6cfa8a 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -19,6 +19,9 @@ class Project(models.Model): result['timesheet_product_id'] = default_product.id return result + def _default_timesheet_product_id(self): + return self.env.ref('sale_timesheet.time_product', False) + billable_type = fields.Selection([ ('task_rate', 'At Task Rate'), ('employee_rate', 'At Employee Rate'), @@ -40,7 +43,8 @@ class Project(models.Model): ('invoice_policy', '=', 'delivery'), ('service_type', '=', 'timesheet'), '|', ('company_id', '=', False), ('company_id', '=', company_id)]""", - help='Select a Service product with which you would like to bill your time spent on tasks.') + help='Select a Service product with which you would like to bill your time spent on tasks.', + 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.'),