Skip to content

Commit

Permalink
[FIX] sale_stock: invoice policy on delivered quantities
Browse files Browse the repository at this point in the history
The created accounting entries have their debit/credit columns switched
because
  - they use the sign of the value to post to decide if it should be
    credit or debit
  - an out move always have a negative sign

As this code is always called on out moves, we can safely reverse the
sign when getting the price_unit of the move.

Fixes #20080
  • Loading branch information
sle-odoo committed Oct 18, 2017
1 parent faff276 commit f1d485d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/sale_stock/models/account_invoice.py
Expand Up @@ -51,7 +51,7 @@ def _compute_average_price(self, qty_done, quantity, moves):
qty_to_consider = invoiced_qty - qty_done qty_to_consider = invoiced_qty - qty_done
qty_to_consider = min(qty_to_consider, quantity - qty_delivered) qty_to_consider = min(qty_to_consider, quantity - qty_delivered)
qty_delivered += qty_to_consider qty_delivered += qty_to_consider
average_price_unit = (average_price_unit * (qty_delivered - qty_to_consider) + move.price_unit * qty_to_consider) / qty_delivered average_price_unit = (average_price_unit * (qty_delivered - qty_to_consider) + (-1 * move.price_unit) * qty_to_consider) / qty_delivered
if qty_delivered == quantity: if qty_delivered == quantity:
break break
return average_price_unit return average_price_unit

0 comments on commit f1d485d

Please sign in to comment.