Permalink
Browse files

[FIX] sale: ensure a non null date

Sometimes, a sale.order in the SALE state doesn't have a confirmed date,
which can cause a traceback. To avoid this, when confirmation_date is
null, use the write_date, which is never NULL when sale.order is in sale
state.
  • Loading branch information...
nseinlet committed Oct 30, 2018
1 parent eaedfe4 commit b3b9980a97f341d51b521fdf6c8558b3154f522d
Showing with 2 additions and 2 deletions.
  1. +1 −1 addons/sale/models/sale.py
  2. +1 −1 addons/sale_stock/models/sale_order.py
@@ -228,7 +228,7 @@ def _compute_expected_date(self):
"""
for order in self:
dates_list = []
confirm_date = fields.Datetime.from_string(order.confirmation_date if order.state == 'sale' else fields.Datetime.now())
confirm_date = fields.Datetime.from_string((order.confirmation_date or order.write_date) if order.state == 'sale' else fields.Datetime.now())
for line in order.order_line.filtered(lambda x: x.state != 'cancel' and not x._is_delivery()):
dt = confirm_date + timedelta(days=line.customer_lead or 0.0)
dates_list.append(dt)
@@ -48,7 +48,7 @@ def _compute_expected_date(self):
super(SaleOrder, self)._compute_expected_date()
for order in self:
dates_list = []
confirm_date = fields.Datetime.from_string(order.confirmation_date if order.state == 'sale' else fields.Datetime.now())
confirm_date = fields.Datetime.from_string((order.confirmation_date or order.write_date) if order.state == 'sale' else fields.Datetime.now())
for line in order.order_line.filtered(lambda x: x.state != 'cancel'):
dt = confirm_date + timedelta(days=line.customer_lead or 0.0)
dates_list.append(dt)

0 comments on commit b3b9980

Please sign in to comment.