Skip to content
Open
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
19 changes: 15 additions & 4 deletions shopfloor/services/single_pack_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,25 @@ def start(self, barcode, confirmation=None):

return self._response_for_scan_location(package_level)

def _prepare_picking_vals_for_package(self, package):
vals = {}
if package.owner_id:
vals["owner_id"] = package.owner_id.id
Comment on lines +185 to +186
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should do that only when you want to change ownership from what I remember.

The package will have an owner when all quants inside it have that owner.
The picking should keep the quant ownership during the transfer (unless you force another one on the picking). The created moves will have the owner of the quant inside the package. Same for the move lines.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes in the normal case it is keeping the owner, but somehow in this scenario its not the case. I need to investigate why.

return vals

def _create_picking_for_package(self, package):
picking_vals = self._prepare_picking_vals_for_package(package)
StockPicking = self.env["stock.picking"].with_context(
default_picking_type_id=self.picking_types.id
)
picking = StockPicking.create(picking_vals)
return picking

def _create_package_level(self, package):
# this method can be called only if we have one picking type
# (allow_move_create==True on menu)
assert self.picking_types.ensure_one()
StockPicking = self.env["stock.picking"].with_context(
default_picking_type_id=self.picking_types.id
)
picking = StockPicking.create({})
picking = self._create_picking_for_package(package)
package_level = self.env["stock.package_level"].create(
{
"picking_id": picking.id,
Expand Down