~vauxoo/addons-vauxoo/trunk-upforward70-2-dev-moylop260

« back to all changes in this revision

Viewing changes to kardex/kardex.py

  • Committer: Juan Carlos Funes
  • Date: 2012-10-23 00:01:58 UTC
  • mto: (501.1.35 6.1)
  • mto: This revision was merged to the branch mainline in revision 502.
  • Revision ID: openerp1@hotmail.com-20121023000158-h8hvnf2jyxryeelf
[IMP][KARDEX]add inherit

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) Vauxoo (<http://vauxoo.com>).
 
6
#    All Rights Reserved
 
7
###############Credits######################################################
 
8
#    Coded by: Juan Carlos Funes(juan@vauxoo.com)
 
9
#############################################################################
 
10
#    This program is free software: you can redistribute it and/or modify
 
11
#    it under the terms of the GNU Affero General Public License as published by
 
12
#    the Free Software Foundation, either version 3 of the License, or
 
13
#    (at your option) any later version.
 
14
#
 
15
#    This program is distributed in the hope that it will be useful,
 
16
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
#    GNU Affero General Public License for more details.
 
19
#
 
20
#    You should have received a copy of the GNU Affero General Public License
 
21
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
22
################################################################################
 
23
 
 
24
from osv import osv, fields, orm
 
25
import decimal_precision as dp
 
26
from tools.translate import _
 
27
 
 
28
class product_product(osv.osv):
 
29
    _inherit = "product.product"
 
30
 
 
31
    def _product_available_done(self, cr, uid, ids, field_names=None, arg=False, context=None):
 
32
        res = super(product_product,self)._product_available(cr, uid, ids, field_names, arg, context=context )
 
33
        for f in field_names:
 
34
            c = context.copy()
 
35
            if f == 'incoming_done_qty':
 
36
                c.update({ 'states': ('done',), 'what': ('in',) })
 
37
            if f == 'outgoing_done_qty':
 
38
                c.update({ 'states': ('done',), 'what': ('out',) })
 
39
            stock = self.get_product_available(cr, uid, ids, context=c)
 
40
            for id in ids:
 
41
                res[id][f] = stock.get(id, 0.0)
 
42
        return res
 
43
 
 
44
    def _stock_start(self, cr, uid, ids, field_names=None, arg=False, context=None):
 
45
        from_date = context.get('from_date',False)
 
46
        c = context.copy()
 
47
        c.update({ 'states': ('done',), 'what': ('in','out',) ,'to_date': from_date,'from_date': False })
 
48
        res = self.get_product_available(cr, uid, ids, context=c)
 
49
        return res
 
50
 
 
51
    _columns = {
 
52
        'incoming_done_qty': fields.function(_product_available_done, multi='incoming_done_qty',
 
53
            type='float',  digits_compute=dp.get_precision('Product UoM'),
 
54
            string='Incoming'),
 
55
        'outgoing_done_qty': fields.function(_product_available_done, multi='incoming_done_qty',
 
56
            type='float',  digits_compute=dp.get_precision('Product UoM'),
 
57
            string='Outgoing'),
 
58
        'stock_done_start': fields.function(_stock_start,
 
59
            type='float',  digits_compute=dp.get_precision('Product UoM'),
 
60
            string='Stock_Start'),
 
61
}
 
62
 
 
63
product_product()