[FIX] sale: do not schedule activity when no user_id

- The `_write` override on `sale.order` create a Next Activity for the
  SO's salesperson when changing the SO `invoice_status` to upselling.

  If the SO doesn't have a salesperson this code crashes since `user_id`
  is required on Next Activities.
  To avoid this crash we create the Next Activity only if a salesperson
  is set on the SO.

  OPW-1914087
This commit is contained in:
Toufik Ben Jaa
2018-12-10 11:43:12 +01:00
parent f32cdb5ccf
commit 007669feac
+1 -1
View File
@@ -309,7 +309,7 @@ class SaleOrder(models.Model):
if 'invoice_status' in values:
self.activity_unlink(['sale.mail_act_sale_upsell'])
if values['invoice_status'] == 'upselling':
for order in self:
for order in self.filtered('user_id'):
order.activity_schedule(
'sale.mail_act_sale_upsell', fields.Date.today(),
user_id=order.user_id.id,