[FIX] account: balance with line quantity > 1 and fiscal position
Currently the onchange is setting the price_unit to the price_subtotal to work out the proper price unit related to the tax, but does not have a different line quantity in mind. The update of the price_unit was raising a balance difference UserError which is now resolved by the fact that we only update the price_unit if it is affected OPW-2362066 closes odoo/odoo#60256 X-original-commit: 8c8d803992c31ba68a12801fa6dd4dcf909d9ed9 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
committed by
Laurent Smet
parent
60134be18d
commit
2a7f5e25f1
@@ -3332,11 +3332,17 @@ class AccountMoveLine(models.Model):
|
||||
# E.g. mapping a 10% price-included tax to a 20% price-included tax for a price_unit of 110 should preserve
|
||||
# 100 as balance but set 120 as price_unit.
|
||||
if line.tax_ids and line.move_id.fiscal_position_id:
|
||||
line.price_unit = line._get_price_total_and_subtotal()['price_subtotal']
|
||||
line.tax_ids = line.move_id.fiscal_position_id.map_tax(line.tax_ids._origin, partner=line.move_id.partner_id)
|
||||
accounting_vals = line._get_fields_onchange_subtotal(price_subtotal=line.price_unit, currency=line.move_id.company_currency_id)
|
||||
price_subtotal = line._get_price_total_and_subtotal()['price_subtotal']
|
||||
line.tax_ids = line.move_id.fiscal_position_id.map_tax(
|
||||
line.tax_ids._origin,
|
||||
partner=line.move_id.partner_id)
|
||||
accounting_vals = line._get_fields_onchange_subtotal(
|
||||
price_subtotal=price_subtotal,
|
||||
currency=line.move_id.company_currency_id)
|
||||
amount_currency = accounting_vals['amount_currency']
|
||||
line.price_unit = line._get_fields_onchange_balance(amount_currency=amount_currency).get('price_unit', line.price_unit)
|
||||
business_vals = line._get_fields_onchange_balance(amount_currency=amount_currency)
|
||||
if 'price_unit' in business_vals:
|
||||
line.price_unit = business_vals['price_unit']
|
||||
|
||||
# Convert the unit price to the invoice's currency.
|
||||
company = line.move_id.company_id
|
||||
|
||||
Reference in New Issue
Block a user