~stock-logistic-core-editors/stock-logistic-warehouse/7.0

« back to all changes in this revision

Viewing changes to stock_move_on_hold/product.py

  • Committer: Joel Grand-Guillaume
  • Date: 2012-11-05 13:50:04 UTC
  • Revision ID: joel.grandguillaume@camptocamp.com-20121105135004-4arbgyaog3rshjnc
[DEL] Remove the following module and move them to this project : https://launchpad.net/stock-logistic-flows : stock_move_on_hold

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) 2011 Julius Network Solutions SARL <contact@julius.fr>
6
 
#
7
 
#    This program is free software: you can redistribute it and/or modify
8
 
#    it under the terms of the GNU General Public License as published by
9
 
#    the Free Software Foundation, either version 3 of the License, or
10
 
#    (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 General Public License for more details.
16
 
#
17
 
#    You should have received a copy of the GNU General Public License
18
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
#
20
 
#################################################################################
21
 
 
22
 
from osv import fields, osv
23
 
from tools.translate import _
24
 
import decimal_precision as dp
25
 
 
26
 
class product_product(osv.osv):
27
 
    
28
 
    _inherit = "product.product"
29
 
 
30
 
    def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}):
31
 
        if not field_names:
32
 
            field_names = []
33
 
        res = {}
34
 
        for id in ids:
35
 
            res[id] = {}.fromkeys(field_names, 0.0)
36
 
        for f in field_names:
37
 
            c = context.copy()
38
 
            if f == 'qty_available':
39
 
                c.update({ 'states':('done',), 'what':('in', 'out') })
40
 
            if f == 'virtual_available':
41
 
                c.update({ 'states':('confirmed','waiting','assigned','on_hold','on_hold_billing','on_hold_paym','done'), 'what':('in', 'out') })
42
 
            if f == 'incoming_qty':
43
 
                c.update({ 'states':('confirmed','waiting','assigned','on_hold','on_hold_billing','on_hold_paym'), 'what':('in',) })
44
 
            if f == 'outgoing_qty':
45
 
                c.update({ 'states':('confirmed','waiting','assigned','on_hold','on_hold_billing','on_hold_paym'), 'what':('out',) })
46
 
            stock = self.get_product_available(cr,uid,ids,context=c)
47
 
            for id in ids:
48
 
                res[id][f] = stock.get(id, 0.0)
49
 
        return res
50
 
 
51
 
    _columns = {
52
 
        'qty_available': fields.function(_product_available, method=True, type='float', string='Real Stock', help="Current quantities of products in selected locations or all internal if none have been selected.", multi='qty_available', digits_compute=dp.get_precision('Product UoM')),
53
 
        'virtual_available': fields.function(_product_available, method=True, type='float', string='Virtual Stock', help="Future stock for this product according to the selected location or all internal if none have been selected. Computed as: Real Stock - Outgoing + Incoming.", multi='qty_available', digits_compute=dp.get_precision('Product UoM')),
54
 
        'incoming_qty': fields.function(_product_available, method=True, type='float', string='Incoming', help="Quantities of products that are planned to arrive in selected locations or all internal if none have been selected.", multi='qty_available', digits_compute=dp.get_precision('Product UoM')),
55
 
        'outgoing_qty': fields.function(_product_available, method=True, type='float', string='Outgoing', help="Quantities of products that are planned to leave in selected locations or all internal if none have been selected.", multi='qty_available', digits_compute=dp.get_precision('Product UoM')),
56
 
    }
57
 
    
58
 
product_product()
59
 
 
60
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: