Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix taxes calculation and override in a proper way
- Loading branch information
1 parent
22ccb6d
commit 374908b
Showing
4 changed files
with
61 additions
and
39 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,3 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import account_invoice | ||
from . import account_invoice_line |
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,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Tecnativa - David Vidal | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
_inherit = "account.invoice" | ||
|
||
def get_taxes_values(self): | ||
prices = {} | ||
discount = {} | ||
for line in self.invoice_line_ids: | ||
prices[line.id] = line.price_unit | ||
discount[line.id] = line.discount | ||
line.price_unit *= (1 - (line.discount or 0.0) / 100.0) | ||
line.price_unit *= (1 - (line.discount2 or 0.0) / 100.0) | ||
line.price_unit *= (1 - (line.discount3 or 0.0) / 100.0) | ||
line['discount'] = 0.0 | ||
tax_grouped = super(AccountInvoice, self).get_taxes_values() | ||
for line in self.invoice_line_ids: | ||
line['price_unit'] = prices[line.id] | ||
line['discount'] = discount[line.id] | ||
return tax_grouped |
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