1 つのオブジェクトまたはテーブルに対して作成されるレコードの数を制限する方法はありますか
私の要件では、会社の連絡先を 3 つだけ作成する必要があります。そうする方法はありますか?
Thanks & Regards,
Atchuthan
1 つのオブジェクトまたはテーブルに対して作成されるレコードの数を制限する方法はありますか
私の要件では、会社の連絡先を 3 つだけ作成する必要があります。そうする方法はありますか?
Thanks & Regards,
Atchuthan
次のいずれかの方法を使用して、作成されるレコードの数を制限できます。
1. Restrict from postgresql-- I dont know how to implement this
2. Restrict from python side.: Override your create method of your model and add check condition, if the limit is reached, then raise a warning.
たとえば、最大 5 人のユーザーのみを作成する場合は、res.users
モデルを継承します。
class users(osv.osv):
_inherit="res.users"
def create(cr, uid, default, context=None):
res = super(user, self).create(cr, uid, default, context)
if len(self.search(cr, uid, [])) > 5:
raise osv_except('Error','User Limt exceeded')
return res
デフォルトでは制限は 80 ですが、このファイル内でこれを変更できます。
web/addons/web/static/src/js/view_list.js
その方法に関する完全なドキュメントは、次の Web サイトにあります。
http://help.openerp.com/question/6627/how-set-limit-for-number-records-of-x2many/