# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ############################################################################## from osv import fields, osv from tools.translate import _ import time class stock_partial_picking(osv.osv_memory): _name = "stock.partial.picking" _description = "Partial Picking" _columns = { 'date': fields.datetime('Date', required=True), 'product_moves_out' : fields.one2many('stock.move.memory.out', 'wizard_id', 'Moves'), 'product_moves_in' : fields.one2many('stock.move.memory.in', 'wizard_id', 'Moves'), } def __is_in(self,cr, uid, pick_ids): """ @return: True if one of the moves has as picking type 'in' """ if not pick_ids: return False pick_obj = self.pool.get('stock.picking') pick_ids = pick_obj.search(cr, uid, [('id','in',pick_ids)]) for pick in pick_obj.browse(cr, uid, pick_ids): for move in pick.move_lines: if pick.type == 'in' and move.product_id.cost_method == 'average': return True return False def __get_picking_type(self, cr, uid, pick_ids): if self.__is_in(cr, uid, pick_ids): return "product_moves_in" else: return "product_moves_out" def view_init(self, cr, uid, fields_list, context=None): res = super(stock_partial_picking, self).view_init(cr, uid, fields_list, context=context) return res def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) picking_ids = context.get('active_ids', False) picking_type = self.__get_picking_type(cr, uid, picking_ids) _moves_arch_lst = """
""" % (_('Process Document'), _('Products'), picking_type) _moves_fields = result['fields'] _moves_fields.update({ 'product_moves_in' : {'relation': 'stock.move.memory.in', 'type' : 'one2many', 'string' : 'Product Moves'}, 'product_moves_out' : {'relation': 'stock.move.memory.out', 'type' : 'one2many', 'string' : 'Product Moves'} }) _moves_arch_lst += """