This question has been flagged
3 Replies
3783 Views

Has anyone been able to get the color attribute to work on the Product Tree View ?  According to the code below , a product with a virtual_available < 0 should be in 'red' - it doesn't appear to be.

The code in ../addons/stock/product_view.xml looks like this -


<record id="view_stock_product_template_tree" model="ir.ui.view">
            <field name="name">product.template.stock.tree.inherit</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_template_tree_view"/>
            <field name="arch" type="xml">
                <tree position="attributes">                                              
                     <attribute name="colors">{'red':virtual_available&lt;=0, 'blue':virtual_available&gt;=0 and state in ('draft', 'end', 'obsolete'), 'black':virtual_available&gt;=0 and state not in ('draft', 'end', 'obsolete')}</attribute>-->
                </tree> 
                <field name="uom_id" position="after">
                    <field name="qty_available"/>
                    <field name="virtual_available"/>
                </field>
            </field>
        </record>

 

Avatar
Discard
Author

Problem Solved - see zbik answer

Best Answer

It may have something to do with the fact that qty_available and virtual_available are function fields that are not stored (with a good reason) and does not have fnct_search implemented (due to complexity).  Try using other fields and see if it works.

Avatar
Discard
Best Answer

Update your system. See one of the latest commits: https://github.com/odoo/odoo/commit/e28e01a70f397f9ded4bac1ff060b93bf6072e40

Avatar
Discard
Author Best Answer

Thanks Ivan, but that code is the standard Odoo code - not mine. However, if I modify the code as below, it does work, which means that it's possibaly not because virtual_available is a function ? I think it has to do with the { }

<record id="view_stock_product_template_tree" model="ir.ui.view">
            <field name="name">product.template.stock.tree.inherit</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_template_tree_view"/>
            <field name="arch" type="xml">
                <tree position="attributes">
                    <attribute name="colors">red:virtual_available&lt;=0</attribute>
            <!--         <attribute name="colors">{'red':virtual_available&lt;=0, 'blue':virtual_available&gt;=0 and state in ('draft', 'end', 'obsolete'), 'black':virtual_available&gt;=0 and state not in ('draft', 'end', 'obsolete')}</attribute>-->
                </tree> 
                <field name="uom_id" position="after">
                    <field name="qty_available"/>
                    <field name="virtual_available"/>
                </field>
                
                <field name="state" position="replace"/>
            </field>
        </record>

Avatar
Discard

@Roland. Sorry, I am not aware that it is actually Odoo's code. You might want to check what @zbik has mentiond to upgrade your code to the latest commit. The fix seems to echo what you have done, removing the { } and single quotes.

Thanks - zbik's link fixed it - it was a bug in the standard code


Regards
Roland Lautenbach

082 658 1000
<img src="cid:image001.gif@01CFC5CB.632A8E40">







On 16 January 2015 at 14:50, Ivan <niecw@mail.odoo.com> wrote:

@Roland. Sorry, I am not aware that it is actually Odoo's code. You might want to check what @zbik has mentiond to upgrade your code to the latest commit. The fix seems to echo what you have done, removing the { } and single quotes.

--
Ivan
Sent by Odoo Inc. using Odoo about Forum Post tree colors not working on Product Tree view V8 (73283)