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.


Custom object has no integrity check on delete

tim diamond
on 10/4/13, 10:10 PM 1,161 views

Hi community,

I have what I think should be an easy question for someone to help me with. When deleting products, the system checks to make sure there are no other objects that reference the product. This is great functionality!

I've made a custom object, and the problem is even if that object is referenced in other places, my system lets me delete it with no warning. How can I have the same functionality like there is in the system for products, sales orders, and purchase orders? I've looked everywhere, including pouring through the source of the product.py file. But I find no code that tells the system to do this integrity check.

Could someone point me in the right direction?





| 4 5 8
Tétouan, Morocco

For more informations about IBS, please visit our website at www.ibs-na.com.

For a specific questions, collaboration or help, please send us an email to support@ibs-na.com

On 10/6/13, 3:11 PM

You can either use _constraints or _sql_constraints

You can find many _constraints usage examples in the OpenERP source base, just search for it.

Here are two:

_constraints = [
    (_check_percent, 'Percentages for Payment Term Line must be between 0 and 1, Example: 0.02 for 2%.', ['value_amount']),


 _sql_constraints = [
    ('name_company_uniq', 'unique(name, company_id)', 'The name of the period must be unique per company!'),

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: 10/4/13, 10:10 PM
Seen: 1161 times
Last updated: 3/16/15, 8:10 AM