Skip to Content
Menu
This question has been flagged

Hi,


I want to color a field in sale order line when the product category is for example = FOURNITURES


I did it with the product type and it worked fine but when I do the same with product category nothing happens


Here is my code :


Python :

product_categ_id = fields.Many2one(related='product_id.product_tmpl_id.categ_id', string='Catégorie')


XML :

<?xml version="1.0"?>
<odoo>
    <record id="view_order_form" model="ir.ui.view">
        <field name="name">sale.type.line</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
                <field name="product_type_id" invisible="1"/>
                <field name="product_categ_id" invisible="1"/>
            </xpath>
        </field>
    </record>
</odoo>
<field name="name" decoration-info="product_categ_id == 'FOURNITURES'" decoration-warning="product_categ_id == 'All'"



It should look like this :

https://i.imgur.com/f8kesac.png


Thanks in advance

Avatar
Discard
Best Answer

try

product_categ_name= fields.Char(related='product_id.product_tmpl_id.categ_id.name', string='Catégorie')

and 

<field name="name" decoration-info="product_categ_name == 'FOURNITURES'" decoration-warning="product_categ_name == 'All'"

Avatar
Discard
Author

OK it works now!

Thank you

Related Posts Replies Views Activity
0
Feb 21
1204
2
Jul 20
3762
2
Jan 22
2998
1
Apr 21
2972
1
Sep 20
3441