[FIX] sale: Correct sale order management on accounting entries creation

If an analytic account is not linked to sale order, do nothing (and do not return False which is not a valid value for a write ({} would have been valid)). We should allow the simple analytic accounting without sales order.
This commit is contained in:
Yannick Tivisse
2016-09-19 15:40:08 +02:00
parent db42c46eb7
commit e04b44dad1
+1 -3
View File
@@ -80,9 +80,7 @@ class AccountAnalyticLine(models.Model):
so_line = result.get('so_line', False) or self.so_line
if not so_line and self.account_id and self.product_id and (self.product_id.expense_policy != 'no'):
order = self.env['sale.order'].search([('project_id', '=', self.account_id.id)], limit=1)
if not order:
return False
if order.state != 'sale':
if order and order.state != 'sale':
raise UserError(_('The Sale Order %s linked to the Analytic Account must be validated before registering expenses.') % order.name)
order = self.env['sale.order'].search([('project_id', '=', self.account_id.id), ('state', '=', 'sale')], limit=1)