1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2010 Netquatro C.A. (http://openerp.netquatro.com/) All Rights Reserved.
5
# Javier Duran <javier.duran@netquatro.com>
6
# Nhomar Hernandez <nhomar.hernandez@netquatro.com>
8
# WARNING: This program as such is intended to be used by professional
9
# programmers who take the whole responsability of assessing all potential
10
# consequences resulting from its eventual inadequacies and bugs
11
# End users who are looking for a ready-to-use solution with commercial
12
# garantees and support are strongly adviced to contract a Free Software
15
# This program is Free Software; you can redistribute it and/or
16
# modify it under the terms of the GNU General Public License
17
# as published by the Free Software Foundation; either version 2
18
# of the License, or (at your option) any later version.
20
# This program is distributed in the hope that it will be useful,
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
# GNU General Public License for more details.
25
# You should have received a copy of the GNU General Public License
26
# along with this program; if not, write to the Free Software
27
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
##############################################################################
32
from osv import fields
33
from tools.translate import _
35
class product_uom_consol(osv.osv):
36
_name = 'product.uom.consol'
37
_description = 'A third unit to consolidate the sales and purchase.'
39
'name': fields.char('Name', size=64, required=True, translate=True),
40
'uom_line_ids':fields.one2many('product.uom.consol.line', 'p_uom_c_id', 'Units', required=False),
45
class product_uom_consol_line(osv.osv):
47
Third Unit to consolidate sales and purchases!
49
_name = 'product.uom.consol.line'
50
_description = ''' Elements to control the seconds unit of measure. '''
52
def _factor(self, cursor, user, ids, name, arg, context):
54
for uom in self.browse(cursor, user, ids, context=context):
56
if uom.factor_inv_data_consol:
57
res[uom.id] = uom.factor_inv_data_consol
59
res[uom.id] = round(1 / uom.factor_consol, 6)
64
'p_uom_c_id':fields.many2one('product.uom.consol', 'Consolidate Unit', required=False),
65
'factor_consol': fields.float('Rate', digits=(12, 6), required=True,
66
help='The coefficient for the formula:\n' \
67
'1 (base unit) = coeff (this unit). Rate = 1 / Factor.'),
68
'factor_inv_consol': fields.function(_factor, digits=(12, 6),
69
method=True, string='Factor inv',
70
help='The coefficient for the formula:\n' \
71
'coeff (base unit) = 1 (this unit). Factor = 1 / Rate.'),
72
'factor_inv_data_consol': fields.float('Factor', digits=(12, 6)),
73
'rounding_consol': fields.float('Rounding Precision', digits=(16, 3), required=True,
74
help="The computed quantity will be a multiple of this value. Use 1.0 for products that can not be split."),
75
'analysis': fields.boolean('Active'),
76
'p_uom_id':fields.many2one('product.uom', 'Unit of measure', required=True, help="Unit of Measure used for compute."),
77
'name': fields.char('Name', size=64, required=False),
80
product_uom_consol_line()