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

Hi everyone, 

I dealing with a curly one in Odoo Online. In an Odoo base view "eCommerce: Multi-Menus" I have added an Inherited view to filter our certain Website categories and what is needed as below:

  1. Only show where the category has names like "Toner" or "Ink" or Printers & Scanners", etc.
  2. And also don't show any category if there is no "chiled_id" or "product_tmpl_ids" so empty categories where they are not a parent category will be also hidden

Here is my current code: 

<xpath expr="//t[@t-set='categories']" position="replace">
    <t t-set="categories" t-value="request.env['product.public.category'].search(
        [
            '&',
                '|',
                    ('child_id', '!=', False),
                    ('product_tmpl_ids', '!=', False),
                '|', '|', '|',
                    ('name', '=', 'Ink Cartridge'),
                    ('name', '=', 'Toner Laser Cartridge'),
                    ('name', '=', 'Printers By Brand'),
                    ('name', '=', 'Printers & Scanners')
        ]
    )[:20]"/>
</xpath>


But I am getting this error: 

Validation Error

Error while parsing or validating view: xmlParseEntityRef: no name, line 4, column 15 (<string>, line 4)


I understand that all '&' need to be changed to '&amp;' instead, and I do this I am able to save the view. But then it doesn't do what was intended (it show only categories that we want but yet not hiding the empty categories). 


Any thoughts is highly appreciated.


Re,

Victor

Imagine profil
Abandonează
Cel mai bun răspuns

Hii,

<xpath expr="//t[@t-set='categories']" position="replace">

    <t t-set="categories" t-value="request.env['product.public.category'].search([

        '&amp;',

            '|',

                ('child_id', '!=', False),

                ('product_tmpl_ids', '!=', False),

            '|', '|', '|',

                ('name', '=', 'Ink Cartridge'),

                ('name', '=', 'Toner Laser Cartridge'),

                ('name', '=', 'Printers By Brand'),

                ('name', '=', 'Printers & Scanners')

    ])[:20]"/>

</xpath>


i hope this code solve your error 


Imagine profil
Abandonează
Cel mai bun răspuns
Hi try this 
<xpath expr="//t[@t-set='categories']" position="replace">
    <t t-set="categories" t-value="request.env['product.public.category'].search([
        '&amp;',
            '|',
                ('child_id', '!=', False),
                ('product_tmpl_ids', '!=', False),
            '|',
                ('name', '=', 'Ink Cartridge'),
                ('name', '=', 'Toner Laser Cartridge'),
            '|',
                ('name', '=', 'Printers By Brand'),
                ('name', '=', 'Printers & Scanners'),
    ])[:20]"/>
</xpath>

The outer &amp; ensures:

  • Either children or products must exist, AND
  • The name must be one of the four.


The inner | blocks combine the names properly.



Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
iul. 23
1528
0
oct. 20
2924
2
iun. 22
2579
1
mar. 22
7671
0
feb. 23
2103