Skip to content

Commit 32bef5d

Browse files
committed
[?]
1 parent 68f284e commit 32bef5d

5 files changed

Lines changed: 94 additions & 0 deletions

File tree

account_invoice_tax/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Part of Odoo. See LICENSE file for full copyright and licensing details.
22
from . import wizards
3+
from . import models
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import account_tax_repartition_line
2+
from . import account_tax
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
from odoo import models, fields, api
2+
3+
class AccountTax(models.Model):
4+
5+
_inherit = "account.tax"
6+
7+
@api.model
8+
def _get_tax_totals_summary(self, base_lines, currency, company, cash_rounding=None):
9+
res = super()._get_tax_totals_summary(base_lines, currency, company, cash_rounding=cash_rounding)
10+
if 'tax_context' in self.env.context:
11+
rate = self.env.context.get('inverse_invoice_currency_rate', 1)
12+
for tax_groups in res['subtotals'][0]['tax_groups']:
13+
for involved_tax_id in tax_groups['involved_tax_ids']:
14+
amount = self.env.context['tax_context'].get(involved_tax_id)
15+
original_amount = tax_groups.get('tax_amount', 0.0)
16+
if amount and amount != original_amount:
17+
tax_groups.update({
18+
'tax_amount': amount,
19+
'tax_amount_currency': amount
20+
})
21+
res['tax_amount'] += amount - original_amount
22+
res['total_amount'] += amount - original_amount
23+
res['tax_amount_currency'] += (amount - original_amount) * rate
24+
res['total_amount_currency'] += (amount - original_amount) * rate
25+
26+
return res
27+
28+
29+
"""
30+
{'base_amount': 25476.980000000003,
31+
'base_amount_currency': 25476.980000000003,
32+
'company_currency_id': 19,
33+
'company_currency_pd': 0.01,
34+
'currency_id': 19,
35+
'currency_pd': 0.01,
36+
'has_tax_groups': True,
37+
'same_tax_base': True,
38+
'subtotals': [{'base_amount': 25476.980000000003,
39+
'base_amount_currency': 25476.980000000003,
40+
'name': 'Untaxed Amount',
41+
'tax_amount': 5356.169999999999,
42+
'tax_amount_currency': 5356.169999999999,
43+
'tax_groups': [{'base_amount': 25476.980000000003,
44+
'base_amount_currency': 25476.980000000003,
45+
'display_base_amount': 25476.980000000003,
46+
'display_base_amount_currency': 25476.980000000003,
47+
'group_label': False,
48+
'group_name': 'VAT 21%',
49+
'id': 84,
50+
'involved_tax_ids': [140],
51+
'tax_amount': 5350.169999999999,
52+
'tax_amount_currency': 5350.169999999999},
53+
{'base_amount': 25476.980000000003,
54+
'base_amount_currency': 25476.980000000003,
55+
'display_base_amount': None,
56+
'display_base_amount_currency': None,
57+
'group_label': False,
58+
'group_name': 'Perc IIBB ARBA',
59+
'id': 98,
60+
'involved_tax_ids': [79],
61+
'tax_amount': 6.0,
62+
'tax_amount_currency': 6.0}]}],
63+
'tax_amount': 5356.169999999999,
64+
'tax_amount_currency': 5356.169999999999,
65+
'total_amount': 30833.15,
66+
'total_amount_currency': 30833.15}
67+
68+
"""
69+
class AccountMove(models.Model):
70+
71+
_inherit = "account.move"
72+
73+
def _compute_tax_totals(self):
74+
for move in self:
75+
tax_context = {'inverse_invoice_currency_rate': move.inverse_invoice_currency_rate}
76+
for line in move.line_ids.filtered(lambda x: x.fixed_amount_in_currency):
77+
tax_context[line.tax_line_id.id] = line.fixed_amount_in_currency
78+
super(AccountMove, move.with_context(tax_context=tax_context))._compute_tax_totals()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from odoo import models, fields
2+
3+
4+
class AccountMoveLine(models.Model):
5+
_inherit = "account.move.line"
6+
7+
tax_fixed_amount = fields.Float()
8+
tax_fixed_amount_in_currency = fields.Float()

account_invoice_tax/wizards/account_invoice_tax.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,15 @@ def action_update_tax(self):
7272
and x.tax_repartition_line_id.tax_id.amount_type == "fixed"
7373
):
7474
tax_line.write(fixed_taxes_bu.get(tax_line.tax_line_id))
75+
7576
for tax_line_id in self.tax_line_ids:
7677
# seteamos valor al impuesto segun lo que puso en el wizard
7778
line_with_tax = move.line_ids.filtered(lambda x: x.tax_line_id == tax_line_id.tax_id)
7879
line_with_tax.write(tax_line_id._get_amount_updated_values())
80+
if line_with_tax.tax_repartition_line_id.tax_id.amount_type == "fixed":
81+
82+
line_with_tax.tax_fixed_amount = tax_line_id.amount_company_currency if self.is_in_company_currency else tax_line_id.amount
83+
line_with_tax.tax_fixed_amount_in_currency = tax_line_id.amount
7984

8085
def add_tax_and_new(self):
8186
self.add_tax()

0 commit comments

Comments
 (0)