I've defined a new field on the product.product
model using the UI in Odoo V10. The field is defined like this:
Name = x_sellable_inventory
Type = float
Readonly = true
Dependencies = qty_available,outgoing_qty
the Compute method is:
for record in self:
record['x_sellable_inventory'] = record.qty_available - record.outgoing_qty
I added this field to a view and confirmed that it's changing correctly if the on-hand inventory is adjusted for the product. So far everything is working as expected.
Now, I want to be able to access this value from a sale.order.line
, so I created a related field on the sale.order.line
to access it. It's defined like this:
Name = x_product_sellable_inventory_new
Type = float
Readonly = true
Stored = true
Related Field = product_id.x_sellable_inventory
I then added this field to the sale order view so I can see it in the list of order lines. It appears once for each order line in the tree.
Now, when I change the on-hand quantity for the product, it still updates correctly on the product view, but the value on the sale order line never changes. It never changes from that initial time it was set.
If I uncheck the Store
option, the value gets updated correctly. What is happening here? Why does it matter if the related field is Stored or not? Shouldn't it get updated whenever the value of product_id.x_sellable_inventory
changes?