Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3752 Vizualizări

I already got some help on an old thread here. I would need to build a filter for products on purchase order so that all products would be listed if no vendor is selected, and only vendor related products would be listed if the user has selected the vendor.

With the earlier tips I was able to write a domain filter and test it a couple of times with success. But my modifications got written over. I had some notes, but despite a couple hours of trying I don't seem to be able to build the domain filter again. Below is the code, perhaps somebody can point the error. With the code below I get the following error when adding a product to PO (no vendor selected). I assume the error is on the first condition where I try to declare that the vendor has to be selected.

Error:

ValueError: Invalid leaf (True, '=', False)

Code:

  (['|', '&', (True, '=',parent.partner_id),

                            ('seller_ids.name','=',parent.partner_id),

                            ('purchase_ok', '=', True), '|',

                            ('company_id', '=', False),

                            ('company_id', '=',parent.company_id),

                            '&', (False, '=', parent.partner_id),

                            ('purchase_ok', '=', True), '|',

                            ('company_id', '=', False),

                            ('company_id', '=', parent.company_id)])

 


My Odoo version is 15.



Imagine profil
Abandonează
Cel mai bun răspuns

The first part "(True, '=',parent.partner_id)" looks pretty suspicious to me. Are you sure that you didn't invert the first and last parameter? The first one should in theory be a variable/field

Imagine profil
Abandonează
Autor

Thank you for your help! Yes, that part seems suspicious, and I probably had the first and last parameter inverted while this worked. I tried to invert it and write "(parent.partner_id, '=', True)". However, I still get "ValueError: Invalid leaf (744, '=', True)", and this originates from that line of code.

Below is the current version. I remember fixing some parenthesis etc minor things before I got it to work, seems just ridiculous I can't do it again.

<field name="product_id" position="attributes">
<attribute name="domain">(['|', '&amp;', (parent.partner_id, '=', True),
('seller_ids.name','=',parent.partner_id),
('purchase_ok', '=', True), '|',
('company_id', '=', False),
('company_id', '=',parent.company_id),
'&amp;', (parent.partner_id, '=', False),
('purchase_ok', '=', True), '|',
('company_id', '=', False),
('company_id', '=', parent.company_id)])
</attribute>
</field>

Related Posts Răspunsuri Vizualizări Activitate
0
mai 22
2416
2
dec. 20
6044
0
iul. 24
2296
3
mai 24
6803
1
mai 24
7132