← Back to team overview

openerp-india team mailing list archive

[Bug 973157] Re: Flag "Invoiced" on sales order line not set after creating invoice

 

Dear Ravish,

I have reproduced the problem in a blank database (find attached) where I install Sales and Invocing. Please access with user = "admin" and password = "admin".
I have created a number of duplicated sales orders. From SO006 to SO024. All the orders include a single product, which is a service purchased externally, and indicate Picking policy=Partial delivery, Shipping policy=Invoice On Order After Delivery, Invoice on = Ordered quantities.

After sales orders were created and confirmed, I executed the "Create invoice" wizard from the menu "Lines to Invoice".
All order lines were flagged as invoiced except for the order line related to order SO013. This order line converted into an invoice, but the line was not flagged as "Invoiced".

The root cause of the problem is, as far as I understand, the following:

1. The wizard "Make invoice" from the menu "Lines to Invoice" calls class sale_order_line_make_invoice, method "make_invoices".
2. Method "make_invoices" creates the invoice line in c8ode line 87:
(line_id = sales_order_line_obj.invoice_line_create(cr, uid,
                        [line.id])
Method "invoice_line_create" will relate the sales order lines with the invoice lines 
sale/sale.py Line 955: cr.execute('insert into sale_order_line_invoice_rel (order_line_id,invoice_id) values (%s,%s)', (line.id, inv_id))
, and flag the order line as "invoiced"

3. In sale/wizard/sale_invoice_line.py, line 108 the sales order
worklfow is then triggered with trigger "all_lines". This workflow in
turn triggers the sales.order method action_invoice_end, that checks for
each order line whether any related invoice line exists. If no invoice
line exists, it resets the flag "Invoiced" on the order line.

The problem is that when point 3 is executed, the insert instruction
indicated in point 2 may or may not have been commited. I assume that
the sale order workflow is executed in a separate thread to the class
sale_order_line_make_invoice, method "make_invoices".  As two threads
run in parallel, you cannot guarantee, that the commit for the insert
has been finished by the time you check the contents in point 3.

What I did is, I remove logic in "action_invoice_end" related to reset
invoice flag, and it then works fine!



** Attachment added: "Example database"
   https://bugs.launchpad.net/openobject-addons/+bug/973157/+attachment/3026377/+files/test2-08.sql.gz

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/973157

Title:
  Flag "Invoiced" on sales order line not set after creating invoice

Status in OpenERP Addons (modules):
  Opinion

Bug description:
  We have detected cases where the "invoiced" flag associated to the
  sales order line is not set once the invoice is created from sales
  order line. We cannot identify why in some cases the flag is set, and
  in other cases it is not.

  This problem causes inconsistencies in information, and the
  uncertainty of the user, that cannot keep good control of which order
  lines have already been invoices, and which have not.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/973157/+subscriptions


References