Is there any way to restrict the number of records to be created for a single object or table
My requirement needs me to create only 3 contacts for my company. Is there any way to do so.
Thanks & Regards, Atchuthan
You can do this by def create() like:
_name = "test" def create(self, cr, uid, vals, context=None): limit = len(self.search(cr, uid, , context=context)) if(limit >= 15): raise osv.except_osv(_("Warning!"), _("Message to display")) else: return super(test, self).create(cr, uid, vals, context=context)
Here, test should be name of your object. I have given to 15 record's creation.
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: 8/5/13, 9:43 AM|
|Seen: 1313 times|
|Last updated: 3/31/15, 5:37 PM|