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

Hello,

I have following field in sale.py

'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True, readonly=True, states={'draft': [('readonly', False)]}, ondelete='restrict'), 

Here my domain is domain=[('sale_ok', '=', True)]

Now I want to extent this domain like

<xpath expr="//field[@name='order_line']/form/group/group/field[@name='product_id']" position="attributes">
<attribute name="domain">[('sale_ok','=',True),('my_new_field','=',True)]</attribute>
</xpath>

But its not working.

I have another idea if I replace product_id with new field like

'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True),('my_new_field','=',True)], change_default=True, readonly=True, states={'draft': [('readonly', False)]}, ondelete='restrict')
Awatar
Odrzuć

I have the same issue!

did you solve this issue?

Najlepsza odpowiedź

Hello Solanki Shamji,

By default, Odoo uses AND operator if not add any operator in the domain,

Here, your domain work as AND ( & ) operator

[('sale_ok','=',True),('my_new_field','=',True)]


As per your requirement use OR (|) operators on domain in xml file :

[‘|’,('sale_ok','=',True),('my_new_field','=',True)]


And If you change in py file just write the below code :
product_id = fields.many2one(domain=[‘|’,('sale_ok','=',True),('my_new_field','=',True)])

I hope this solution is helpful for you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
sty 24
16102
3
maj 16
10112
2
paź 22
25941
11
wrz 16
25339
1
mar 15
7808