summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorjdoutreloux <jud@odoo.com>2020-03-11 15:06:46 +0000
committerjdoutreloux <jud@odoo.com>2020-03-11 15:22:21 +0000
commit1d0b5072f83f765ff2443d752b98dacb7e8be2bb (patch)
treeb2ee5900deaf4a182dba5c036fd20940e10f47ac /addons
parent6ab6750041720b2246b287072954daaf93ad90d1 (diff)
[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>
Diffstat (limited to 'addons')
-rw-r--r--addons/sale_timesheet/models/project.py6
1 files changed, 5 insertions, 1 deletions
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.'),