[FIX] delivery: Invoice line for delivery method

Steps to reproduce:

1. Activate the following options
** Settings > Warehouse > Products > Manage different units of measure for products
** Settings > Accounting > Accounting & Finance > Analytic accouting
2. Desactivate the following option
** Settings > Accounting > Analytic accouting > Sale > Use multiple analytic accounts on sales
3. Create a Sale order
** Add 2 qty of the product iMac
** Add in quote the delivery method "Normal Delivery Charges" and set 2 qty
** Set an analytic account under Contract/Analytic
** Set the field Create Invoice to "On delivery Order"
4. Deliver only 1 quantity of the iMac and then create the invoice
5. Deliver the last quantity of the iMac and then create the invoice

Behavior before the fix:
The first invoice contains 2 qty of the Transport
The second invoice contains 1 qty of the Transport, has no analytic account set, has no UOM set

Behavior after the fix:
The first invoice contains 2 qty of the Transport
The second invoice contains 0 qty of the Transport because it has already been invoiced

Closed #12644

opw:682284
This commit is contained in:
Goffin Simon 2016-07-06 10:32:06 +02:00
parent ef83f798d5
commit 965024902d
1 changed files with 4 additions and 0 deletions

View File

@ -79,6 +79,10 @@ class stock_picking(osv.osv):
:return: dict containing the values to create the invoice line,
or None to create nothing
"""
if picking.sale_id:
delivery_line = picking.sale_id.order_line.filtered(lambda l: l.is_delivery and l.invoiced)
if delivery_line:
return None
carrier_obj = self.pool.get('delivery.carrier')
grid_obj = self.pool.get('delivery.grid')
currency_obj = self.pool.get('res.currency')