[REF] stock_account: unit price of rereturn
`_get_price_unit` is used to get the price to value a stock move and returns `unit_price` if present (most of the times it is set by purchase_stock to copy the price unit of po line) or the standard price. Note that a return copies the original move and `price_unit` is set as copy False. Before this patch, a return of a return used the standard price (due to the copy False), which doens't bring any issue but could be confusing as explained in the following receipt scenario. On a receipt, return and rereturn. The original and rereturn move may not have the same price if the standard price has changed between the operations, which is weird since there's a unit price on a potentially linked po line. On an delivery, there won't be any effect since the valuation methods do not use the result of `_get_price_unit` but force it to the standard price (standard and avco) or run fifo. task-1875873
This commit is contained in:
@@ -32,8 +32,13 @@ class StockMove(models.Model):
|
||||
return action_data
|
||||
|
||||
def _get_price_unit(self):
|
||||
""" Returns the unit price to store on the quant """
|
||||
return not self.company_id.currency_id.is_zero(self.price_unit) and self.price_unit or self.product_id.standard_price
|
||||
""" Returns the unit price to value this stock move """
|
||||
self.ensure_one()
|
||||
price_unit = self.price_unit
|
||||
# If the move is a return, use the original move's price unit.
|
||||
if self.origin_returned_move_id:
|
||||
price_unit = self.origin_returned_move_id.price_unit
|
||||
return not self.company_id.currency_id.is_zero(price_unit) and price_unit or self.product_id.standard_price
|
||||
|
||||
@api.model
|
||||
def _get_in_base_domain(self, company_id=False):
|
||||
|
||||
Reference in New Issue
Block a user