[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) <xbo@odoo.com>
Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
This commit is contained in:
Victor Piryns (pivi)
2023-08-02 05:10:37 +02:00
parent 442a79eeb0
commit ed77febae6
+1 -1
View File
@@ -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')