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

[18.0][MIG] stock_picking_type_shipping_policy #988

Closed

Conversation

sebalix
Copy link
Contributor

@sebalix sebalix commented Feb 26, 2025

Notes:

  • previous shipping_policy field is replaced by force_move_type boolean field
  • migration script added to set the std field move_type based on the value of previous shipping_policy + set force_move_type to True
  • remove override of stock.move and switched to an override of <stock.picking>._compute_move_type
  • DESCRIPTION of the module updated (BTW the mentioned module stock_routing_operation doesn't exist, I supposed it should be stock_dynamic_routing?)

grindtildeath and others added 29 commits February 26, 2025 13:49
... stock_picking_group_by_partner_by_carrier (of
OCA/stock-logistics-workflow).

In stock_picking_group_by_partner_by_carrier, the override of the method
_search_picking_for_assignation adds a domain on:

("move_type", "=", self.group_id.move_type)

(self is the move to assign in a picking).

When the move_type of the procurement group is "direct", the transfer is
normally created with the move_type "direct": when a first move is
assigned to a picking and none is found, it creates one with type
"direct", the second move should find the same and be assigned to it.

This is not what happens, with stock_picking_type_shipping_policy
configured to "force_all_product_ready", as it changes the way the first
stock.picking is created:

    def _get_new_picking_values(self):
        res = super()._get_new_picking_values()
        picking_type = self.mapped("picking_type_id")
        if picking_type.shipping_policy == "force_as_soon_as_possible":
            res["move_type"] = "direct"
        elif picking_type.shipping_policy == "force_all_products_ready":
            res["move_type"] = "one"
        return res

The first stock.picking is created with a move_type of "one", so when
the second move search a stock.picking, it can't find it as it looks for
a "direct" one.

This glue module changes the domain of the grouping to take into account the
picking type's shipping policy when both modules are installed.
Currently translated at 100.0% (4 of 4 strings)

Translation: wms-13.0/wms-13.0-stock_picking_type_shipping_policy
Translate-URL: https://translation.odoo-community.org/projects/wms-13-0/wms-13-0-stock_picking_type_shipping_policy/es_MX/
Currently translated at 100.0% (4 of 4 strings)

Translation: wms-13.0/wms-13.0-stock_picking_type_shipping_policy
Translate-URL: https://translation.odoo-community.org/projects/wms-13-0/wms-13-0-stock_picking_type_shipping_policy/es_AR/
Currently translated at 100.0% (4 of 4 strings)

Translation: wms-16.0/wms-16.0-stock_picking_type_shipping_policy
Translate-URL: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_picking_type_shipping_policy/it/
Currently translated at 100.0% (4 of 4 strings)

Translation: wms-17.0/wms-17.0-stock_picking_type_shipping_policy
Translate-URL: https://translation.odoo-community.org/projects/wms-17-0/wms-17-0-stock_picking_type_shipping_policy/it/
@sebalix
Copy link
Contributor Author

sebalix commented Feb 26, 2025

/ocabot migration stock_picking_type_shipping_policy

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Feb 26, 2025
@OCA-git-bot OCA-git-bot mentioned this pull request Feb 26, 2025
4 tasks
@sebalix sebalix force-pushed the 18-mig-stock_picking_type_shipping_policy branch from 850589d to 5770e2d Compare February 26, 2025 16:43
@sebalix
Copy link
Contributor Author

sebalix commented Feb 26, 2025

@jbaudoux FYI in v18 we have a new field <stock.picking.type>.move_type (required), and the stock.picking takes in priority the <procurement.group>.move_type, otherwise fallback on the one defined in its picking_type_id.move_type: https://github.com/odoo/odoo/blob/18.0/addons/stock/models/stock_picking.py#L715-L719

But this std code doesn't allow to force the move_type as the current module does, like ignoring the group_id.move_type and force to picking_type_id.move_type. For now I kept the field <stock.picking.type>.shipping_policy defined by the current module, while changing its label to not conflict with the new std "Shipping Policy" field. But maybe we could leverage the std one to add new section values in it, to explicitely "force" the value we want. Your POV, keeping two fields, or try to merge them in one?

@sebalix sebalix force-pushed the 18-mig-stock_picking_type_shipping_policy branch from 5770e2d to 14a2bde Compare February 26, 2025 16:48
@sebalix sebalix marked this pull request as ready for review February 26, 2025 16:48
@@ -19,6 +19,7 @@ def _selection_shipping_policy(self):
]

shipping_policy = fields.Selection(
string="Force Shipping Policy",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the user's label to not conflict with move_type/Shipping Policy std field

Copy link
Contributor

Choose a reason for hiding this comment

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

I would change it to a boolean as the selection is now standard on the picking type as you said

Copy link
Contributor

Choose a reason for hiding this comment

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

and extend _compute_move_type on stock.picking to check that boolean to see if we should use the one from the picking type
https://github.com/odoo/odoo/blob/18.0/addons/stock/models/stock_picking.py#L716

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done:

  • previous shipping_policy field is replaced by force_move_type boolean field
  • migration script added to set the std field move_type based on the value of previous shipping_policy + set force_move_type to True
  • remove override of stock.move and switched to an override of <stock.picking>._compute_move_type
  • DESCRIPTION of the module updated (BTW the mentioned module stock_routing_operation doesn't exist, I supposed it should be stock_dynamic_routing?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we rename the module now that Odoo has some kind of support of the shipping policy on operation types? Like stock_picking_type_force_move_type or stock_picking_type_force_shipping_policy?

def test_shipping_policy(self):
self.pack_type.shipping_policy = "force_all_products_ready"
self.pick_type.shipping_policy = "force_as_soon_as_possible"
# Create picking
Copy link
Contributor Author

@sebalix sebalix Feb 26, 2025

Choose a reason for hiding this comment

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

Rewrote this part to align with new default Odoo delivery flow that creates the Pick first, then Pack + Ship.
To ensure things are created as expected, we generate the initial move/picking through a procurement.

@sebalix sebalix force-pushed the 18-mig-stock_picking_type_shipping_policy branch from b787fb5 to 45aef84 Compare February 27, 2025 14:59
@sebalix
Copy link
Contributor Author

sebalix commented Feb 27, 2025

Moved to OCA/stock-logistics-workflow#1888

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.