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 authored and jem-odoo committed Oct 30, 2018
1 parent 7aa2136 commit c7770a518ab9cc3462aca92078b4ea89fc63fb23
Showing with 3 additions and 3 deletions.
  1. +1 −1 addons/sale/models/sale.py
  2. +2 −2 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,8 +48,8 @@ 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())
for line in order.order_line.filtered(lambda x: x.state != 'cancel' and not x._is_delivery()):
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)
if dates_list:

0 comments on commit c7770a5

Please sign in to comment.