Skip to Content
Menu
This question has been flagged
1 Reply
2103 Views

I'm pretty sure that if I want to define cost of a product at invoicing, I need to store the value in `product.price.history.cost`. But I can't establish either one2many relationship I want or many2one relationship that I tried instead: https://ibb.co/gbPBd7, and this is the error I'm getting: https://ibb.co/iw4oQn

What am I supposed to do?

Avatar
Discard
Best Answer

One2many needs a many2one relational field. Here the given field cost is float. Here you can make the relation with the product_id or company_id.

One2many makes relation with a co_model and inverse_name as one of the many2one column from co_model.

Here is the documentation for odoo fields

http://odoo-new-api-guide-line.readthedocs.io/en/latest/fields.html#related-field

https://www.odoo.com/documentation/10.0/reference/orm.html#relational-fields

Avatar
Discard
Author

How do I make a relation with product_id? What I want to do is just set the cost value while creating invoice. Please tell me what filed and how to add that field. I'm trying to approach with my prior SQL knowledge, but that won't work, it seems.

Author

I tried making a float field in account.invoice.line with related field product.price.history.cost, but it just says Unknown field name 'product' in related field 'product.price.history.cost'.

First of all, you have to learn about relational fields. Look the above documentation