-
-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][FIX] account_avatax_oca, skip exception raise on lines with not product in display_type #404
base: 16.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from . import models | ||
from . import wizard | ||
from .hooks import pre_init_hook | ||
from .hooks import post_load_hook |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,26 +82,39 @@ def compute_all( | |
fixed_multiplicator, | ||
) | ||
avatax_invoice = self.env.context.get("avatax_invoice") | ||
current_aml = False | ||
if "current_aml" in self.env.context: | ||
current_aml = self.env["account.move.line"].browse( | ||
self.env.context.get("current_aml") | ||
) | ||
if not ( | ||
current_aml.display_type == "product" | ||
and current_aml.account_type != "asset_receivable" | ||
): | ||
avatax_invoice = False | ||
if avatax_invoice: | ||
# Find the Avatax amount in the invoice Lines | ||
# Looks up the line for the current product, price_unit, and quantity | ||
# Note that the price_unit used must consider discount | ||
base = res["total_excluded"] | ||
digits = 6 | ||
avatax_amount = None | ||
for line in avatax_invoice.invoice_line_ids: | ||
price_unit = line.currency_id._convert( | ||
price_unit, | ||
avatax_invoice.company_id.currency_id, | ||
avatax_invoice.company_id, | ||
avatax_invoice.date, | ||
) | ||
if ( | ||
line.product_id == product | ||
and float_compare(line.quantity, quantity, digits) == 0 | ||
): | ||
avatax_amount = copysign(line.avatax_amt_line, base) | ||
break | ||
if current_aml: | ||
avatax_amount = copysign(current_aml.avatax_amt_line, base) | ||
else: | ||
for line in avatax_invoice.invoice_line_ids: | ||
price_unit = line.currency_id._convert( | ||
price_unit, | ||
avatax_invoice.company_id.currency_id, | ||
avatax_invoice.company_id, | ||
avatax_invoice.date, | ||
) | ||
if ( | ||
line.product_id == product | ||
and float_compare(line.quantity, quantity, digits) == 0 | ||
): | ||
avatax_amount = copysign(line.avatax_amt_line, base) | ||
break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of logic changes here that I don't understand , I'm not comfortable with this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is only for adding a process of current aml, if that is not found, should be done standard behavior, you can notice change in showed only for tab adding in else condition |
||
if avatax_amount is None: | ||
avatax_amount = 0.0 | ||
raise exceptions.UserError( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we are monkey patching the _compute_all_tax method.
Why would we need to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's needed because in this line https://github.com/odoo/odoo/blob/16.0/addons/account/models/account_move_line.py#L940, I'm adding a context with current aml, to know what account move line trigger tax compute, then in next process I can process with more precision