~pexego/openobject-addons/6.1-pexego-sale_commission

« back to all changes in this revision

Viewing changes to full_stock_traceability/product.py

  • Committer: Omar (pexego)
  • Date: 2012-07-27 08:40:22 UTC
  • Revision ID: omar@pexego.es-20120727084022-qp3ludpr3vsuyuf6
[ADD] Traceability modules ported to 6.1

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) 2004-2011 Pexego (<www.pexego.es>). All Rights Reserved
 
6
#    $Omar Castiñeira Saavedra$
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU General Public License as published by
 
10
#    the Free Software Foundation, either version 3 of the License, or
 
11
#    (at your option) any later version.
 
12
#
 
13
#    This program is distributed in the hope that it will be useful,
 
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
#    GNU General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
"""add functionally for differentiate miscible products and not"""
 
24
 
 
25
from osv import fields, osv
 
26
from tools.translate import _
 
27
 
 
28
class product_product(osv.osv):
 
29
    """add functionally for differentiate miscible product and not miscible product"""
 
30
    _inherit = "product.product"
 
31
    
 
32
    _columns = {
 
33
                'miscible': fields.boolean('Miscible Product', help="If the product can be mixed check this, for not create a procurement in a production order, and can put inside mix locations and only these."),
 
34
                'not_do_procurement': fields.boolean('Don\'t procurement in production', help="If check, in production, if not is a miscible product won't do a procurement move."),
 
35
                'track_all': fields.boolean('Track All Lots' , help="Forces to specify a Production Lot for all moves containing this product. This will also disable auto picking")
 
36
                }
 
37
    _defaults = {
 
38
                 'miscible': lambda *a: 0,
 
39
                 'not_do_procurement': lambda *a: 0,
 
40
                 }
 
41
 
 
42
    def check_if_procurement(self, cr, uid, ids, vals):
 
43
        """checks if the product has configurate well the procurement"""
 
44
        if vals.get('miscible', False) and not vals.get('not_do_procurement', False):
 
45
            raise osv.except_osv(_('Error!'),
 
46
                _('Cannnot put this product to do procurement, because this poduct is marked as miscible and the miscible products don\'t do procurement.'))
 
47
        return True
 
48
 
 
49
    def write(self, cr, uid, ids, vals, context={}):
 
50
        """overwrites write method for checks if the procurement for the product is configurate well"""
 
51
        self.check_if_procurement(cr, uid, ids, vals)
 
52
 
 
53
        if vals.get('track_all', False):
 
54
            vals.update({ 'track_production' : True, 'track_incoming' : True, 'track_outgoing' : True})
 
55
 
 
56
        return super(product_product, self).write(cr, uid, ids, vals, context=context)
 
57
 
 
58
    def create(self, cr, uid, vals, context={}):
 
59
        """overwrites create method for checks if the procurement for the product is configurate well and creates sequence to production lots"""
 
60
        self.check_if_procurement(cr, uid, [], vals)
 
61
 
 
62
        if vals.get('track_all', False):
 
63
            vals.update({ 'track_production' : True, 'track_incoming' : True, 'track_outgoing' : True})
 
64
 
 
65
        return super(product_product, self).create(cr, uid, vals, context=context)
 
66
 
 
67
 
 
68
product_product()
 
69
 
 
70
class product_template(osv.osv):
 
71
    """add functionally for differentiate miscible product and not miscible product"""
 
72
    _inherit = "product.template"
 
73
 
 
74
    _columns = {
 
75
        'property_raw': fields.property(
 
76
            'stock.location',
 
77
            type='many2one',
 
78
            relation='stock.location',
 
79
            string="Raw Materials Location",
 
80
            method=True,
 
81
            view_load=True,
 
82
            help="For the current product (template), this stock location will be used, instead of the default one, as the source where search the products needs for a production of this product (template)."),
 
83
        'property_mix': fields.property(
 
84
            'stock.location',
 
85
            type='many2one',
 
86
            relation='stock.location',
 
87
            string='Mix Moves Location',
 
88
            method=True,
 
89
            view_load=True,
 
90
            help="Location where will go the products that form a mix")
 
91
        }
 
92
 
 
93
product_template()
 
 
b'\\ No newline at end of file'