[FIX] account: fixed grouping of account.invoice.tax creation.

in details:
[FIX] added analytic account in grouping key of because we need to create different journal items for each of the lines having a different analytic account.
[REF] added a function on account.tax that returns the grouping key and that could be inherited in another (community) module
This commit is contained in:
qdp-odoo
2016-07-05 10:22:35 +02:00
parent 5a5ac1d7a5
commit fb6a05d358
2 changed files with 7 additions and 1 deletions
+5
View File
@@ -602,6 +602,11 @@ class AccountTax(models.Model):
if self.price_include:
self.include_base_amount = True
def get_grouping_key(self, invoice_tax_val):
""" Returns a string that will be used to group account.invoice.tax sharing the same properties"""
self.ensure_one()
return str(invoice_tax_val['tax_id']) + '-' + str(invoice_tax_val['account_id']) + '-' + str(invoice_tax_val['account_analytic_id'])
def _compute_amount(self, base_amount, price_unit, quantity=1.0, product=None, partner=None):
""" Returns the amount of a single tax. base_amount is the actual amount on which the tax is applied, which is
price_unit * quantity eventually affected by previous taxes (if tax is include_base_amount XOR price_include)
+2 -1
View File
@@ -567,7 +567,8 @@ class AccountInvoice(models.Model):
if not val.get('account_analytic_id') and line.account_analytic_id and val['account_id'] == line.account_id.id:
val['account_analytic_id'] = line.account_analytic_id.id
key = str(tax['id']) + '-' + str(val['account_id'])
key = self.env['account.tax'].browse(tax['id']).get_grouping_key(val)
if key not in tax_grouped:
tax_grouped[key] = val
else: