2
# -*- encoding: utf-8 -*-
3
###########################################################################
4
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (C) Vauxoo (<http://vauxoo.com>).
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.
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.
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
################################################################################
24
from osv import osv, fields, orm
25
import decimal_precision as dp
26
from tools.translate import _
28
class product_product(osv.osv):
29
_inherit = "product.product"
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 )
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)
41
res[id][f] = stock.get(id, 0.0)
44
def _stock_start(self, cr, uid, ids, field_names=None, arg=False, context=None):
45
from_date = context.get('from_date',False)
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)
52
'incoming_done_qty': fields.function(_product_available_done, multi='incoming_done_qty',
53
type='float', digits_compute=dp.get_precision('Product UoM'),
55
'outgoing_done_qty': fields.function(_product_available_done, multi='incoming_done_qty',
56
type='float', digits_compute=dp.get_precision('Product UoM'),
58
'stock_done_start': fields.function(_stock_start,
59
type='float', digits_compute=dp.get_precision('Product UoM'),
60
string='Stock_Start'),