[IMP] stock_account : If the invoice is coming from another source

than the sale order (ex: delivery order), the source is the
      concatenation of the picking reference + the sales order reference
This commit is contained in:
Yannick Tivisse
2015-06-23 16:16:40 +02:00
parent f2811a456a
commit 98e5151ad8
+8 -4
View File
@@ -273,8 +273,12 @@ class stock_picking(osv.osv):
else:
account_id = partner.property_account_payable_id.id
payment_term = partner.property_supplier_payment_term_id.id or False
if not move.origin:
origin = move.picking_id.name
else:
origin = move.picking_id.name + ', ' + move.origin
return {
'origin': move.picking_id.name,
'origin': origin,
'date_invoice': context.get('date_inv', False),
'user_id': user_id,
'partner_id': partner.id,
@@ -304,7 +308,6 @@ class stock_picking(osv.osv):
key = (partner, currency_id, company.id, _user_id)
invoice_vals = self._get_invoice_vals(cr, uid, key, inv_type, journal_id, move, context=context)
if key not in invoices:
# Get account and payment terms
invoice_id = self._create_invoice_from_picking(cr, uid, move.picking_id, invoice_vals, context=context)
@@ -312,8 +315,9 @@ class stock_picking(osv.osv):
else:
invoice = invoice_obj.browse(cr, uid, invoices[key], context=context)
if not invoice.origin or invoice_vals['origin'] not in invoice.origin.split(', '):
invoice_origin = filter(None, [invoice.origin, invoice_vals['origin']])
invoice.write({'origin': ', '.join(invoice_origin)})
elements = (invoice.origin or '').split(',') + (invoice_vals['origin'] or '').split(',')
invoice_origin = ', '.join(set(e.strip() for e in elements))
invoice.write({'origin': invoice_origin})
invoice_line_vals = move_obj._get_invoice_line_vals(cr, uid, move, partner, inv_type, context=context)
invoice_line_vals['invoice_id'] = invoices[key]