Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] now after modifying a fixed tax through the wizard, it keeps th…
…e total amount of the tax groups even if we change the information of the invoice lines.
- Loading branch information
1 parent
2cea11b
commit 01ad82e
Showing
8 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
from . import wizards | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import account_move | ||
from . import account_tax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import models, fields, api | ||
import logging | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class AccountMove(models.Model): | ||
|
||
_inherit = "account.move" | ||
|
||
|
||
def _compute_tax_totals(self): | ||
""" Computed field used for custom widget's rendering. | ||
Only set on invoices. | ||
""" | ||
for move in self: | ||
super(AccountMove, move.with_context(tax_total_origin=move._origin.tax_totals))._compute_tax_totals() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import models, fields, api | ||
from odoo.tools.misc import formatLang | ||
|
||
import logging | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class AccountTax(models.Model): | ||
|
||
_inherit = "account.tax" | ||
|
||
|
||
@api.model | ||
def _prepare_tax_totals(self, base_lines, currency, tax_lines=None): | ||
totals = super()._prepare_tax_totals(base_lines, currency, tax_lines) | ||
##recorrer totals y si comple on la condicion y esta en self.env._context.get('tax_total_origin') | ||
tax_total_origin = self.env.context.get('tax_total_origin') | ||
if tax_total_origin: | ||
for subtotals_order in totals['subtotals_order']: | ||
for subtotals_index in range(0,len(totals['groups_by_subtotal'][subtotals_order])): | ||
id_fixed = all([x.amount_type == 'fixed' and x.type_tax_use == 'purchase' for x in self.env['account.tax'].search([('tax_group_id' ,'=', totals['groups_by_subtotal'][subtotals_order][subtotals_index]['tax_group_id'])])]) | ||
exist = [x for x in tax_total_origin['groups_by_subtotal'][subtotals_order] if x['tax_group_id'] == totals['groups_by_subtotal'][subtotals_order][subtotals_index]['tax_group_id']] | ||
|
||
if id_fixed and exist: | ||
totals['groups_by_subtotal'][subtotals_order][subtotals_index] = exist[0] | ||
|
||
|
||
subtotals = [] | ||
amount_tax = 0 | ||
for subtotal_title in totals['subtotals_order']: | ||
amount_total = totals['amount_untaxed'] + amount_tax | ||
subtotals.append({ | ||
'name': subtotal_title, | ||
'amount': amount_total, | ||
'formatted_amount': formatLang(self.env, amount_total, currency_obj=currency), | ||
}) | ||
amount_tax += sum(x['tax_group_amount'] for x in totals['groups_by_subtotal'][subtotal_title]) | ||
|
||
amount_total = totals['amount_untaxed'] + amount_tax | ||
|
||
totals['amount_tax'] = amount_tax | ||
return totals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<templates> | ||
|
||
<t t-name="account.TaxGroupComponent" t-inherit="account.TaxGroupComponent" t-inherit-mode="extension" owl="1"> | ||
<xpath expr="//span[hasclass('o_tax_group_edit')]" position="replace"> | ||
<span class="o_tax_group_edit"> | ||
<span class="o_tax_group_amount_value"> | ||
<t t-out="props.taxGroup.formatted_tax_group_amount"/> | ||
</span> | ||
</span> | ||
</xpath> | ||
</t> | ||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters