diff options
| author | Jérome Maes <jem@openerp.com> | 2017-09-13 16:30:55 +0200 |
|---|---|---|
| committer | Jérome Maes <jem@openerp.com> | 2017-09-14 14:48:07 +0200 |
| commit | 04dd0a2dd481ed2f9d134df8fbafb67edb07642e (patch) | |
| tree | cff46f1f881bd129a8fc58b890504323a87e2378 | |
| parent | 751330a843f30298f50a479cba3d22b5ffaf6cb3 (diff) | |
[IMP] sale: create an ananlytic on SO confirmation when at least an expense product
This behavior kind of disappear with 48ea59d46e26b7b5a8eebfe06740482f1a263d72
Moreover, since the Analytic Accounting is hidden, and
a AA on expense is required to reinvoice product on
SO, an AA should be on the SO as default value.
| -rw-r--r-- | addons/sale/models/sale.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 5ff3dc3ab77..9b354af7ab6 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -520,6 +520,12 @@ class SaleOrder(models.Model): self.force_quotation_send() if self.env['ir.config_parameter'].sudo().get_param('sale.auto_done_setting'): self.action_done() + + # create an analytic account if at least an expense product + if any([expense_policy != 'no' for expense_policy in self.order_line.mapped('product_id.expense_policy')]): + if not self.analytic_account_id: + self._create_analytic_account() + return True @api.multi @@ -786,7 +792,9 @@ class SaleOrderLine(models.Model): if line.state == 'sale': msg = _("Extra line with %s ") % (line.product_id.display_name,) line.order_id.message_post(body=msg) - + # create an analytic account if at least an expense product + if line.product_id.expense_policy != 'no' and not self.order_id.analytic_account_id: + self.order_id._create_analytic_account() return line def _update_line_quantity(self, values): |
