~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to invoice_sale_ref/stock_picking.py

  • Committer: moylop260
  • Date: 2012-09-08 02:03:25 UTC
  • Revision ID: moylop260@vauxoo.com-20120908020325-h5yurx5rqkc1ml6w
[ADD] [account_analytic_btree] Add module account_analytic_btree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
###########################################################################
 
3
#    Module Writen to OpenERP, Open Source Management Solution
 
4
#
 
5
#    Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
 
6
#    All Rights Reserved.
 
7
#    info Vauxoo (info@vauxoo.com)
 
8
############################################################################
 
9
#    Coded by: Luis Torres (luis_t@vauxoo.com)
 
10
############################################################################
 
11
#
 
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.
 
16
#
 
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.
 
21
#
 
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/>.
 
24
#
 
25
##############################################################################
 
26
from osv import osv
 
27
 
 
28
class stock_picking(osv.osv):
 
29
    _inherit = 'stock.picking'
 
30
    
 
31
    def action_invoice_create(self, cursor, user, ids, journal_id=False,
 
32
            group=False, type='out_invoice', context=None):
 
33
        if context is None:
 
34
            context = {}
 
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,
 
39
                context=context)
 
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
 
50
 
 
51
stock_picking()