diff options
| author | Martin Trigaux <mat@odoo.com> | 2015-12-01 08:41:52 +0100 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2015-12-01 08:41:52 +0100 |
| commit | a9ec2894ded44e405a9adfe8a8c021a7dcc27c20 (patch) | |
| tree | 56f82900a68aa55a84c8f4819082272498910f1a /addons/account_analytic_default | |
| parent | 0ee11f23f15ab11851baf3ca00d9c3a5947fe294 (diff) | |
| parent | 19fe77b7d71aed1b25bc3f15538eea0a5510020b (diff) | |
[MERGE] forward port of branch saas-6 up to 19fe77b
Diffstat (limited to 'addons/account_analytic_default')
| -rw-r--r-- | addons/account_analytic_default/account_analytic_default.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/account_analytic_default/account_analytic_default.py b/addons/account_analytic_default/account_analytic_default.py index 7fa23b1b0f6..5b38ad413c1 100644 --- a/addons/account_analytic_default/account_analytic_default.py +++ b/addons/account_analytic_default/account_analytic_default.py @@ -131,3 +131,17 @@ class product_template(osv.Model): # Remove context so it is not going to filter on product_id with active_id of template result['context'] = "{}" return result + + +class stock_move(osv.Model): + _inherit = 'stock.move' + + def _create_invoice_line_from_vals(self, cr, uid, move, invoice_line_vals, context=None): + # It will set the default analtyic account on the invoice line + partner_id = self.pool['account.invoice'].browse(cr, uid, invoice_line_vals.get('invoice_id'), context=context).partner_id.id + if 'account_analytic_id' not in invoice_line_vals or not invoice_line_vals.get('account_analytic_id'): + rec = self.pool['account.analytic.default'].account_get(cr, uid, move.product_id.id, partner_id, uid, time.strftime('%Y-%m-%d'), company_id=move.company_id.id, context=context) + if rec: + invoice_line_vals.update({'account_analytic_id': rec.analytic_id.id}) + res = super(stock_move, self)._create_invoice_line_from_vals(cr, uid, move, invoice_line_vals, context=context) + return res |
