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

[16.0][IMP] sale_stock_available_to_promise_release mto availability_status #903

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
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
15 changes: 4 additions & 11 deletions sale_stock_available_to_promise_release/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ class SaleOrderLine(models.Model):
digits="Product Unit of Measure", compute="_compute_availability_status"
)

def _on_order_route(self):
self.ensure_one()
mto_route = self.env.ref("stock.route_warehouse0_mto")
product_is_mto = mto_route in self.product_id.route_ids
line_is_mto = mto_route == self.route_id
return product_is_mto or line_is_mto

@api.depends(
"move_ids.ordered_available_to_promise_uom_qty",
"product_id.route_ids",
Expand Down Expand Up @@ -73,11 +66,8 @@ def _get_availability_data(self):
# required values
product = self.product_id
rounding = product.uom_id.rounding
# on_order product
if self._on_order_route():
availability_status = "on_order"
# Fully available
elif (
if (
product.type == "service"
or float_compare(
available_qty, self.product_uom_qty, precision_rounding=rounding
Expand All @@ -90,6 +80,9 @@ def _get_availability_data(self):
elif float_compare(available_qty, 0, precision_rounding=rounding) == 1:
availability_status = "partial"
delayed_qty = self.product_uom_qty - available_qty
# On order product
elif self.is_mto:
availability_status = "on_order"
jbaudoux marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +83 to +85
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be checked first ?
We might have MTO sale order lines availability status set to partial here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends what we want to show to the user first. I would show 1st partial (we are able to deliver some qty), 2nd on_order ( we have no quantity available and need to fully order it)

Copy link
Member

Choose a reason for hiding this comment

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

If mto, it's on order, period, whether you have stock or not.

Copy link
Member

Choose a reason for hiding this comment

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

If user wants smth else, he changes the route on the so line, and that's it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sale person wants to know if product is available to ship or if action is required to order it. Otherwise this status is useless for him.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to display availability, then product shouldn't be MTO.
@jbaudoux @santostelmo can we discuss this ? I'm not sure to understand what we're solving here...

Copy link
Contributor

@jbaudoux jbaudoux May 22, 2024

Choose a reason for hiding this comment

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

@mmequignon For standard MTO products, it's on order when SO is draft but the status will update when the product is received and available.
Also, in case of MTO as MTS (MTO route that generates an orderpoint with min/max=0), then if you have stock because someone returned an MTO product, then you see if it is available when placing the SO

# No stock
elif float_is_zero(available_qty, precision_rounding=rounding):
jbaudoux marked this conversation as resolved.
Show resolved Hide resolved
product_replenishment_date = product._get_next_replenishment_date()
Expand Down
Loading