Openerp 如果数量>订单数量,我们如何拒绝库存转移?

Openerp 如果数量>订单数量,我们如何拒绝库存转移?,openerp,transfer,odoo,stock,Openerp,Transfer,Odoo,Stock,odoo中的新库存管理允许转移超过命令数量的库存 当数量>订单.数量时,我们如何拒绝进行详细的库存转移.拣货?如果有以下额外动作,我们将进行警告: 升高osv。除“警告”外, _u'数量超过验证数量!!' 您必须创建一个模块或修改扩展对象“stock.transfert_details”的Odoo核心代码。在此扩展对象中,重新定义方法“do_detaild_transfer”以检查加工数量,如果加工数量大于指令数量,则会引发错误。 @api.cr_uid_ids_context

odoo中的新库存管理允许转移超过命令数量的库存


当数量>订单.数量时,我们如何拒绝进行详细的库存转移.拣货?如果有以下额外动作,我们将进行警告: 升高osv。除“警告”外, _u'数量超过验证数量!!'


您必须创建一个模块或修改扩展对象“stock.transfert_details”的Odoo核心代码。在此扩展对象中,重新定义方法“do_detaild_transfer”以检查加工数量,如果加工数量大于指令数量,则会引发错误。
    @api.cr_uid_ids_context
    def do_transfer(self, cr, uid, picking_ids, context=None):
        """
            If no pack operation, we do simple action_done of the picking
            Otherwise, do the pack operations
        """
        if not context:
            context = {}
        stock_move_obj = self.pool.get('stock.move')
        for picking in self.browse(cr, uid, picking_ids, context=context):
            if not picking.pack_operation_ids:
                self.action_done(cr, uid, [picking.id], context=context)
                continue
            else:
                need_rereserve, all_op_processed = self.picking_recompute_remaining_quantities(cr, uid, picking, context=context)
                #create extra moves in the picking (unexpected product moves coming from pack operations)
                todo_move_ids = []
                if not all_op_processed:
                    todo_move_ids += self._create_extra_moves(cr, uid, picking, context=context)
                    **raise osv.except_osv(_('Warning !'),
                                             _(u'The quantity is more than validate quantity !!') )**
                #split move lines if needed
                toassign_move_ids = []
                for move in picking.move_lines:
                    remaining_qty = move.remaining_qty
                    if move.state in ('done', 'cancel'):
                        #ignore stock moves cancelled or already done
                        continue
                    elif move.state == 'draft':
                        toassign_move_ids.append(move.id)
                    if float_compare(remaining_qty, 0,  precision_rounding = move.product_id.uom_id.rounding) == 0:
                        if move.state in ('draft', 'assigned', 'confirmed'):
                            todo_move_ids.append(move.id)
                    elif float_compare(remaining_qty,0, precision_rounding = move.product_id.uom_id.rounding) > 0 and \
                                float_compare(remaining_qty, move.product_qty, precision_rounding = move.product_id.uom_id.rounding) < 0:
                        raise osv.except_osv(_('Warning !'),
                                             _(u'La quantity doit être inferieur à %s'% move.product_qty) )
                        return False
                        new_move = stock_move_obj.split(cr, uid, move, remaining_qty, context=context)
                        todo_move_ids.append(move.id)
                        #Assign move as it was assigned before
                        toassign_move_ids.append(new_move)
                if need_rereserve or not all_op_processed: 
                    if not picking.location_id.usage in ("supplier", "production", "inventory"):
                        self.rereserve_quants(cr, uid, picking, move_ids=todo_move_ids, context=context)
                    self.do_recompute_remaining_quantities(cr, uid, [picking.id], context=context)
                if todo_move_ids and not context.get('do_only_split'):
                    self.pool.get('stock.move').action_done(cr, uid, todo_move_ids, context=context)
                elif context.get('do_only_split'):
                    context = dict(context, split=todo_move_ids)
            self._create_backorder(cr, uid, picking, context=context)
            if toassign_move_ids:
                stock_move_obj.action_assign(cr, uid, toassign_move_ids, context=context)
        return True