1
votes

I am trying to add new field to product.product model.

What I've done so far is:

Add new field on the following model (From Settings > Database Structure > Models):

  1. product.product

with the following details:

  • Name: x_product_cost
  • Field Label: Product Cost
  • Field Type: Float

and leave the rest to default.

The problem is i am unable to show it on the form. This is the only code that is generated when I tried to edit Form:

  • View Name: product.product.form
  • Object: product.product
  • Inherited View: product.template.common.form

    Product Variant lst_price

I can't use product.template model, since that inherits to product.product Am i missing something here?

PS: I am trying to temporarily fixed assign-different-cost-on-product-variant bug as specified here

https://github.com/odoo/odoo/issues/1198

Can anyone help me with this?

1
It is better to do that from a new module. You wont see in the form view the inherited fields, if you do a view and inherit from there you can put the field wherever you want, dont do it from odoodccdany
@DanielCrocco What would be the best way to do it? Should i do it from the source code?Jeremy
No, just add a new module inheriting the object and adding the field.dccdany

1 Answers

-1
votes

Actually instead of modifying the model from the Odoo configuration, you should create a custom module, in which you will add the new fields and the new behaviors that you need.

To do so you will have to inherit from the models in the python files to extend them, and you will surely have to modify the views as well, so that your custom fields get displayed.

For reference on how to extend models, create a custom module and create the views, you should refer to the Odoo documentation that you can find here.

As an additional note in case you didn't know, but their is a new API that appeared in the version 8 of Odoo, if you can use it, it is much easier and much nicer.