~serpent-consulting-services/openerp-usa/shipping_api_6-1

« back to all changes in this revision

Viewing changes to assembly_bom/report/delivery_report.py

  • Committer: npgllc
  • Date: 2012-08-02 17:13:27 UTC
  • Revision ID: npgllc-20120802171327-2xgyyjjb5d1kx26y
Removed all the 6.0 compatible modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    OpenERP, Open Source Management Solution
5
 
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6
 
#
7
 
#    This program is free software: you can redistribute it and/or modify
8
 
#    it under the terms of the GNU Affero General Public License as
9
 
#    published by the Free Software Foundation, either version 3 of the
10
 
#    License, or (at your option) any later version.
11
 
#
12
 
#    This program is distributed in the hope that it will be useful,
13
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
#    GNU Affero General Public License for more details.
16
 
#
17
 
#    You should have received a copy of the GNU Affero General Public License
18
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
#
20
 
##############################################################################
21
 
 
22
 
import time
23
 
 
24
 
from report import report_sxw
25
 
 
26
 
class delivery_report(report_sxw.rml_parse):
27
 
    def __init__(self, cr, uid, name, context=None):
28
 
        super(delivery_report, self).__init__(cr, uid, name, context=context)
29
 
        self.localcontext.update({
30
 
            'time': time,
31
 
#            'detail_list':context.get('detail_list', [])
32
 
            '_get_parent':self._get_parent,
33
 
            '_get_childs':self._get_childs
34
 
        })
35
 
 
36
 
    def _get_parent(self,pick_id):
37
 
        cr=self.cr
38
 
        uid=self.uid
39
 
        context=self.localcontext
40
 
        move_obj=self.pool.get('stock.move')
41
 
        move_ids=move_obj.search(cr,uid,[('picking_id','=',pick_id),("parent_bom_id","!=",False)])
42
 
        moves=move_obj.browse(cr,uid,move_ids,context=context)
43
 
        for move in moves:
44
 
            production=move.kit_id
45
 
            if production:
46
 
                product_qty=production.product_qty
47
 
                sale_id=move.sale_id.id
48
 
 
49
 
                parent_move_ids=move_obj.search(cr,uid,[("sale_id","=",sale_id),
50
 
                                                       ("product_qty","=",product_qty),
51
 
                                                       ("product_id","=",production.product_id.id)])
52
 
                parent_moves=move_obj.browse(cr,uid,parent_move_ids)
53
 
                print "parent_move_ids",parent_move_ids
54
 
#                return {'child_moves':moves,"parent_moves":parent_moves}
55
 
                return parent_moves
56
 
                break
57
 
 
58
 
    def _get_childs(self,pick_id):
59
 
        cr=self.cr
60
 
        uid=self.uid
61
 
        context=self.localcontext
62
 
        move_obj=self.pool.get('stock.move')
63
 
        move_ids=move_obj.search(cr,uid,[('picking_id','=',pick_id),("parent_bom_id","!=",False)])
64
 
        print move_ids,'====================move_ids================================'
65
 
        return move_obj.browse(cr,uid,move_ids,context=context)
66
 
 
67
 
report_sxw.report_sxw('report.delivery.bom', 'stock.picking', 'addons/assembly_bom/report/delivery_report.rml', parser=delivery_report, header=False)
68
 
 
69
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
70