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

Hello everybody,

I try to get a domain (context maybe) on field when I change a value of an other field.

My case :

I have two fields :

  1. partner_id : m2o (res.partner) type
  2. type : selection(sale or purchase)

On a form view, I want when I set type=sale, the domain=[('customer','=',True)] applied to the field partner_id

My idea is to use onchange action on the field type, but I don't know how

A help please

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

Hello Yug Faa,

on_change in OpenERP has 3 possible values returned finally in a dictionary or a {} .

1: The value dictionary i.e {field1:value1,field2:value2}

2: The domain dictionary i.e {field1:domain1}

3: The warning

Syntax:

res = {'value':{},'domain':{},'warning':'Warning Message'}

According to your case add this to the return dictionary.

{'domain':{'partner_id':[('customer','=',True)]}}

Thanks

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

Hi, 

You can watch following video for this:

https://youtu.be/ezH3ql5Dmx4

Thanks

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

'warning' key permits also a dict as value: {'title': 'Caption title of window:', 'message': 'Text of the message'}

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 19
3832
Help me write this domain and context. แก้ไขแล้ว
1
พ.ย. 24
4540
1
มี.ค. 15
5262
7
มี.ค. 25
8175
3
พ.ค. 24
4531