1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
"""stock_move inherit, manage stock moves for check traceability and mixes"""
from osv import osv, fields
from tools import config
class stock_move(osv.osv):
"""stock_move inherit for manage total prices"""
_inherit = 'stock.move'
def _get_total_price(self, cr, uid, ids, field_name, arg, context = {}):
"""obtains price of prodlots unit price with quantity"""
res = {}
for move in self.browse(cr, uid, ids):
res[move.id] = None
if move.prodlot_id and move.prodlot_id.unit_price:
if move.prodlot_id.product_uom.id != move.product_uom.id:
# pylint: disable-msg=W0212
res[move.id] = move.prodlot_id.unit_price * self.pool.get('product.uom')._compute_qty(cr, uid, move.product_uom.id, move.product_qty, move.prodlot_id.product_uom.id)
else:
res[move.id] = move.prodlot_id.unit_price * move.product_qty
return res
_columns = {
'price': fields.function(_get_total_price, method=True, string="Cost Price", type='float', readonly=True, digits=(16, int(config['price_accuracy']))),
}
stock_move()
|