Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project_timesheet_hours_only/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Project Timesheet Hours Only",
"summary": "Filter project timesheet smart button to "
"exclude material consumption and show hours only",
"version": "14.0.1.1.0",
"version": "14.0.1.2.0",
"category": "Project",
"author": "Numigi",
"website": "https://www.numigi.com",
Expand Down
16 changes: 4 additions & 12 deletions project_timesheet_hours_only/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,19 @@ class SaleOrder(models.Model):

@api.depends('analytic_account_id.line_ids')
def _compute_timesheet_ids(self):
# Call the original method to retrieve the standard timesheets.
super(SaleOrder, self)._compute_timesheet_ids()

for order in self:
# Filter the results using the same logic (t.task_id) to keep
# actual labor hours only and exclude material consumption.
order.timesheet_ids = order.timesheet_ids.filtered(lambda t: t.task_id)

# Update the counter displayed on the smart button.
order.timesheet_ids = order.timesheet_ids.filtered(
lambda t: t.task_id and t.project_id in order.project_ids
)
order.timesheet_count = len(order.timesheet_ids)

# Note: the 'timesheet_total_duration' field updates by itself
# since it depends on the 'timesheet_ids' we just filtered.

def action_view_timesheet(self):
# Get the action from the original smart button.
action = super(SaleOrder, self).action_view_timesheet()

# Restrict the displayed lines to those linked to a task.
if isinstance(action, dict) and action.get('domain'):
action['domain'].append(('task_id', '!=', False))
action['domain'].append(('project_id', 'in', self.project_ids.ids))

return action

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,22 @@ def setUpClass(cls):

cls.order = cls.env["sale.order"].create({
"partner_id": cls.partner.id,
"analytic_account_id": cls.analytic_account.id,
"order_line": [(0, 0, {
"product_id": cls.service_product.id,
"product_uom_qty": 20.0,
"product_uom": cls.uom_hour.id,
})],
})
cls.order_line = cls.order.order_line
cls.project.write({
"sale_line_id": cls.order_line.id,
"sale_order_id": cls.order.id,
})
cls.task.write({
"sale_line_id": cls.order_line.id,
"sale_order_id": cls.order.id,
})

def _create_analytic_line(self, unit_amount, task=None):
return self.env["account.analytic.line"].create({
Expand Down
Loading