Odoo Help


This community 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.


How to run python function when editing a product

on 6/21/16, 6:57 AM 191 views


I'm trying to run a python function when I click on "Save" in a product page but I don't know what is the function I have to inherit from product.product or product.template.

Please, help me ! Thank you in advance.


Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 6/21/16, 7:33 AM

def create() if it is a new record

def write() if it is an existing record.

You can find nice informations in the documentation of odoo about the ORM : https://www.odoo.com/documentation/8.0/reference/orm.html

product.product if you are in a product variant view

product.template if you are on a product view.

You can find easily in the url the active_model.

Dilip Dabhi
On 6/21/16, 9:12 AM

When you click on "Save" button below two method you have to inherit...

def create(self, cr, uid, ids, context=None):



res = super(sale_order, self).create(cr, uid, ids, context=None)



return res


def write(self, cr, uid, ids,vals, context=None):



res = super(sale_order, self).create(cr, uid, ids, vals,context=None)



return res

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 6/21/16, 6:57 AM
Seen: 191 times
Last updated: 6/21/16, 9:12 AM