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.
How to override a method without calling the previously inherited one but directly the framework method?
An exemple is that the model product.product has an unlink method which delete the related product template if no more variants exists.
def unlink(self, cr, uid, ids, context=None):
unlink_ids = 
unlink_product_tmpl_ids = 
for product in self.browse(cr, uid, ids, context=context):
tmpl_id = product.product_tmpl_id.id
# Check if the product is last product of this template
other_product_ids = self.search(cr, uid, [('product_tmpl_id', '=', tmpl_id), ('id', '!=', product.id)], context=context)
if not other_product_ids:
res = super(product_product, self).unlink(cr, uid, unlink_ids, context=context)
# delete templates after calling super, as deleting template could lead to deleting
# products due to ondelete='cascade'
self.pool.get('product.template').unlink(cr, uid, unlink_product_tmpl_ids, context=context)
I would like to override this unlink method to delete the template only if it is a real template (defining attributes) and not a simple single variant template. I have for this created the field is_template. The override method would be modified with:
if not other_product_ids and not product.product_tmpl_id.is_template:
and be placed in a new module.
But this fails as the previously defined method is called (with the super()) and will unlink the template even if it is a "real template". Would you have some suggestion on how to bypass the previously inherited method?
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: 2/19/15, 4:55 AM|
|Seen: 1867 times|
|Last updated: 3/16/15, 8:10 AM|