Skip to content

Conversation

@fw-bot
Copy link
Contributor

@fw-bot fw-bot commented May 14, 2025

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.

def _create_invoices(self, sale_orders):
""" Override method from sale/wizard/sale_make_invoice_advance.py
When the user want to invoice the timesheets to the SO
up to a specific period then we need to recompute the
qty_to_invoice for each product_id in sale.order.line,
before creating the invoice.
"""
if self.advance_payment_method == 'delivered' and self.invoicing_timesheet_enabled:
if self.date_start_invoice_timesheet or self.date_end_invoice_timesheet:
sale_orders.order_line._recompute_qty_to_invoice(
self.date_start_invoice_timesheet, self.date_end_invoice_timesheet)
return sale_orders.with_context(
timesheet_start_date=self.date_start_invoice_timesheet,
timesheet_end_date=self.date_end_invoice_timesheet
)._create_invoices(final=self.deduct_down_payments, grouped=not self.consolidated_billing)
return super()._create_invoices(sale_orders)
moves._link_timesheets_to_invoice(self.env.context.get("timesheet_start_date"), self.env.context.get("timesheet_end_date"))

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: #205782
Forward-Port-Of: #205029

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

X-original-commit: f67a3be
@robodoo
Copy link
Contributor

robodoo commented May 14, 2025

Pull request status dashboard

@fw-bot
Copy link
Contributor Author

fw-bot commented May 14, 2025

This PR targets saas-18.2 and is part of the forward-port chain. Further PRs will be created up to master.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@robodoo robodoo added the forwardport This PR was created by @fw-bot label May 14, 2025
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label May 14, 2025
robodoo pushed a commit that referenced this pull request May 15, 2025
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

closes #209915

X-original-commit: f67a3be
Related: odoo/enterprise#85496
Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: Youssef Bashandy (yoba) <yoba@odoo.com>
@robodoo robodoo closed this May 15, 2025
@fw-bot fw-bot deleted the saas-18.2-18.0-opw-4523727-prevent_linking_all_timesheets-yoba-429146-fw branch May 22, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants