Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
8 ตอบกลับ
5363 มุมมอง

I want to make that if user is set the partner is not required and if partner is set the user is not required.

I posted below the code of my form fields:

The partner_id field has attrs="{'required': [('user_id', '=', False)]}" and the user_id attrs="{'required': [('partner_id', '=', False)]}"

Can some one tell me if this can even work and how?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Your attrs syntax seems to be correct. Make sure required=True is not set in the py file in the fields definition. If it is set, make it required=False.

อวตาร
ละทิ้ง
ผู้เขียน

The python files don't have required. I'm setting required only on views.

คำตอบที่ดีที่สุด

It's impossible. Model res.user inherits from model res.partner.

class Users(models.Model):
  _inherits = {'res.partner': 'partner_id'}

อวตาร
ละทิ้ง
ผู้เขียน

they are two different fields in a wizard that works with tasks. one field is the m2o relation to res.partner the other is a m2o relation to res.users. The weird part is when I have set partner_id and not user_id it works but not the other way around.

Well. this is a different situation and it should work. How you defined these fields. It is possible that the reason is also in a completely different place.

Probably partner_id is set in module automatically after selecting the user, and user is not set when is selected the partner

ผู้เขียน

yeah... the reason is in a different place. removed the attributes from the fields and made both not required and I'm still getting the same validation error.

ผู้เขียน คำตอบที่ดีที่สุด

I fed up. Had an if statement in an related model that I used that checked that the partner_id is set and I searched for it with match case enabled so I didn't find it. Sorry Zbik and Sudhir Arya for wasting your time.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 19
4307
2
มี.ค. 18
4685
2
เม.ย. 17
13893
2
ธ.ค. 19
2585
0
พ.ย. 18
3147