Odoo Help

2

0
4 Answers
4
Allison United States
3/8/13, 12:18 PM

It looks like I have to add a related field to the lead object in order to access the stage name in this capacity.

'related_stage_name': fields.related('stage_id','name',type="char",string="stage")

and use it in the domain of the required attribute

 <field name="field_name" attrs="{'required':[('related_stage_name','=','New')]}"/>

I would still like to know if this is possible with CSS classes or colors?

2 Comments
Daniel Reis Portugal
3/8/13, 5:17 PM

This is a good answer, but I woulld like to add: Try #1 would work if you were using state instead of stage_id. Try #2 should work with a 1 instead of '1', and if 1 is the database id for the Stage "New", Try #3, I wish it could work - you can't use dot notation in these domain filters, so the solution is to create a related field.

Allison United States
3/11/13, 10:53 AM

Thanks for the followup explanation!

0
kazunobu ndong Japan
11/29/17, 11:55 PM

Hello Allison,

I am having the same problem in Odoo 10. in the OCA'S project timeline module I am trying  to change the gantt chart color according to a specific stage. I don't fully understand your solution: are you adding this code portion in the xml file? <'related_stage_name': fields.related('stage_id','name',type="char",string="stage")>

for example in my case i have the following xml, where "stage_id==4" leads to no result:

<?xml version="1.0" encoding="utf-8"?>

<odoo>


    <record id="project_task_timeline" model="ir.ui.view">

        <field name="model">project.task</field>

        <field name="type">timeline</field>

        <field name="arch" type="xml">

            <timeline date_start="date_start"

                      date_stop="date_end"

                      default_group_by="project_id"

                      event_open_popup="true"

                      colors="#ec7063: user_id == false; #2ecb71: stage_id == 4;">

            </timeline>

        </field>

    </record>


    <record id="project.action_view_task" model="ir.actions.act_window">

        <field name="view_mode">kanban,tree,form,calendar,timeline,pivot,graph</field>

    </record>


    <record id="project.act_project_project_2_project_task_all" model="ir.actions.act_window">

        <field name="view_mode">kanban,tree,form,calendar,timeline,pivot,graph</field>

    </record>


    <record id="view_task_form2" model="ir.ui.view">

        <field name="name">project.task.form</field>

        <field name="model">project.task</field>

        <field name="inherit_id" ref="project.view_task_form2"/>

        <field name="arch" type="xml">

            <xpath expr="//field[@name='date_assign']" position="before">

                <field name="date_start"/>

                <field name="date_end"/>

            </xpath>

        </field>

    </record>


</odoo>

thanks


Kazu

Ask a Question
Writer
Keep Informed
0 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now