This question has been flagged
2 Replies
2477 Views

Hi all:

I try to add the standard_price in the tree view in edition view

inventory -> reporting -> Inventory Report



If i add<field name="standard_price" /> I get the following error


Error while validating view: Field "standard_price" does not exist in model "stock.quant" View name: stock.quant.tree.editable Error context: view: ir.ui.view(974,) xmlid: stock.view_stock_quant_tree_editable view.model: stock.quant

So how can i add the standard_price  from product.template  ?


Any help welcome.


Avatar
Discard

If you are trying it do it from the front end then Niyas's answer is suitable, for future reference before trying to add a field in the list view you can first check whether the field is present in the model or not, to do so activate the developer mode then click on the ladybug icon and select the option of view fields and it'll display all the fields present for that model.

Best Answer

Hello sir,

You need to add  related field in stock.quant model like here I try to show you

Class StockQuant(models.Model):
_inherit = 'stock.quant'
standard_price = fields.float(related='product_id.standard_price' )

Then you should used as you above add that fields in edit list screen.

Hope it helps.


Avatar
Discard
Best Answer

Hi,

You have to add a related field in this model from the user interface, you can activate the developer mode and from the settings and add a new related field in the stock.quant model, after adding it in the model, you can add it to the view.

To add a related field from the user interface, see: How to Add Custom Field From User Interface In Odoo


Thanks

Avatar
Discard