[FIX] stock_account: fix remaining qty in svl
Steps to reproduce the bug:
- Create a product category “Fifo”:
- set the costing method to Fifo
- Create a storable product “P1”:
- category: All (costing method = standard)
- Update the qty to 10 units
- Go to inventory → Product variant → “P1”
- Change the category from “All” to “Fifo”
- Go to inventory → Reporting → stock valuation
- Add “reaming_qty” field in the list view
Problem:
The empty_stock layer (the layer created to empty the product) has `remaining_qty` of -10 instead of 0 whereas we change from standard to Fifo
The write method of `product.product` is triggered, leading to Product Variant having another category than Product Template when the write method of `product.template` is triggered
opw-3138061
closes odoo/odoo#111911
X-original-commit: f6f5d4a27af5bad42c3c6c11ce681be631f43248
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
committed by
William Henrotin
parent
a5036864b1
commit
a8398234cb
@@ -203,7 +203,7 @@ class ProductProduct(models.Model):
|
||||
fifo_vals = self._run_fifo(abs(quantity), company)
|
||||
vals['remaining_qty'] = fifo_vals.get('remaining_qty')
|
||||
# In case of AVCO, fix rounding issue of standard price when needed.
|
||||
if self.cost_method == 'average':
|
||||
if self.product_tmpl_id.cost_method == 'average':
|
||||
rounding_error = currency.round(self.standard_price * self.quantity_svl - self.value_svl)
|
||||
if rounding_error:
|
||||
# If it is bigger than the (smallest number of the currency * quantity) / 2,
|
||||
@@ -215,7 +215,7 @@ class ProductProduct(models.Model):
|
||||
float_repr(rounding_error, precision_digits=currency.decimal_places),
|
||||
currency.symbol
|
||||
)
|
||||
if self.cost_method == 'fifo':
|
||||
if self.product_tmpl_id.cost_method == 'fifo':
|
||||
vals.update(fifo_vals)
|
||||
return vals
|
||||
|
||||
|
||||
Reference in New Issue
Block a user