Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odgovori
2838 Prikazi

Hey, so we have added a state system to an existing module in our odoo installation.

However i cant seem to make the approve button only appear if its in draft with a name set.

Here is what ive tried:

    <xpath expr="//div[@name='button_box']/.." position="before">

        <header>

            

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

              <button name="action_approve_contract" type="object" string="Approve Contract" state="draft" confirm="Please make sure you have checked all the information on this contract before approving it." domain="[('name', '!=', False)]"/>

              <button name="action_contract_send" type="object" string="Send by Email" groups="base.group_user" state="approved"/>

            </xpath>

            

            

            <field name="x_state" widget="statusbar" statusbar_visible="draft,approved,sent,cancel,expired"/>

        </header>

    </xpath>


The result of this is that both of the buttons arent showing at all, regardless of state and name field data.

Avatar
Opusti

Inheritance in model and views: https://goo.gl/4Zyc9d

Best Answer

Hi,
You can add it like this

<xpath expr="//div[@name='button_box']/.." position="before">

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

            <button name="action_approve_contract" type="object" string="Approve Contract" state="draft" confirm="Please make sure you have checked all the information on this contract before approving it." domain="[('name', '!=', False)]"/>

             <button name="action_contract_send" type="object" string="Send by Email" groups="base.group_user" state="approved"/>

        </xpath>

</xpath>


Thanks & Regards
Urvisha (Odoo Developer)
Caret IT Solutions Pvt Ltd

Avatar
Opusti
Avtor

Does the state="approved" work even in the case of custom state selection e.g. my field is x_state

you can try it in both cases

Related Posts Odgovori Prikazi Aktivnost
1
apr. 23
21822
1
jul. 15
7221
0
mar. 15
3751
2
okt. 22
4863
1
jul. 22
2135