1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2011 Pexego (<www.pexego.es>). All Rights Reserved
6
# $Omar Castiñeira Saavedra$
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.
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.
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/>.
21
##############################################################################
23
"""add functionally for differentiate miscible products and not"""
25
from osv import fields, osv
26
from tools.translate import _
28
class product_product(osv.osv):
29
"""add functionally for differentiate miscible product and not miscible product"""
30
_inherit = "product.product"
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")
38
'miscible': lambda *a: 0,
39
'not_do_procurement': lambda *a: 0,
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.'))
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)
53
if vals.get('track_all', False):
54
vals.update({ 'track_production' : True, 'track_incoming' : True, 'track_outgoing' : True})
56
return super(product_product, self).write(cr, uid, ids, vals, context=context)
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)
62
if vals.get('track_all', False):
63
vals.update({ 'track_production' : True, 'track_incoming' : True, 'track_outgoing' : True})
65
return super(product_product, self).create(cr, uid, vals, context=context)
70
class product_template(osv.osv):
71
"""add functionally for differentiate miscible product and not miscible product"""
72
_inherit = "product.template"
75
'property_raw': fields.property(
78
relation='stock.location',
79
string="Raw Materials Location",
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(
86
relation='stock.location',
87
string='Mix Moves Location',
90
help="Location where will go the products that form a mix")
b'\\ No newline at end of file'