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:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
1
Répondre
8922
Vues
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.
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrirePublications associées | Réponses | Vues | Activité | |
---|---|---|---|---|
|
2
mars 16
|
3457 | ||
|
0
sept. 24
|
1131 | ||
|
2
févr. 21
|
7519 | ||
|
0
févr. 20
|
2987 | ||
|
2
févr. 20
|
4026 |