Skip to Content
Menu
This question has been flagged
1 Reply
2331 Views

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.



Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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 Replies Views Activity
0
May 22
1609
2
Dec 20
3930
0
Jul 24
279
3
May 24
4125
1
May 24
4224