This commit sets up the logic and adds the button for "Put in Pack" action that already exists in stock.picking. Reuse/extension of logic from stock.picking reused where possible, including extension of pack wizard to handle products with different destination. Note that logic to handle "Delivery Packaging" wizard when "Delivery Methods" is active was purposely not extended to work correctly in batch pickings due to complexity of adding in a new module just to handle conflicting carrier_ids across pickings in the same batch. It is expected that this use case will not occur except in case of user error. Additionally, stock.picking implementation of 'put_in_pack' method has been renamed to 'action_put_in_pack' to have consistent naming (and support enterprise level code). Part of "1. Improve Batch Pickings" specification of overall barcode improvements task. Task: 1884520 Enterprise PR: odoo/enterprise#12086 Closes: odoo/odoo#55096
30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class ChooseDestinationLocation(models.TransientModel):
|
|
_name = 'stock.package.destination'
|
|
_description = 'Stock Package Destination'
|
|
|
|
picking_id = fields.Many2one('stock.picking', required=True)
|
|
move_line_ids = fields.Many2many('stock.move.line', 'Products', compute='_compute_move_line_ids', required=True)
|
|
location_dest_id = fields.Many2one('stock.location', 'Destination location', required=True)
|
|
filtered_location = fields.One2many(comodel_name='stock.location', compute='_filter_location')
|
|
|
|
@api.depends('picking_id')
|
|
def _compute_move_line_ids(self):
|
|
for destination in self:
|
|
destination.move_line_ids = destination.picking_id.move_line_ids.filtered(lambda l: l.qty_done > 0 and not l.result_package_id)
|
|
|
|
@api.depends('move_line_ids')
|
|
def _filter_location(self):
|
|
for destination in self:
|
|
destination.filtered_location = destination.move_line_ids.mapped('location_dest_id')
|
|
|
|
def action_done(self):
|
|
# set the same location on each move line and pass again in action_put_in_pack
|
|
self.move_line_ids.location_dest_id = self.location_dest_id
|
|
return self.picking_id.action_put_in_pack()
|