Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
9024 Weergaven

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?

Avatar
Annuleer
Beste antwoord

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.

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
mrt. 16
3531
0
sep. 24
1214
2
feb. 21
7646
0
feb. 20
3089
2
feb. 20
4130