From ef0cba867fbe96b7356dfb4b93372eb9eb0cf2df Mon Sep 17 00:00:00 2001 From: cubells Date: Thu, 26 May 2016 08:44:00 +0200 Subject: [PATCH 1/3] [IMP] Movimientos duplicados al transferir --- .../models/stock_picking.py | 1 - .../wizard/stock_transfer_details.py | 53 ++++++++++--------- 2 files changed, 27 insertions(+), 27 deletions(-) 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 From 7e33f18441f07e9f50acf1b5a8cafbc5ae7b5bc5 Mon Sep 17 00:00:00 2001 From: cubells Date: Thu, 26 May 2016 08:44:00 +0200 Subject: [PATCH 2/3] [IMP] Movimientos duplicados al transferir --- .../models/stock_picking.py | 1 - .../wizard/stock_transfer_details.py | 53 ++++++++++--------- 2 files changed, 27 insertions(+), 27 deletions(-) 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 From eae82b4412cd4a454d75ff1606678d0feab6ba74 Mon Sep 17 00:00:00 2001 From: Andhitia Rama Date: Mon, 30 May 2016 18:08:14 +0700 Subject: [PATCH 3/3] Rebase. Fix pylint --- stock_picking_package_info/README.rst | 1 + 1 file changed, 1 insertion(+) 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 ============================