summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2016-09-19 15:28:24 +0200
committerYannick Tivisse <yti@odoo.com>2016-09-19 15:40:08 +0200
commite04b44dad1df732cf0bf09eb4ece825cb5432c67 (patch)
tree376156662808dc1ae99e8d5ebe2a72bf5b7fa181
parentdb42c46eb7e37b1312047697bb690bd8e508b08e (diff)
[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.
-rw-r--r--addons/sale/models/sale_analytic.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/addons/sale/models/sale_analytic.py b/addons/sale/models/sale_analytic.py
index 81852f4a8a2..36340863725 100644
--- a/addons/sale/models/sale_analytic.py
+++ b/addons/sale/models/sale_analytic.py
@@ -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)