Hi friendz,
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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi friendz,
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
Hello,
You can do this by def create() like:
class test(osv.osv):
_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.
Exactly what i would have answering. Maybe you must overwritten the write too.
def write() is used to update the record. And in question it's to restrict number of records to create., So no needed to overwrite write().
When you add a contact to an already existing Customer, it don't pass by Customer write ?
@Xsias I have fetched all the records of 'test' object. We need to pass domain according to our requirement.
Exact, my bad.
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
Registrarse