diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py
index 5fa42965e8f..1975b6882a5 100644
--- a/addons/hr_timesheet/models/project.py
+++ b/addons/hr_timesheet/models/project.py
@@ -242,7 +242,7 @@ class Task(models.Model):
remaining_hours = fields.Float("Remaining Hours", compute='_compute_remaining_hours', store=True, readonly=True, help="Number of allocated hours minus the number of hours spent.")
remaining_hours_percentage = fields.Float(compute='_compute_remaining_hours_percentage', search='_search_remaining_hours_percentage')
effective_hours = fields.Float("Hours Spent", compute='_compute_effective_hours', compute_sudo=True, store=True)
- total_hours_spent = fields.Float("Total Hours", compute='_compute_total_hours_spent', store=True, help="Time spent on this task and its sub-tasks (and their own sub-tasks).")
+ total_hours_spent = fields.Float("Total Hours Spent", compute='_compute_total_hours_spent', store=True, help="Time spent on this task and its sub-tasks (and their own sub-tasks).")
progress = fields.Float("Progress", compute='_compute_progress_hours', store=True, group_operator="avg")
overtime = fields.Float(compute='_compute_progress_hours', store=True)
subtask_effective_hours = fields.Float("Sub-tasks Hours Spent", compute='_compute_subtask_effective_hours', recursive=True, store=True, help="Time spent on the sub-tasks (and their own sub-tasks) of this task.")
diff --git a/addons/hr_timesheet/views/project_views.xml b/addons/hr_timesheet/views/project_views.xml
index e195e915135..8d2d1a50e71 100644
--- a/addons/hr_timesheet/views/project_views.xml
+++ b/addons/hr_timesheet/views/project_views.xml
@@ -115,7 +115,7 @@
-
+
@@ -241,7 +241,7 @@
attrs="{'invisible': ['|', '|', ('planned_hours', '=', 0.0), ('encode_uom_in_days', '=', False), ('remaining_hours', '>=', 0)]}"/>
+ attrs="{'invisible' : [('planned_hours', '=', 0.0)]}" nolabel="1" decoration-danger="remaining_hours < 0"/>
diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml
index d7323e577a6..dadb5e9f098 100644
--- a/addons/project/views/project_views.xml
+++ b/addons/project/views/project_views.xml
@@ -533,7 +533,7 @@
-
+
@
@@ -1089,8 +1089,8 @@
diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py
index 0110f06f520..a8d3d14b3a9 100644
--- a/addons/sale_timesheet/models/project.py
+++ b/addons/sale_timesheet/models/project.py
@@ -276,7 +276,7 @@ class Project(models.Model):
action['context'].update(search_default_groupby_timesheet_invoice_type=False, **self.env.context)
graph_view = False
if section_name == 'billable_time':
- graph_view = self.env.ref('hr_timesheet.view_hr_timesheet_line_graph_all').id
+ graph_view = self.env.ref('sale_timesheet.view_hr_timesheet_line_graph_invoice_employee').id
action['views'] = [
(view_id, view_type) if view_type != 'graph' else (graph_view or view_id, view_type)
for view_id, view_type in action['views']
@@ -440,7 +440,6 @@ class Project(models.Model):
if record_ids:
if invoice_type not in ['other_costs', 'other_revenues'] and can_see_timesheets: # action to see the timesheets
action = get_timesheets_action(invoice_type, record_ids)
- action['context'] = json.dumps({'search_default_groupby_invoice': 1 if not cost and invoice_type == 'billable_time' else 0})
data['action'] = action
profitability_data.append(data)
return profitability_data
@@ -459,7 +458,6 @@ class Project(models.Model):
record_ids = aal_revenue.get('record_ids', [])
if can_see_timesheets and record_ids:
action = get_timesheets_action(revenue_id, record_ids)
- action['context'] = json.dumps({'search_default_groupby_invoice': 1 if revenue_id == 'billable_time' else 0})
revenue['action'] = action
for cost in profitability_items['costs']['data']:
diff --git a/addons/sale_timesheet/models/sale_order.py b/addons/sale_timesheet/models/sale_order.py
index d8fddf60d95..6537a7ebef7 100644
--- a/addons/sale_timesheet/models/sale_order.py
+++ b/addons/sale_timesheet/models/sale_order.py
@@ -134,18 +134,24 @@ class SaleOrderLine(models.Model):
def name_get(self):
res = super(SaleOrderLine, self).name_get()
with_remaining_hours = self.env.context.get('with_remaining_hours')
- if with_remaining_hours:
+ if with_remaining_hours and any(line.remaining_hours_available for line in self):
names = dict(res)
result = []
- uom_hour = self.env.ref('uom.product_uom_hour')
- uom_day = self.env.ref('uom.product_uom_day')
+ company = self.env.company
+ encoding_uom = company.timesheet_encode_uom_id
+ is_hour = is_day = False
+ unit_label = ''
+ if encoding_uom == self.env.ref('uom.product_uom_hour'):
+ is_hour = True
+ unit_label = _('remaining')
+ elif encoding_uom == self.env.ref('uom.product_uom_day'):
+ is_day = True
+ unit_label = _('days remaining')
for line in self:
name = names.get(line.id)
if line.remaining_hours_available:
- company = self.env.company
- encoding_uom = company.timesheet_encode_uom_id
remaining_time = ''
- if encoding_uom == uom_hour:
+ if is_hour:
hours, minutes = divmod(abs(line.remaining_hours) * 60, 60)
round_minutes = minutes / 30
minutes = math.ceil(round_minutes) if line.remaining_hours >= 0 else math.floor(round_minutes)
@@ -154,15 +160,16 @@ class SaleOrderLine(models.Model):
hours += 1
else:
minutes = minutes * 30
- remaining_time = ' ({sign}{hours:02.0f}:{minutes:02.0f})'.format(
+ remaining_time = ' ({sign}{hours:02.0f}:{minutes:02.0f} {remaining})'.format(
sign='-' if line.remaining_hours < 0 else '',
hours=hours,
- minutes=minutes)
- elif encoding_uom == uom_day:
+ minutes=minutes,
+ remaining=unit_label)
+ elif is_day:
remaining_days = company.project_time_mode_id._compute_quantity(line.remaining_hours, encoding_uom, round=False)
remaining_time = ' ({qty:.02f} {unit})'.format(
qty=remaining_days,
- unit=_('days') if abs(remaining_days) > 1 else _('day')
+ unit=unit_label
)
name = '{name}{remaining_time}'.format(
name=name,
diff --git a/addons/sale_timesheet/views/hr_timesheet_views.xml b/addons/sale_timesheet/views/hr_timesheet_views.xml
index 0bd691cdf5e..5886b33ed30 100644
--- a/addons/sale_timesheet/views/hr_timesheet_views.xml
+++ b/addons/sale_timesheet/views/hr_timesheet_views.xml
@@ -88,6 +88,30 @@
+
+ account.analytic.line.graph.invoice.employee
+ account.analytic.line
+ primary
+
+
+
+
+
+
+
+
+
+ account.analytic.line.pivot
+ account.analytic.line
+ primary
+
+
+
+ measure
+
+
+
+
@@ -122,6 +146,7 @@
[('project_id', '!=', False), ('so_line', '=', active_id)]
{
+ 'grid_range': 'week',
'search_default_billable_timesheet': True,
'search_default_week': 1,
'default_so_line': active_id,
@@ -155,7 +180,7 @@
pivot
-
+