[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) <yti@odoo.com>
This commit is contained in:
jdoutreloux
2020-03-11 15:22:21 +00:00
parent 6ab6750041
commit 1d0b5072f8
+5 -1
View File
@@ -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.'),