Skip to content

Commit

Permalink
[FIX] purchase_stock: AVCO computation - support line discount
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaudoux authored and lmignon committed Feb 21, 2024
1 parent 8a7a95d commit 43d1550
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions addons/purchase_stock/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ def _get_price_unit(self):
for invoice_line in line.sudo().invoice_lines:
if invoice_line.move_id.state != 'posted':
continue
if invoice_line.tax_ids:
invoiced_value += invoice_line.tax_ids.with_context(round=False).compute_all(
invoice_line.price_unit, currency=invoice_line.currency_id, quantity=invoice_line.quantity)['total_void']
else:
invoiced_value += invoice_line.price_unit * invoice_line.quantity
# FIX je@bcim.be - Use discounted untaxed sub-total in price unit used for avco computation
# Current odoo computation is missing the line discount
invoiced_value += invoice_line.price_subtotal
#if invoice_line.tax_ids:
# invoiced_value += invoice_line.tax_ids.with_context(round=False).compute_all(
# invoice_line.price_unit, currency=invoice_line.currency_id, quantity=invoice_line.quantity)['total_void']
#else:
# invoiced_value += invoice_line.price_unit * invoice_line.quantity
invoiced_qty += invoice_line.product_uom_id._compute_quantity(invoice_line.quantity, line.product_id.uom_id)
# TODO currency check
remaining_value = invoiced_value - receipt_value
Expand Down

0 comments on commit 43d1550

Please sign in to comment.