Sales button "Invoice Corrected" does not set the order lines as invoiced
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) | Status tracked in Trunk | |||||
5.0 |
Fix Released
|
Undecided
|
Unassigned | |||
Trunk |
Fix Released
|
Undecided
|
JMA(Open ERP) |
Bug Description
The "Invoice Corrected" button of the sale orders in "invoice_except" state, does not set the invoice lines as invoiced.
This means that wizards like the "make_invoice" one, will re-invoice those lines!
How to reproduce:
- The user creates a new sale order (with manual invoice method: "Shipping & Manual Invoice", "Ordered Quantities").
- The user confirms the sale order ("Confirm Order" button).
=> Order state is set to "Manual in Progress".
- The user creates an invoice from the sale order (either using the "Create Invoice" button or "Make invoices" wizard).
=> The sale order is set to "In Progress".
=> The sale order lines state is set as "Done" and they are flagged as "Invoiced".
- The user cancels the invoice ("Cancel" button)
=> The sale order state is automatically set to "Invoice Exception".
=> The sale order lines state is still "Done" but the "Invoiced" flag has been removed.
- The user corrects the invoice ("Set to Draft" button), then confirms it ("Validate" button)
=> The sale order & lines remain in "invoice_except" state, waiting for human intervention.
- The user edits the sale order, and confirms that the invoice has been corrected ("Invoice Corrected" button).
=> The sale order state is set to "Done".
=> PROBLEM: THE SALE ORDER LINES ARE NOT FLAGGED AS "Invoiced".
- The user runs the "Make invoices" wizard for several orders including the 'invoice corrected' order.
=> PROBLEM: A new invoice was created for the sale order!!! with 0.00 total (lines are duplicated with negative and positive sign).
=> The sale order lines are now marked as "Invoiced"
Related branches
- Jay Vora (Serpent Consulting Services) (community): Approve
- JMA(Open ERP) (community): Approve
-
Diff: 62 lines (+34/-9)1 file modifiedsale/sale.py (+34/-9)
Changed in openobject-addons: | |
status: | New → Confirmed |
Changed in openobject-addons: | |
assignee: | nobody → JMA(Open ERP) (jma-openerp) |
Changed in openobject-addons: | |
milestone: | none → 5.0.15 |
Additional notes:
Using the "Invoice Corrected" button of the sale order form, will signal the "invoice_corrected" signal, causing a transaction between the act_invoice_except and invoice_end workflow activities (trans_ invoice_ except_ invoice_ end).
The invoice_end activity (with id act_invoice_end), runs the action_ invoice_ end() action of the sale order object.
So, the problem is, that the action_invoice_end is not setting the lines as invoices.
Currently it does this:
for line in order.order_line:
self. pool.get( 'sale.order. line'). write(cr, uid, [line.id], {'state': 'confirmed'}, context=context)
if line.state == 'exception':
And should do this instead:
for line in order.order_line:
invoiced = False
if iline.invoice_id and iline.invoice_ id.state == 'cancel':
continue
else:
invoiced = True
state = (line.state == 'exception') and 'confirmed' or line.state
self. pool.get( 'sale.order. line'). write(cr, uid, [line.id], {'invoiced': invoiced, 'state': state})
for iline in line.invoice_lines:
-----
BTW: The problem is present in trunk too, though the trunk code is a bit different so the patch needs a small change.