Skip to content

Commit

Permalink
[IMP] sale_stock_available_to_promise_release mto availability_status
Browse files Browse the repository at this point in the history
  • Loading branch information
santostelmo committed May 22, 2024
1 parent 8f7b9b7 commit 1f6901b
Showing 1 changed file with 4 additions and 11 deletions.
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"
# No stock
elif float_is_zero(available_qty, precision_rounding=rounding):
product_replenishment_date = product._get_next_replenishment_date()
Expand Down

0 comments on commit 1f6901b

Please sign in to comment.