[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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user