odoo icon indicating copy to clipboard operation
odoo copied to clipboard

[FIX] sale_timesheet: take credit notes into account when invoicing

Open pivi-odoo opened this issue 2 years ago • 5 comments

When invoicing a timesheet service (with selected dates that include the service's logged time), that was partially refunded/credited, more hours are invoiced than delivered.

Steps to reproduce:

  • create a service that is invoiced based on delivered timesheet, based on task or project, unit hours
  • create a sale order with a line of that service with a certain quantity, validate the order and generate the invoice
  • create a credit note that refunds part of that invoiced quantity
  • log more time in the timesheet
  • create a new invoice (select dates that include the newly logged work)

Current result: more hours were invoiced than delivered Expected result: invoiced quantity should be equal to the delivered quantity

Fix: When we are calculating how much to invoice for each line, if it is a timesheeted one, and it was previously refunded, substract the currently invoiced quantity from the line.

Affected versions:

  • 15.0
  • saas-15.2
  • saas-15.3

⚠️ ~~as of writing this PR, the bug couldn't be reproduced on master (now version 16.0) due to another issue (the wizard doesn't show date fields when having sale order lines based on timesheeted tasks). When that issue gets resolved, forward port this PR to version 16.0 and master.~~ I've written a fix https://github.com/odoo/odoo/pull/101020, the issue has been confirmed present on 16.0 and master.

opw-2974259

-- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

pivi-odoo avatar Sep 13 '22 11:09 pivi-odoo

Pull request status dashboard

robodoo avatar Sep 13 '22 11:09 robodoo

@fw-bot up to saas-15.3

pivi-odoo avatar Sep 13 '22 11:09 pivi-odoo

Forward-porting to 'saas-15.3'.

fw-bot avatar Sep 13 '22 11:09 fw-bot

The issue has been reproduced on 16.0 and master (check PR message), forward porting this fix to master included

@fw-bot up to master

pivi-odoo avatar Sep 23 '22 14:09 pivi-odoo

Forward-porting to 'master'.

fw-bot avatar Sep 23 '22 14:09 fw-bot

I've added a lower bound of 0 for the substraction, because I just stumbled on another issue. Let say I sell 20 hours of service, clock in 5 hours in August, clock in 5 hours in September (10 hours delivered). Invoice them both, create the credit note and reimburse 3 hours (7 hours invoiced). Now on the SO, create a new invoice and chose to invoice for September, the generated invoice will have a negative entry (5 hours delivered in September, 7 already invoiced, -2 to invoice...). So I've added a lower bound of 0, to avoid creating negative invoices. Currently there is no way to specify when creating the credit note on a SOL that has a timesheet service which entry in the timesheet we are reimbursing.

Would love to get the PO's input on this.

pivi-odoo avatar Sep 29 '22 13:09 pivi-odoo

This issue was classified as a "technical limitation". We currently don't support partial refund for lines that are a timesheet service, only full refund. An alternative flow is to do a full refund and then change the quantity on the SOL. Closing this PR.

pivi-odoo avatar Oct 03 '22 11:10 pivi-odoo