1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
7
# info Vauxoo (info@vauxoo.com)
8
############################################################################
9
# Coded by: Luis Torres (luis_t@vauxoo.com)
10
############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as
14
# published by the Free Software Foundation, either version 3 of the
15
# License, or (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
##############################################################################
28
class stock_picking(osv.osv):
29
_inherit = 'stock.picking'
31
def action_invoice_create(self, cursor, user, ids, journal_id=False,
32
group=False, type='out_invoice', context=None):
35
picking_obj = self.pool.get('stock.picking')
36
invoice_obj = self.pool.get('account.invoice')
37
picking_id__invoice_id_dict = super(stock_picking, self).action_invoice_create(cursor, user,
38
ids, journal_id=journal_id, group=group, type=type,
40
invoice_id__client_order_ref_dict = {}
41
for picking_id in picking_id__invoice_id_dict.keys():
42
invoice_id = picking_id__invoice_id_dict[ picking_id ]
43
picking = picking_obj.browse(cursor, user, picking_id, context=context)
44
invoice_id__client_order_ref_dict.setdefault(invoice_id, []).append( picking.sale_id and picking.sale_id.client_order_ref or '' )
45
for invoice_id in invoice_id__client_order_ref_dict:
46
client_order_ref_list = invoice_id__client_order_ref_dict[invoice_id]
47
client_order_ref_str = ','.join( map( lambda x: str(x), client_order_ref_list))
48
invoice_obj.write(cursor, user, [invoice_id], {'name': client_order_ref_str}, context=context)
49
return picking_id__invoice_id_dict