odoo/enterprise#83333

Created by fw-bot
Merged at 883210e597fd061d3b7a392627f2ed7dabe97592

Statuses:

Linked pull requests
label
odoo-dev:saas-18.1-18.0-opw-4523727-prevent_linking_all_timesheets-yoba-419955-fw
head
a7710466b506909dd24f85c828e4f158fb2cd932
merged
6 months ago by Fun Services, Xavier Bol (xbo)
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: #80582