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

Odoo16
I'm trying to set a domain for warehouse_ids  field that exist in sale.order.line model
the domain depends on the selected values of allowed_locations field that is exist in res.users model

this is the code but it doesn't work

@api.depends('self.env.user.allowed_locations')
def domain(self):
user = self.env.user
locations_domain = []
for loc_id in user.allowed_locations:
locations_domain.append(loc_id.id)
print (loc_id.id)
return {'domain': {'warehouse_ids': [('id', 'in', locations_domain)]}}
warehouse_ids = fields.Many2one('stock.location',string="Warehouse ")


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
def _get_warehouse_domain(self):
​return [('id', 'in', self.env.user.allowed_locations.ids)]
warehouse_ids = fields.Many2one('stock.location', string="Warehouse", domain=_get_warehouse_domain)
อวตาร
ละทิ้ง
ผู้เขียน

Thanks very much
it works correctely after i added your code

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

Domain based on some another field

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Duplicate section on Sales order แก้ไขแล้ว
2
มี.ค. 25
2991
1
ก.ย. 23
3099
Multiple Address in sale orde แก้ไขแล้ว
2
มี.ค. 24
2804
2
พ.ค. 23
197
1
ม.ค. 18
8540