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 _
26
class stock_partial_picking(osv.osv_memory):
27
_inherit = "stock.partial.picking"
28
_description = "Partial Picking with hook"
31
def do_partial_hook(self, cr, uid, context, *args, **kwargs):
33
add hook to do_partial
35
partial_datas = kwargs.get('partial_datas')
36
assert partial_datas, 'partial_datas missing'
41
# @@@override stock>wizard>stock_partial_picking.py>stock_partial_picking
42
def do_partial(self, cr, uid, ids, context=None):
43
""" Makes partial moves and pickings done.
44
@param self: The object pointer.
45
@param cr: A database cursor
46
@param uid: ID of the user currently logged in
47
@param fields: List of fields for which we want default values
48
@param context: A standard dictionary
49
@return: A dictionary which of fields with values.
51
pick_obj = self.pool.get('stock.picking')
53
picking_ids = context.get('active_ids', False)
54
partial = self.browse(cr, uid, ids[0], context=context)
56
'delivery_date' : partial.date
59
for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
60
picking_type = self.get_picking_type(cr, uid, pick, context=context)
61
moves_list = picking_type == 'in' and partial.product_moves_in or partial.product_moves_out
63
for move in moves_list:
64
partial_datas['move%s' % (move.move_id.id)] = {
65
'product_id': move.id,
66
'product_qty': move.quantity,
67
'product_uom': move.product_uom.id,
68
'prodlot_id': move.prodlot_id.id,
70
if (picking_type == 'in') and (move.product_id.cost_method == 'average'):
71
partial_datas['move%s' % (move.move_id.id)].update({
72
'product_price' : move.cost,
73
'product_currency': move.currency.id,
76
# override : add hook call
77
partial_datas = self.do_partial_hook(cr, uid, context, move=move, partial_datas=partial_datas)
80
pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
81
return {'type': 'ir.actions.act_window_close'}
84
stock_partial_picking()