Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] stock_picking_package_info: duplicate moves on transfer #1242

Open
wants to merge 4 commits into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stock_picking_package_info/README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
============================
Stock picking packaging info
============================

Expand Down
1 change: 0 additions & 1 deletion stock_picking_package_info/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
53 changes: 27 additions & 26 deletions stock_picking_wave_package_info/wizard/stock_transfer_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -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