diff --git a/addons/sale_stock/stock.py b/addons/sale_stock/stock.py index b69a8a27ef6..54bafa55063 100644 --- a/addons/sale_stock/stock.py +++ b/addons/sale_stock/stock.py @@ -61,6 +61,15 @@ class stock_picking(osv.osv): return picking.note or picking.sale_id.note return super(stock_picking, self)._get_comment_invoice(cursor, user, picking) + def _prepare_invoice_group(self, cr, uid, picking, partner, invoice, context=None): + """ Inherit the original function of the 'stock' module in order to override name field + to pass the customer reference form the sales order + """ + invoice_vals = super(stock_picking, self)._prepare_invoice_group(cr, uid, picking, partner, invoice, context) + if picking.sale_id: + invoice_vals['name'] = (invoice.name or '') + ', ' + (picking.sale_id.client_order_ref or '') + return invoice_vals + def _prepare_invoice(self, cr, uid, picking, partner, inv_type, journal_id, context=None): """ Inherit the original function of the 'stock' module in order to override some values if the picking has been generated by a sales order