-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6e38a2
commit 8e464a8
Showing
8 changed files
with
149 additions
and
94 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
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 +1,3 @@ | ||
from . import account_tax | ||
from . import sale_order_line | ||
from . import sale_order |
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,73 @@ | ||
# Copyright 2023 Studio73 - Ferran Mora | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountTax(models.Model): | ||
_inherit = "account.tax" | ||
|
||
def _convert_to_tax_base_line_dict( | ||
self, | ||
base_line, | ||
partner=None, | ||
currency=None, | ||
product=None, | ||
taxes=None, | ||
price_unit=None, | ||
quantity=None, | ||
discount=None, | ||
account=None, | ||
analytic_distribution=None, | ||
price_subtotal=None, | ||
is_refund=False, | ||
rate=None, | ||
handle_price_include=True, | ||
extra_context=None, | ||
): | ||
if ( | ||
not isinstance(base_line, models.Model) | ||
or base_line._name != "sale.order.line" | ||
or not base_line.order_id.global_discount_ids | ||
or not self.env.context.get("from_tax_calculation", False) | ||
): | ||
return super()._convert_to_tax_base_line_dict( | ||
base_line, | ||
partner, | ||
currency, | ||
product, | ||
taxes, | ||
price_unit, | ||
quantity, | ||
discount, | ||
account, | ||
analytic_distribution, | ||
price_subtotal, | ||
is_refund, | ||
rate, | ||
handle_price_include, | ||
extra_context, | ||
) | ||
discounts = base_line.order_id.global_discount_ids.mapped("discount") | ||
discounted_price_unit = price_unit | ||
if base_line.product_id.apply_global_discount: | ||
discounted_price_unit = base_line.order_id.get_discounted_global( | ||
price_unit, discounts.copy() | ||
) | ||
return super()._convert_to_tax_base_line_dict( | ||
base_line, | ||
partner, | ||
currency, | ||
product, | ||
taxes, | ||
discounted_price_unit, | ||
quantity, | ||
discount, | ||
account, | ||
analytic_distribution, | ||
price_subtotal, | ||
is_refund, | ||
rate, | ||
handle_price_include, | ||
extra_context, | ||
) |
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,14 @@ | ||
# Copyright 2023 Studio73 - Ethan Hildick <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
|
||
@api.depends("product_uom_qty", "discount", "price_unit", "tax_id") | ||
def _compute_amount(self): | ||
return super( | ||
SaleOrderLine, self.with_context(from_tax_calculation=False) | ||
)._compute_amount() |
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
Oops, something went wrong.