Iam using odoo 13 enterprise
I have create custom field in both models (product.template & product.product)
when i save data from product form its only save in product.template not in product.product.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Iam using odoo 13 enterprise
I have create custom field in both models (product.template & product.product)
when i save data from product form its only save in product.template not in product.product.
Just adding your field to product template will do the job. Don't add it in product_product every product template fields are inherited by product so if you add filed to product_template it will be for every product under the same template. Take product type and product category field in template for example.
This example was very helpful. Thank you for sharing.
Without posting your code, I'm not able to help you but I can give you some information about Odoo inheritance.
Odoo provides three different mechanisms to extend models in a modular way. One of these ways is delegation inheritance which enable you to inherit all fields (Method is not inherited) from parent model to the child model and you can add other new fields to the child model.
This kind of inheritance used in product.product model which inherit all fields from product.template model.
So you can add your custom field to product.template only and add it to the product common view (product_template_form_view) which inherited by product.product model. You will be able to use the field from product.product directly.
Note: In delegation inheritance, the methods of parent model are not inherited So If you created any method in product.template to change the value of your custom field you need to add them to product.product.
Refer to Odoo documentation:
I have already put the same field in product.produt also but still product.product filed is not getting data.
class productExtend(models.Model):
_inherit = 'product.template'
itempackage = fields.Many2one('item.package', string='Item package')
class productproductExtend(models.Model):
_inherit = 'product.product'
itempackage = fields.Many2one('item.package', string='Item package')
You have to put it in 'product.template' only
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up