Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I want to do some actions for every new created product.
In order to do that I need the product_id of the freshly new generated product.
I know that I can extend the create method of product.template as in:
class AdditionalActionsOnProductCreation ( models.Model )
_inherit = 'product.template'
def create(self, vals):
# Creates the product using standard create metho
new_product_template = super(AdditionalActionsOnProductCreation, self).create(vals
# Try to add the product_id and assign to ean13 field (just to test/see it easily)
But product_id is not there, where should i retrieve it?
Inspite of inheriting product.template, why don't you inherit product.product.
As with the creation of every product.template a product.product record is created......so you can easily get this by overriding create method of product.product.
and one more thing , we don't have product_id in product.template, but product_templ_id(product.template) in product.product.
Hope it will help you
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 9/29/15, 6:32 AM|
|Seen: 665 times|
|Last updated: 10/1/15, 9:08 AM|