Odoo Help


Custom object has no integrity check on delete

tim diamond
on 10/4/13, 10:10 PM 1,629 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?




odoo.ma by IBS Group

--odoo.ma by IBS Group--
| 4 6 8
Tétouan, Morocco
--odoo.ma by IBS Group--

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

odoo.ma by IBS Group
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!'),

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/4/13, 10:10 PM
Seen: 1629 times
Last updated: 3/16/15, 8:10 AM