Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
2583 Widoki


      [('id', 'in', parent.product_id_domain)]



how can add a condition to this domain as it has to execute only when parent.picking_type_code =='outgoing'
Awatar
Odrzuć
Najlepsza odpowiedź

Hi Sruti,

So the domain conditions are simple to understand and write. Like `[('id', 'in', parent.product_id_domain)]`​ just means if id is found in parent.product_id_domain.

To add more filtering (conditions) simply append the tuple to condition array.

Means, your final condition will be `[( 'id' ,  'in' , parent.product_id_domain ),  (parent.picking_type_code, '=' , 'outgoing')]`


Multiple conditions: 

You can do it as follows,
`

# Check the condition and apply the appropriate domain

if parent_id.picking_type_code == 'outgoing':

domain = [('id', 'in', parent.product_id_domain)]

elif parent_id.picking_type_code == 'incoming':

domain = [('id', 'in', product_id)]


# Search for records using the constructed domain

records = self.env['table.name'].search(domain)`

Awatar
Odrzuć

Hey , Can you please answer this

Can we have multiple conditions like

if parent_id.picking_type_code', '==', 'outgoing execute
('id', 'in', parent.product_id_domain)
else parent_id.picking_type_code == incoming another domain ('id', 'in', product_id)

Hey Nisarga,
Yes, it is doable.
You can do it as follows,

# Check the condition and apply the appropriate domain
if parent_id.picking_type_code == 'outgoing':
domain = [('id', 'in', parent.product_id_domain)]
elif parent_id.picking_type_code == 'incoming':
domain = [('id', 'in', product_id)]

# Search for records using the constructed domain
records = self.env['table.name'].search(domain)

Autor Najlepsza odpowiedź

Thanks Jenish M and Chandan , If you know how can we add multiple as like Nisarga commented , Please comment it

Awatar
Odrzuć

updated my answer.

Najlepsza odpowiedź

Can we have multiple conditions like

if parent_id.picking_type_code', '==', 'outgoing execute 
('id', 'in', parent.product_id_domain)
else parent_id.picking_type_code == incoming another  domain ('id', 'in', product_id)

Awatar
Odrzuć

Hey Nisarga,
Yes, it is doable.
You can do it as follows,

# Check the condition and apply the appropriate domain
if parent_id.picking_type_code == 'outgoing':
domain = [('id', 'in', parent.product_id_domain)]
elif parent_id.picking_type_code == 'incoming':
domain = [('id', 'in', product_id)]

# Search for records using the constructed domain
records = self.env['table.name'].search(domain)

if this answers your question, please upvote (PS: I am new here with no Karma points)

Najlepsza odpowiedź

You can add your conditions seperated by comma(,)

For example,

[('id', 'in', parent.product_id_domain), ('parent_id.picking_type_code', '==', 'outgoing']


Awatar
Odrzuć

Can we have multiple conditions like

if parent_id.picking_type_code', '==', 'outgoing execute
('id', 'in', parent.product_id_domain)
else parent_id.picking_type_code == incoming another domain ('id', 'in', product_id)

Powiązane posty Odpowiedzi Widoki Czynność
3
maj 24
5820
1
sty 24
1802
1
lis 23
1856
1
lis 23
6
1
paź 23
1988