~vauxoo/openerp-venezuela-localization/sisb_jose_consultar_rif_openerp

« back to all changes in this revision

Viewing changes to report_profit/unit_analisys.py

  • Committer: Javier Duran
  • Author(s): javier at vauxoo
  • Date: 2012-01-30 21:23:10 UTC
  • Revision ID: javier@squezee-vir-20120130212310-2gdkxqtdpnlwy49u
[REM] Se remueve el modulo report_profit, ya que es migrado al proyecto lp:addons-vauxoo

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- encoding: utf-8 -*-
2
 
##############################################################################
3
 
#
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>
7
 
#
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
13
 
# Service Company
14
 
#
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.
19
 
#
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.
24
 
#
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.
28
 
#
29
 
##############################################################################
30
 
 
31
 
from osv import osv
32
 
from osv import fields
33
 
from tools.translate import _
34
 
 
35
 
class product_uom_consol(osv.osv):
36
 
    _name = 'product.uom.consol'
37
 
    _description = 'A third unit to consolidate the sales and purchase.'
38
 
    _columns = {
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),
41
 
    }    
42
 
    
43
 
product_uom_consol()
44
 
 
45
 
class product_uom_consol_line(osv.osv):
46
 
    """
47
 
    Third Unit to consolidate sales and purchases!
48
 
    """
49
 
    _name = 'product.uom.consol.line'
50
 
    _description = ''' Elements to control the seconds unit of measure. '''
51
 
 
52
 
    def _factor(self, cursor, user, ids, name, arg, context):
53
 
        res = {}
54
 
        for uom in self.browse(cursor, user, ids, context=context):
55
 
            if uom.factor_consol:
56
 
                if uom.factor_inv_data_consol:
57
 
                    res[uom.id] = uom.factor_inv_data_consol
58
 
                else:
59
 
                    res[uom.id] = round(1 / uom.factor_consol, 6)
60
 
            else:
61
 
                res[uom.id] = 0.0
62
 
        return res
63
 
    _columns = {
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),
78
 
    }
79
 
 
80
 
product_uom_consol_line()