diff --git a/addons/account/account.py b/addons/account/account.py index caf1d68c45d..36e540359f5 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1862,8 +1862,10 @@ class account_tax(osv.osv): 'applicable_type': fields.selection( [('true','Always'), ('code','Given by Python Code')], 'Applicability', required=True, help="If not applicable (computed through a Python code), the tax won't appear on the invoice."), 'domain':fields.char('Domain', size=32, help="This field is only used if you develop your own module allowing developers to create specific taxes in a custom domain."), - 'account_collected_id':fields.many2one('account.account', 'Invoice Tax Account'), - 'account_paid_id':fields.many2one('account.account', 'Refund Tax Account'), + 'account_collected_id':fields.many2one('account.account', 'Invoice Tax Account', help="Set the account that will be set by default on invoice tax lines for invoices. Leave empty to use the expense account."), + 'account_paid_id':fields.many2one('account.account', 'Refund Tax Account', help="Set the account that will be set by default on invoice tax lines for refunds. Leave empty to use the expense account."), + 'account_analytic_collected_id':fields.many2one('account.analytic.account', 'Invoice Tax Analytic Account', help="Set the analytic account that will be used by default on the invoice tax lines for invoices. Leave empty if you don't want to use an analytic account on the invoice tax lines by default."), + 'account_analytic_paid_id':fields.many2one('account.analytic.account', 'Refund Tax Analytic Account', help="Set the analytic account that will be used by default on the invoice tax lines for refunds. Leave empty if you don't want to use an analytic account on the invoice tax lines by default."), 'parent_id':fields.many2one('account.tax', 'Parent Tax Account', select=True), 'child_ids':fields.one2many('account.tax', 'parent_id', 'Child Tax Accounts'), 'child_depend':fields.boolean('Tax on Children', help="Set if the tax computation is based on the computation of child taxes rather than on the total amount."), @@ -2001,6 +2003,8 @@ class account_tax(osv.osv): 'name':tax.description and tax.description + " - " + tax.name or tax.name, 'account_collected_id':tax.account_collected_id.id, 'account_paid_id':tax.account_paid_id.id, + 'account_analytic_collected_id': tax.account_analytic_collected_id.id, + 'account_analytic_paid_id': tax.account_analytic_paid_id.id, 'base_code_id': tax.base_code_id.id, 'ref_base_code_id': tax.ref_base_code_id.id, 'sequence': tax.sequence, @@ -2160,6 +2164,8 @@ class account_tax(osv.osv): 'amount': amount, 'account_collected_id': tax.account_collected_id.id, 'account_paid_id': tax.account_paid_id.id, + 'account_analytic_collected_id': tax.account_analytic_collected_id.id, + 'account_analytic_paid_id': tax.account_analytic_paid_id.id, 'base_code_id': tax.base_code_id.id, 'ref_base_code_id': tax.ref_base_code_id.id, 'sequence': tax.sequence, diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index c6011979f8d..5e27a2e3663 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -756,7 +756,7 @@ class account_invoice(osv.osv): for tax in inv.tax_line: if tax.manual: continue - key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id) + key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id, tax.account_analytic_id.id) tax_key.append(key) if not key in compute_taxes: raise osv.except_osv(_('Warning !'), _('Global taxes defined, but they are not in invoice lines !')) @@ -1002,7 +1002,7 @@ class account_invoice(osv.osv): 'quantity': x.get('quantity',1.00), 'product_id': x.get('product_id', False), 'product_uom_id': x.get('uos_id', False), - 'analytic_account_id': x.get('account_analytic_id', False), + 'analytic_account_id': x.get('analytic_account_id', False), } def action_number(self, cr, uid, ids, context=None): @@ -1578,6 +1578,7 @@ class account_invoice_tax(osv.osv): 'invoice_id': fields.many2one('account.invoice', 'Invoice Line', ondelete='cascade', select=True), 'name': fields.char('Tax Description', size=64, required=True), 'account_id': fields.many2one('account.account', 'Tax Account', required=True, domain=[('type','<>','view'),('type','<>','income'), ('type', '<>', 'closed')]), + 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'), 'base': fields.float('Base', digits_compute=dp.get_precision('Account')), 'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')), 'manual': fields.boolean('Manual'), @@ -1648,14 +1649,16 @@ class account_invoice_tax(osv.osv): val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) val['account_id'] = tax['account_collected_id'] or line.account_id.id + val['account_analytic_id'] = tax['account_analytic_collected_id'] else: val['base_code_id'] = tax['ref_base_code_id'] val['tax_code_id'] = tax['ref_tax_code_id'] val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['ref_base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) val['account_id'] = tax['account_paid_id'] or line.account_id.id + val['account_analytic_id'] = tax['account_analytic_paid_id'] - key = (val['tax_code_id'], val['base_code_id'], val['account_id']) + key = (val['tax_code_id'], val['base_code_id'], val['account_id'], val['account_analytic_id']) if not key in tax_grouped: tax_grouped[key] = val else: @@ -1687,7 +1690,8 @@ class account_invoice_tax(osv.osv): 'price': t['amount'] or 0.0, 'account_id': t['account_id'], 'tax_code_id': t['tax_code_id'], - 'tax_amount': t['tax_amount'] + 'tax_amount': t['tax_amount'], + 'analytic_account_id': t['account_analytic_id'], }) return res diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 7121094641c..d852c95449d 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -98,6 +98,7 @@ + @@ -215,6 +216,7 @@ + diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index a89473af134..10a523dbf6b 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -909,9 +909,9 @@ -