[FIX] stock_account: traceback when create quant
How to reproduce: - Active multilocation in inventory setting; - Go on product form view; - Click on Update Quantity / On Hand button; - Create a new quant. With stock_account, we encounter a traceback when creating a new quant in some case where the `location_id` isn't set by default, because it tries to compute the value and it checks location to know if the quant must be valueted or not. Task #2039731
This commit is contained in:
@@ -11,7 +11,7 @@ class StockQuant(models.Model):
|
||||
value = fields.Monetary('Value', compute='_compute_value', groups='stock.group_stock_manager')
|
||||
currency_id = fields.Many2one(related='product_id.currency_id', groups='stock.group_stock_manager')
|
||||
|
||||
@api.depends('quantity')
|
||||
@api.depends('company_id', 'location_id', 'owner_id', 'product_id', 'quantity')
|
||||
def _compute_value(self):
|
||||
""" For standard and AVCO valuation, compute the current accounting
|
||||
valuation of the quants by multiplying the quantity by
|
||||
@@ -21,6 +21,11 @@ class StockQuant(models.Model):
|
||||
a estimation more than a real value).
|
||||
"""
|
||||
for quant in self:
|
||||
# If the user didn't enter a location yet while enconding a quant.
|
||||
if not quant.location_id:
|
||||
quant.value = 0
|
||||
return
|
||||
|
||||
if not quant.location_id._should_be_valued() or\
|
||||
(quant.owner_id and quant.owner_id != quant.company_id.partner_id):
|
||||
quant.value = 0
|
||||
|
||||
Reference in New Issue
Block a user