Skip to content

Conversation

@JordiMForgeFlow
Copy link
Contributor

@JordiMForgeFlow JordiMForgeFlow commented Jul 18, 2025

In <=V16 Odoo used to automatically split the move lines when packing based on the quantity done on the move line (see: https://github.com/odoo/odoo/blob/fd5fe84f70dabc4b7d045f5181508658b6596c9c/addons/stock/models/stock_picking.py#L1457).

Since V17 the qty done field is not used anymore and Odoo is no longer splitting (see: https://github.com/odoo/odoo/blob/c5222a82887b6c5c781fe823865e2573c14e8b7b/addons/stock/models/stock_picking.py#L1782). Therefore, we manage the split ourselves.

@JordiMForgeFlow JordiMForgeFlow force-pushed the 18.0-mig-stock_picking_auto_create_package branch from 85a89ca to 32ca896 Compare July 18, 2025 11:14
Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a comment

Choose a reason for hiding this comment

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

👍 Code review LGTM

@jbaudoux
Copy link
Contributor

To notify contributors about this migration @raumschmiede-joshuaL @mt-software-de @rousseldenis

Copy link
Contributor

@mt-software-de mt-software-de left a comment

Choose a reason for hiding this comment

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

Thx, for the migration.

Comment on lines 51 to 54
if ml.lot_id:
vals["lot_id"] = False
if ml.lot_name:
vals["lot_name"] = False
Copy link
Contributor

Choose a reason for hiding this comment

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

In v16 it removed the lot, but is this really necessary, and a good approach?

If there is a stock.move.line with a lot for a quantity, it will then be depending on the qty_to_pack, how much you will receive for the scanned lot.

For example: You picked 10 times the same lot and then want to create a automatic package for the qty 1. This will end up with 10 move lines, with a qty of 1. But only the first move.line is containing the lot. The rest will not have any lot.

Copy link
Contributor

Choose a reason for hiding this comment

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

ping @jbaudoux

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mt-software-de mm yes, it does not make much sense to remove the lot if we are just splitting

jbaudoux and others added 16 commits August 18, 2025 12:53
… of 1

This will put the move line per piece in a separate package
Also it is now possible to package an amount which is not a multiple of a its packaging amount
For example: a move over 5 pieces and with a packaging amount of 2
will create 3 packages with following amounts 2 2 1
Currently translated at 11.1% (1 of 9 strings)

Translation: stock-logistics-workflow-14.0/stock-logistics-workflow-14.0-stock_picking_auto_create_package
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-workflow-14-0/stock-logistics-workflow-14-0-stock_picking_auto_create_package/it/
@JordiMForgeFlow JordiMForgeFlow force-pushed the 18.0-mig-stock_picking_auto_create_package branch from 4bed8d9 to 73fc56d Compare August 18, 2025 10:53
Copy link
Contributor

@mt-software-de mt-software-de left a comment

Choose a reason for hiding this comment

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

LG

@rousseldenis
Copy link
Contributor

/ocabot migration stock_picking_auto_create_package

@OCA-git-bot OCA-git-bot mentioned this pull request Aug 28, 2025
80 tasks
Copy link
Contributor

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

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

As the package creation occurs before action done, to keep same behavior as before, we should rely on a picked quantity and not on the reserved quantity.
So depend on https://github.com/OCA/stock-logistics-workflow/tree/18.0/stock_move_line_qty_picked and replace quantity by picked_qty
WDYT @mt-software-de

@mt-software-de
Copy link
Contributor

mt-software-de commented Aug 29, 2025

As the package creation occurs before action done, to keep same behavior as before, we should rely on a picked quantity and not on the reserved quantity. So depend on https://github.com/OCA/stock-logistics-workflow/tree/18.0/stock_move_line_qty_picked and replace quantity by picked_qty WDYT @mt-software-de

If i am getting it correct stock_move_line_qty_picked is there, for not losing the reservation until the transfers is set to done and keeping the picked qty in a separate field.
Why is it done like that and not just created a new move line with the remaining qty, when something is picked?
Also i have seen that this addon is already be used as a dependency for shopfloor. Was it considered to create new move lines? But this doesn't really matter, here.

When you suggesting to rely on qty_picked we need stock_move_line_qty_picked as dependency here, but also on all other addons which are using quantity of stock.move.line.

IMO there a two possible options here

  • add the new dependency and rely on qty_picked
  • rely on quantity and ensure that qty_picked is in sync with quantity before action_done is called, for example by using _register_hook in stock_move_line_qty_picked instead of directly overwriting it
    def _action_done(self, cancel_backorder=False):
    this means that we do not need a dependency here or on any other addon which is using quantity of stock.move.line.

@mt-software-de
Copy link
Contributor

As the package creation occurs before action done, to keep same behavior as before, we should rely on a picked quantity and not on the reserved quantity. So depend on https://github.com/OCA/stock-logistics-workflow/tree/18.0/stock_move_line_qty_picked and replace quantity by picked_qty WDYT @mt-software-de

After checking everything for a response of your initial question, i maybe found a general problem with stock_picking_auto_create_package?

For example: If you end up with:

  • a move with a demand of 2
  • two move lines with a quantity of 1
  • picking type configured `automatic_package_creation_mode == "packaging"
  • smallest packaging on product with a quantity of 2

Then the addon will never create package for a qty of 2 instead i will create two packages with a quantity of 1.
Because https://github.com/ForgeFlow/stock-logistics-workflow/blob/73fc56d39ff52a78e2241c4bf7b32efe873f96fc/stock_picking_auto_create_package/models/stock_picking.py#L41 relies on the quantity of a move.line and not on the quantity of the move.

What do you think @jbaudoux

@mt-software-de
Copy link
Contributor

As the package creation occurs before action done, to keep same behavior as before, we should rely on a picked quantity and not on the reserved quantity. So depend on https://github.com/OCA/stock-logistics-workflow/tree/18.0/stock_move_line_qty_picked and replace quantity by picked_qty WDYT @mt-software-de

If i am getting it correct stock_move_line_qty_picked is there, for not losing the reservation until the transfers is set to done and keeping the picked qty in a separate field. Why is it done like that and not just created a new move line with the remaining qty, when something is picked? Also i have seen that this addon is already be used as a dependency for shopfloor. Was it considered to create new move lines? But this doesn't really matter, here.

When you suggesting to rely on qty_picked we need stock_move_line_qty_picked as dependency here, but also on all other addons which are using quantity of stock.move.line.

IMO there a two possible options here

* add the new dependency and rely on qty_picked

* rely on `quantity` and ensure that `qty_picked` is in sync with quantity before action_done is called, for example by using `_register_hook` in `stock_move_line_qty_picked` instead of directly overwriting it https://github.com/OCA/stock-logistics-workflow/blob/5e864299d5ab5a44b8275ac0b45ba0a051d9e49b/stock_move_line_qty_picked/models/stock_move.py#L28
   this means that we do not need a dependency here or on any other addon which is using `quantity` of `stock.move.line`.

#2091

@jbaudoux
Copy link
Contributor

As the package creation occurs before action done, to keep same behavior as before, we should rely on a picked quantity and not on the reserved quantity. So depend on https://github.com/OCA/stock-logistics-workflow/tree/18.0/stock_move_line_qty_picked and replace quantity by picked_qty WDYT @mt-software-de

If i am getting it correct stock_move_line_qty_picked is there, for not losing the reservation until the transfers is set to done and keeping the picked qty in a separate field.

Yes exactly

Why is it done like that and not just created a new move line with the remaining qty, when something is picked? Also i have seen that this addon is already be used as a dependency for shopfloor. Was it considered to create new move lines? But this doesn't really matter, here.

Because it's convenient

When you suggesting to rely on qty_picked we need stock_move_line_qty_picked as dependency here, but also on all other addons which are using quantity of stock.move.line.

Beside shopfloor, this addon is the only one I found so far having to care for this. Other addons hook after action done and not before or don't care about the quantity.

IMO there a two possible options here

  • add the new dependency and rely on qty_picked
  • rely on quantity and ensure that qty_picked is in sync with quantity before action_done is called, for example by using _register_hook in stock_move_line_qty_picked instead of directly overwriting it
    def _action_done(self, cancel_backorder=False):

    this means that we do not need a dependency here or on any other addon which is using quantity of stock.move.line.

@JordiMForgeFlow
Copy link
Contributor Author

@jbaudoux Odoo standard already gives us the "picked" boolean in order to check the lines that have been picked, not really sure if we should need to force the dependency or if it can simply be a glue module in case you are using both.

@mt-software-de
Copy link
Contributor

@jbaudoux Odoo standard already gives us the "picked" boolean in order to check the lines that have been picked, not really sure if we should need to force the dependency or if it can simply be a glue module in case you are using both.

With this PR #2091 a glue module wouldn't be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants