~vauxoo/addons-vauxoo/addons-vauxoo-mrp_consume_produce-dev-julio

« back to all changes in this revision

Viewing changes to inventory_stock_report/report/reporte_stock2.py

  • Committer: Gabriela (Vauxoo)
  • Date: 2012-01-02 21:20:56 UTC
  • Revision ID: gabrielaquilarque97@gmail.com-20120102212056-un9mxlsiuj7wg90d

[ADD] Added new module product_historical_price.
[ADD] Added new module inventory_stock_report.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- encoding: utf-8 -*-
 
3
###########################################################################
 
4
#    Module Writen to OpenERP, Open Source Management Solution
 
5
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
 
6
#    All Rights Reserved
 
7
###############Credits######################################################
 
8
#    Coded by: Vauxoo C.A.           
 
9
#    Planified by: Nhomar Hernandez
 
10
#    Audited by: Vauxoo C.A.
 
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 published by
 
14
#    the Free Software Foundation, either version 3 of the License, or
 
15
#    (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
import time
 
27
from report import report_sxw
 
28
from osv import osv
 
29
import pooler
 
30
 
 
31
class rep_conteo_stock2(report_sxw.rml_parse):
 
32
    
 
33
 
 
34
 
 
35
    def __init__(self, cr, uid, name, context):
 
36
        super(rep_conteo_stock2, self).__init__(cr, uid, name, context)    
 
37
        self.localcontext.update({
 
38
            'time': time                                ,
 
39
            'get_data':self.get_data                    ,
 
40
            'get_tipo':self.get_tipo                    ,
 
41
            'get_category':self.get_category            ,
 
42
            'get_state':self.get_state                  ,
 
43
            'get_destinado':self.get_destinado          ,
 
44
            'get_suministro':self.get_suministro        ,
 
45
            'get_qty_available':self.get_qty_available  ,
 
46
            'get_code':self.get_code                    ,
 
47
        })
 
48
 
 
49
    def get_tipo(self, stock=None):
 
50
        product= self.pool.get('product.template')
 
51
        cabeza=[]
 
52
        boole=False
 
53
        if stock.tipo=="almacenable" or stock.tipo=="consumible": 
 
54
            cabeza.append("Almacenable/Consumible")
 
55
            boole=True
 
56
        if stock.tipo=="servicio":
 
57
            cabeza.append("Servicio")
 
58
            boole=True
 
59
        if boole==False:
 
60
            cabeza.append("Almacenable - Consumible / Servicio")
 
61
        return cabeza    
 
62
            
 
63
    def get_category(self, stock=None):
 
64
        product= self.pool.get('product.template')
 
65
        cabeza=[]
 
66
        if stock.categoria:
 
67
            cabeza.append(" %s"%(stock.categoria.name))
 
68
        else:
 
69
            cabeza.append("Todas las Categorias") 
 
70
        return cabeza 
 
71
    
 
72
    def get_state(self, stock=None):
 
73
        product= self.pool.get('product.template')
 
74
        cabeza=[]       
 
75
        if stock.estado:
 
76
            cabeza.append(" %s"%(stock.estado))
 
77
        else:
 
78
            cabeza.append("Todas los Estados")
 
79
        return cabeza
 
80
    
 
81
    def get_destinado(self, stock=None):
 
82
        product= self.pool.get('product.template')
 
83
        cabeza=" "
 
84
        
 
85
        if stock.vendible:
 
86
            cabeza="Vendible " 
 
87
            
 
88
        if stock.comprable:
 
89
            cabeza =cabeza+" Comprable"
 
90
 
 
91
        if stock.alquilable:
 
92
            cabeza=cabeza + "Alquilable"
 
93
 
 
94
        if not stock.vendible and not stock.comprable and not stock.alquilable:
 
95
            cabeza="Vendible Comprable Alquilable"
 
96
        return cabeza
 
97
    
 
98
    def get_suministro(self, stock=None):
 
99
        product= self.pool.get('product.template')
 
100
        cabeza=[]
 
101
        if stock.suministro:
 
102
            cabeza.append(" %s"%(stock.suministro))
 
103
        else:
 
104
            cabeza.append("Todas los Tipos de Suministro")      
 
105
        return cabeza
 
106
     
 
107
    
 
108
    
 
109
    def get_data (self,stock=None ):
 
110
        product= self.pool.get('product.template')
 
111
        merge=[]
 
112
        ##################para el tipo del producto####################
 
113
        
 
114
        if stock.tipo=="almacenable": 
 
115
            merge.append( ('type', '=',"product"))  
 
116
        if stock.tipo=="consumible": 
 
117
            merge.append( ('type', '=',"consut"))
 
118
        if stock.tipo=="servicio":
 
119
             merge.append( ('type', '=',"service") ) 
 
120
        
 
121
        ##################para la categoria####################
 
122
 
 
123
        if stock.categoria:
 
124
            merge.append( ('categ_id', '=',stock.categoria.id) ) 
 
125
            
 
126
        ##################para el estado####################
 
127
        if stock.estado:
 
128
            if stock.estado=="desarrollo":
 
129
                merge.append( ('state', '=',"draft") ) 
 
130
                
 
131
            if stock.estado=="produccion":
 
132
                merge.append( ('state', '=',"sellable") ) 
 
133
 
 
134
            if stock.estado=="fin":
 
135
                merge.append( ('state', '=',"end") )
 
136
 
 
137
            if stock.estado=="obsoleto":
 
138
                merge.append( ('state', '=',"obsolete") )
 
139
  
 
140
            if stock.estado=="none":
 
141
                merge.append( ('state', '=',None) )
 
142
                
 
143
        ##################destinado a ser: vendible, conyable, alquilable####################
 
144
        if stock.vendible:
 
145
            merge.append( ('sale_ok', '=',True) )
 
146
 
 
147
        if stock.comprable:
 
148
            merge.append( ('purchase_ok', '=',True) )
 
149
 
 
150
        if stock.alquilable:
 
151
            merge.append( ('rental', '=',True) )
 
152
            
 
153
        ##################tipo de suministro####################
 
154
 
 
155
        if stock.suministro=="comprar":
 
156
            merge.append( ('supply_method', '=','produce') )
 
157
            
 
158
        if stock.suministro=="producir":
 
159
            merge.append( ('supply_method', '=','buy') )
 
160
 
 
161
        id_productos=product.search(self.cr, self.uid, merge, order="name" )
 
162
        data =product.browse(self.cr,self.uid, id_productos) #lista de product_template que cumplen la condicion
 
163
        return data
 
164
 
 
165
 
 
166
    def get_qty_available (self,id_template ):
 
167
        qty=0.0
 
168
        qty2=0.0
 
169
        product= self.pool.get('product.product')
 
170
        try:
 
171
            id_producto=product.search(self.cr, self.uid, [('product_tmpl_id', '=',id_template.id)])
 
172
            producto=product.browse(self.cr,self.uid, id_producto[0])
 
173
            qty=producto.qty_available
 
174
            qty2=producto.virtual_available
 
175
            res=[qty,qty2]
 
176
            return res
 
177
        except:
 
178
            res=[qty,qty2]
 
179
            return res
 
180
 
 
181
    def get_code(self,id_template):
 
182
        code="-"
 
183
        product= self.pool.get('product.product')
 
184
        try:
 
185
            id_producto=product.search(self.cr, self.uid, [('product_tmpl_id', '=',id_template.id)])
 
186
            producto=product.browse(self.cr,self.uid, id_producto[0])
 
187
            code=producto.code
 
188
            return code
 
189
        except:
 
190
            return code
 
191
 
 
192
      
 
193
report_sxw.report_sxw(
 
194
    'report.hoja222'                                             ,  
 
195
    'stock.total'                                                ,
 
196
    'addons/inventory_stock_report/report/hoja_conteo_qty2.rml'     ,  
 
197
    parser=rep_conteo_stock2                                     ,
 
198
)      
 
199
 
 
200
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: