[FIX] delivery, sale, sale_order_dates: ignore delivery line in commitment date computation
The commitment date is computed using every line from the sale order. When the picking policy is set to direct, it takes the earliest date among the sums of the order date and lead time. However when the delivery is set, is adds a line with an order date of 'now' and no lead time. This date thus necessarily becomes the commitment date, bypassing what was intended by setting a lead times on products. We simply ignore delivery lines in this computation. opw 1855646
This commit is contained in:
@@ -117,3 +117,7 @@ class SaleOrderLine(models.Model):
|
||||
if not line.product_id or not line.product_uom or not line.product_uom_qty:
|
||||
return 0.0
|
||||
line.product_qty = line.product_uom._compute_quantity(line.product_uom_qty, line.product_id.uom_id)
|
||||
|
||||
def _is_delivery(self):
|
||||
self.ensure_one()
|
||||
return self.is_delivery
|
||||
|
||||
@@ -1231,3 +1231,7 @@ class SaleOrderLine(models.Model):
|
||||
so_line.write({'qty_delivered': qty})
|
||||
|
||||
return True
|
||||
|
||||
def _is_delivery(self):
|
||||
self.ensure_one()
|
||||
return False
|
||||
|
||||
@@ -33,7 +33,7 @@ class SaleOrder(models.Model):
|
||||
for order in self:
|
||||
dates_list = []
|
||||
order_datetime = fields.Datetime.from_string(order.date_order)
|
||||
for line in order.order_line.filtered(lambda x: x.state != 'cancel'):
|
||||
for line in order.order_line.filtered(lambda x: x.state != 'cancel' and not x._is_delivery()):
|
||||
dt = order_datetime + timedelta(days=line.customer_lead or 0.0)
|
||||
dates_list.append(dt)
|
||||
if dates_list:
|
||||
|
||||
Reference in New Issue
Block a user