I have defined my 2 new fields first_name and last_name for a person-partner. Also when I say that the partner is a company then only name field is mandatory and other two are not.The problem comes when I set all 3 fields to mandatory by setting required=True which is not possible.So the solution is I need to check these at the create and write. How to go about it?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客戶關係
- e-Commerce
- 會計
- 庫存
- PoS
- Project
- MRP
此問題已被標幟
1
回覆
8937
瀏覽次數
Hi,
you must define the method create in your custom module and make tests in this function.
def create(self, cr, uid, vals, context=None):
if context is None:
context={}
if not vals.get('is_company') :
if not vals.get('first_name') :
raise osv.except_osv(('Error first_name'),
(' first_name required ') )
if not vals.get('last_name') :
raise osv.except_osv(('Error last_name'),
(' last_name required ') )
return super(res_partner,self).create(cr, uid, vals, context=context)
and same in methods write and copy.
Thanks.
相關帖文 | 回覆 | 瀏覽次數 | 活動 | |
---|---|---|---|---|
|
2
3月 16
|
3469 | ||
|
0
9月 24
|
1145 | ||
|
2
2月 21
|
7531 | ||
|
0
2月 20
|
3004 | ||
|
2
2月 20
|
4040 |