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?
You can either use
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!'), ]
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
|Asked: 10/4/13, 10:10 PM|
|Seen: 1126 times|
|Last updated: 3/16/15, 8:10 AM|