diff --git a/stock_picking_package_info/README.rst b/stock_picking_package_info/README.rst index e57addd7..3617f935 100644 --- a/stock_picking_package_info/README.rst +++ b/stock_picking_package_info/README.rst @@ -1,3 +1,4 @@ +============================ Stock picking packaging info ============================ diff --git a/stock_picking_package_info/models/stock_picking.py b/stock_picking_package_info/models/stock_picking.py index 6bada01c..a9c2044f 100644 --- a/stock_picking_package_info/models/stock_picking.py +++ b/stock_picking_package_info/models/stock_picking.py @@ -136,5 +136,4 @@ def create_all_move_packages(self): vals.update({'product_qty': new_qty}) else: continue - ops |= pack_op_obj.create(vals) return ops diff --git a/stock_picking_wave_package_info/wizard/stock_transfer_details.py b/stock_picking_wave_package_info/wizard/stock_transfer_details.py index 73dfb8d3..cc0da24b 100644 --- a/stock_picking_wave_package_info/wizard/stock_transfer_details.py +++ b/stock_picking_wave_package_info/wizard/stock_transfer_details.py @@ -12,30 +12,31 @@ class StockTransferDetails(models.TransientModel): @api.one def do_save_for_later(self): operation_obj = self.env['stock.pack.operation'] - for picking in self.picking_ids: - # Create new and update existing pack operations - picking.pack_operation_ids.unlink() - for line in [self.item_ids.filtered(lambda x: x.picking_id.id == - picking.id), - self.packop_ids.filtered(lambda x: x.picking_id.id == - picking.id)]: - for prod in line: - pack_datas = { - 'product_id': prod.product_id.id, - 'product_uom_id': prod.product_uom_id.id, - 'product_qty': prod.quantity, - 'package_id': prod.package_id.id, - 'lot_id': prod.lot_id.id, - 'location_id': prod.sourceloc_id.id, - 'location_dest_id': prod.destinationloc_id.id, - 'result_package_id': prod.result_package_id.id, - 'date': prod.date if prod.date else datetime.now(), - 'owner_id': prod.owner_id.id, - } - if prod.packop_id: - prod.packop_id.with_context(no_recompute=True).write( - pack_datas) - else: - pack_datas['picking_id'] = picking.id - operation_obj.create(pack_datas) + for data in self: + if data.picking_id: + # Create new and update existing pack operations + data.picking_id.pack_operation_ids.unlink() + for line in [self.item_ids.filtered( + lambda x: x.picking_id.id == data.picking_id.id), + self.packop_ids.filtered( + lambda x: x.picking_id.id == data.picking_id.id)]: + for prod in line: + pack_datas = { + 'product_id': prod.product_id.id, + 'product_uom_id': prod.product_uom_id.id, + 'product_qty': prod.quantity, + 'package_id': prod.package_id.id, + 'lot_id': prod.lot_id.id, + 'location_id': prod.sourceloc_id.id, + 'location_dest_id': prod.destinationloc_id.id, + 'result_package_id': prod.result_package_id.id, + 'date': prod.date if prod.date else datetime.now(), + 'owner_id': prod.owner_id.id, + } + if prod.packop_id: + prod.packop_id.with_context( + no_recompute=True).write(pack_datas) + else: + pack_datas['picking_id'] = data.picking_id.id + operation_obj.create(pack_datas) return True