When scanning multiple serial numbers e.g., the list of pack operations can become quite long. In order to avoid that, we make it possible for pack operations to contain multiple lots. The implementation is done in the way that the links between moves and pack operations remains the way it was. The important difference is that on action_done, it will check all the reserved quants and their lots at once first and only afterwards, it will check the lots one by one to check what it can reserve. As the details for the lots for the pack operation became a real object, the wizards related to the pack operation details are not necessary anymore and were replaced by a form view of the pack operation.
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from openerp import models, fields, api
|
|
from openerp.tools import float_compare
|
|
|
|
class stock_immediate_transfer(models.TransientModel):
|
|
_name = 'stock.immediate.transfer'
|
|
_description = 'Immediate Transfer'
|
|
|
|
pick_id = fields.Many2one('stock.picking')
|
|
|
|
@api.model
|
|
def default_get(self, fields):
|
|
res = {}
|
|
active_id = self._context.get('active_id')
|
|
if active_id:
|
|
res = {'pick_id': active_id}
|
|
return res
|
|
|
|
@api.multi
|
|
def process(self):
|
|
self.ensure_one()
|
|
# If still in draft => confirm and assign
|
|
if self.pick_id.state == 'draft':
|
|
self.pick_id.action_confirm()
|
|
if self.pick_id.state != 'assigned':
|
|
self.pick_id.action_assign()
|
|
for pack in self.pick_id.pack_operation_ids:
|
|
if pack.product_qty > 0:
|
|
pack.write({'qty_done': pack.product_qty})
|
|
else:
|
|
pack.unlink()
|
|
self.pick_id.do_transfer() |