From fda8d77c69846badc6ea9ec523c28282068be2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Wed, 2 Aug 2017 15:32:54 +0200 Subject: [PATCH] [IMP] sale_timesheet: split non billable type for timesheet Timesheet logged on project created from a SO line are not exactly the same as the non billable ones. To ease the reporting, we split the non billable type of timesheet: when timesheeting directly on a project (whatever the product config), the billable type will be 'no task found'. The Overview is adapt to display the 2 'non billable' categories. --- addons/sale_timesheet/controllers/main.py | 3 +- addons/sale_timesheet/models/account.py | 7 +++-- .../static/src/less/sale_timesheet.less | 4 +++ .../views/hr_timesheet_templates.xml | 30 ++++++++++++++----- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/addons/sale_timesheet/controllers/main.py b/addons/sale_timesheet/controllers/main.py index 975b79523a9..4435f1e8a60 100644 --- a/addons/sale_timesheet/controllers/main.py +++ b/addons/sale_timesheet/controllers/main.py @@ -24,7 +24,7 @@ class SaleTimesheetController(http.Controller): 'domain': domain, } hour_rounding = request.env.ref('product.product_uom_hour').rounding - billable_types = ['non_billable', 'billable_time', 'billable_fixed'] + billable_types = ['non_billable', 'non_billable_project', 'billable_time', 'billable_fixed'] # -- Dashboard (per billable type) dashboard_values = { @@ -69,6 +69,7 @@ class SaleTimesheetController(http.Controller): repartition_employee.setdefault(employee_id, dict( employee_id=data['employee_id'][0], employee_name=data['employee_id'][1], + non_billable_project=0.0, non_billable=0.0, billable_time=0.0, billable_fixed=0.0, diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py index 96f4aa23bd9..9d9c9ace01a 100644 --- a/addons/sale_timesheet/models/account.py +++ b/addons/sale_timesheet/models/account.py @@ -11,7 +11,8 @@ class AccountAnalyticLine(models.Model): timesheet_invoice_type = fields.Selection([ ('billable_time', 'Billable Time'), ('billable_fixed', 'Billable Fixed'), - ('non_billable', 'Non Billable')], string="Billable Type", readonly=True, copy=False) + ('non_billable', 'Non Billable'), + ('non_billable_project', 'No task found')], string="Billable Type", readonly=True, copy=False) timesheet_invoice_id = fields.Many2one('account.invoice', string="Invoice", readonly=True, copy=False, help="Invoice created from the timesheet") timesheet_revenue = fields.Monetary("Revenue", default=0.0, readonly=True, currency_field='company_currency_id', copy=False) @@ -83,14 +84,14 @@ class AccountAnalyticLine(models.Model): timesheet_uom = self.env.user.company_id.project_time_mode_id # default values - billable_type = 'non_billable' + billable_type = 'non_billable_project' if not timesheet.task_id else 'non_billable' unit_amount = timesheet.unit_amount so_line = timesheet.so_line revenue = 0.0 billable_type = 'non_billable' # set the revenue and billable type according to the product and the SO line - if so_line.product_id.type == 'service' and so_line.product_id.service_type == 'timesheet': + if timesheet.task_id and so_line.product_id.type == 'service' and so_line.product_id.service_type == 'timesheet': # find the analytic account to convert revenue into its currency analytic_account = timesheet.account_id # convert the unit of mesure into hours diff --git a/addons/sale_timesheet/static/src/less/sale_timesheet.less b/addons/sale_timesheet/static/src/less/sale_timesheet.less index b420a53a2a2..8eba97fb085 100644 --- a/addons/sale_timesheet/static/src/less/sale_timesheet.less +++ b/addons/sale_timesheet/static/src/less/sale_timesheet.less @@ -35,6 +35,10 @@ background-color: #5bc0de; color: white; } + .o_progress_non_billable_project { + background-color: @brand-primary; + color: white; + } .o_progress_non_billable { background-color: gray; color: white; diff --git a/addons/sale_timesheet/views/hr_timesheet_templates.xml b/addons/sale_timesheet/views/hr_timesheet_templates.xml index 14fc5fd6195..01c8523ce75 100644 --- a/addons/sale_timesheet/views/hr_timesheet_templates.xml +++ b/addons/sale_timesheet/views/hr_timesheet_templates.xml @@ -19,21 +19,21 @@ - - - - + - + + + + + + + + +
+ Hours h Time and material + Rates % Time and material + Profitability @@ -61,13 +61,13 @@
- h + Non BillableNo task found - % + % Non BillableNo task found @@ -75,6 +75,18 @@ Cost
+ + Non Billable + % + Non Billable
h @@ -104,6 +116,7 @@
Billable fixed Billable time + No task found Non billable
@@ -123,8 +136,9 @@
+
-
+