From ed77febae6cb71adf514c9eb8fec6dbbc86e7327 Mon Sep 17 00:00:00 2001 From: "Victor Piryns (pivi)" Date: Mon, 31 Jul 2023 14:14:09 +0000 Subject: [PATCH] [FIX] sale_timesheet: don't include expenses when printing Timesheets Issue: Follow up on #128432, but this time it's removing expense lines from the pdf report when we print the Sales Order that has both timesheets, and posted expenses. Steps to reproduce: - Install Sales, Timesheets, Expense - Create an SO and sell a service that creates a Task > Confirm - Log some timesheet on the task (3h for ex.) - Create an expense related to the SO, approve it and generate the journal entries. - Print > Timesheets on the SO - In the pdf, we have table row entries for the expense lines. Cause: The report is basing itself on `timesheet_ids` to print the report, those might include expense lines. Fix: Add a domain on `timesheet_ids` to exclude lines that don't have a `project_id` set, those are not timesheet, so can be expenses. We want to exclude those. Affected versions: 16.0 up to master Reference: opw-3342274 closes odoo/odoo#130315 X-original-commit: c55f01cff7e415c48f823201ace63074bf9a9146 Signed-off-by: Xavier Bol (xbo) Signed-off-by: Piryns Victor (pivi) --- addons/sale_timesheet/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_timesheet/models/sale_order.py b/addons/sale_timesheet/models/sale_order.py index 8c033dbecbf..89da8d7a487 100644 --- a/addons/sale_timesheet/models/sale_order.py +++ b/addons/sale_timesheet/models/sale_order.py @@ -155,7 +155,7 @@ class SaleOrderLine(models.Model): remaining_hours_available = fields.Boolean(compute='_compute_remaining_hours_available', compute_sudo=True) remaining_hours = fields.Float('Remaining Hours on SO', compute='_compute_remaining_hours', compute_sudo=True, store=True) has_displayed_warning_upsell = fields.Boolean('Has Displayed Warning Upsell') - timesheet_ids = fields.One2many('account.analytic.line', 'so_line', 'Timesheets') + timesheet_ids = fields.One2many('account.analytic.line', 'so_line', domain=[('project_id', '!=', False)], string='Timesheets') @api.depends('remaining_hours_available', 'remaining_hours') @api.depends_context('with_remaining_hours', 'company')