[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. In migration, we will try to populate the confirmation date with the mail.message subtype. As ultimate fallback, we will take the write_date. closes odoo/odoo#28296
This commit is contained in:
committed by
jem-odoo
parent
8f39509d27
commit
e1c9efb2d2
@@ -228,7 +228,7 @@ class SaleOrder(models.Model):
|
||||
"""
|
||||
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 @@ class SaleOrder(models.Model):
|
||||
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' and not x._is_delivery()):
|
||||
dt = confirm_date + timedelta(days=line.customer_lead or 0.0)
|
||||
dates_list.append(dt)
|
||||
|
||||
Reference in New Issue
Block a user