Skip to content
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

fix method compute amound line all #1485

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions pos_orderline_absolute_discount/models/pos_order_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,30 @@ class PosOrderLine(models.Model):
"price_unit", "tax_ids", "qty", "discount", "product_id", "absolute_discount"
)
def _compute_amount_line_all(self):
super(PosOrderLine, self)._compute_amount_line_all()
for line in self:
fpos = line.order_id.fiscal_position_id
tax_ids_after_fiscal_position = (
fpos.map_tax(line.tax_ids, line.product_id, line.order_id.partner_id)
if fpos
else line.tax_ids
self.ensure_one()
res = super(PosOrderLine, self)._compute_amount_line_all()
fpos = self.order_id.fiscal_position_id
tax_ids_after_fiscal_position = (
fpos.map_tax(self.tax_ids, self.product_id, self.order_id.partner_id)
if fpos
else self.tax_ids
)
if self.absolute_discount:
price = self.price_unit - self.absolute_discount
taxes = tax_ids_after_fiscal_position.compute_all(
price,
self.order_id.pricelist_id.currency_id,
self.qty,
product=self.product_id,
partner=self.order_id.partner_id,
)
if line.absolute_discount:
price = line.price_unit - line.absolute_discount
taxes = tax_ids_after_fiscal_position.compute_all(
price,
line.order_id.pricelist_id.currency_id,
line.qty,
product=line.product_id,
partner=line.order_id.partner_id,
)
line.update(
{
"price_subtotal_incl": taxes["total_included"],
"price_subtotal": taxes["total_excluded"],
}
)
res.update(
{
"price_subtotal_incl": taxes["total_included"],
"price_subtotal": taxes["total_excluded"],
}
)
return res

@api.onchange("qty", "discount", "price_unit", "tax_ids", "absolute_discount")
def _onchange_qty(self):
Expand Down