1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2011 TeMPO Consulting, MSF
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
22
from osv import fields, osv
23
from tools.translate import _
27
class stock_partial_move_memory_out(osv.osv_memory):
28
_inherit = "stock.move.memory.out"
30
def _vals_get(self, cr, uid, ids, fields, arg, context=None):
32
multi fields function method
37
if isinstance(ids, (int, long)):
41
for obj in self.browse(cr, uid, ids, context=context):
42
result[obj.id] = {'kit_mem_check': False}
43
# we want the possibility to link a composition list if
44
# - the product is a kit AND
45
# - the product is not perishable nor batch management
46
product = obj.product_id
47
if product.type == 'product' and product.subtype == 'kit' and not product.perishable:
48
result[obj.id].update({'kit_mem_check': True})
51
_columns = {'composition_list_id': fields.many2one('composition.kit', string='Kit'),
52
'kit_mem_check' : fields.function(_vals_get, method=True, string='Kit Mem Check', type='boolean', readonly=True, multi='get_vals'),
55
stock_partial_move_memory_out()
57
class stock_partial_move_memory_in(osv.osv_memory):
58
_inherit = "stock.move.memory.out"
59
_name = "stock.move.memory.in"
61
stock_partial_move_memory_in()
64
class stock_partial_move(osv.osv_memory):
65
_inherit = "stock.partial.move"
67
def __create_partial_move_memory(self, move):
69
add the composition_list_id
71
move_memory = super(stock_partial_move, self).__create_partial_move_memory(move)
72
assert move_memory is not None
74
move_memory.update({'composition_list_id' : move.composition_list_id.id})
78
def do_partial_hook(self, cr, uid, context, *args, **kwargs):
80
add hook to do_partial
83
partial_datas = super(stock_partial_move, self).do_partial_hook(cr, uid, context, *args, **kwargs)
84
assert partial_datas, 'partial_datas missing'
86
move = kwargs.get('move')
87
assert move, 'move is missing'
88
p_moves = kwargs.get('p_moves')
89
assert p_moves, 'p_moves is missing'
91
# update composition_list_id
92
partial_datas['move%s' % (move.id)].update({'composition_list_id': p_moves[move.id].composition_list_id.id,})