odoo/enterprise#85533

Created by fw-bot
Merged at c58bc05a3d70cf30909af2178e5d27aaff022098

Statuses:

Linked pull requests
label
odoo-dev:master-18.0-opw-4523727-prevent_linking_all_timesheets-yoba-436088-fw
head
469f4575fc0722a1c8ed7db0f8c36ccd3bfdd0aa
merged
6 months ago by Bugfix, Youssef Bashandy (yoba)
odoo/odoo odoo/enterprise
18.0 #205029 #80582
saas-18.1 #205782 #83333
saas-18.2 #209915 #85496
saas-18.3 #209950 #85515
saas-18.4
19.0
master #209975 #85533

[FW][FIX] sale_subscription_timesheet : Prevent linking not-invoiced timesheet to invoice

Steps to reproduce:

- Create a recurring service (product) with invoicing policy
set as 'Based on Timesheets'
- Create a subscription using the created product
- Create a task and link it to this subscription order
- Timesheet 3 line in the task one in the past one on the same
date of creation and one in the future.
- Create an invoice for this order
- Notice the quantity has been invoiced is the present timesheet line only
- Notice that the 3 timesheet lines have all been validated

Cause:

This is happening because when trying to link the lines to
the invoice we consider the timesheets within the date range that the user
might have set in the create invoice wizard.
https://github.com/odoo/odoo/blob/9a4ec08b9a6b07470747923d09adcf51f7e4cd6a/addons/sale_timesheet/wizard/sale_make_invoice_advance.py#L33-L51
https://github.com/odoo/odoo/blob/9a4ec08b9a6b07470747923d09adcf51f7e4cd6a/addons/sale_timesheet/models/sale_order.py#L153

Fix:

In subscription we can use the last and next invoice dates
if the user hasn't set a period for the invoice.

opw-4523727

Forward-Port-Of: #83333
Forward-Port-Of: #80582