Search code examples
stringodooodoo-13purchase-order

How to change string of Purchase Status(purchase_state) that is in Purchase Request? (ODOO)


So I want to change the string of "Purchase Order" inside Purchase Status(Inside Purchase Request) to something like "PO Created" when the purchase_state is in [purchase] but I don't know how I can do it. I want to create fresh module as well.

Here' s what I tried so far. I've created an XML and inherit the view.

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="purchase_request_form_inherit" model="ir.ui.view">
            <field name="name">purchase.request.inherit</field>
            <field name="model">purchase.request</field>
            <field name="inherit_id" ref="purchase_request.view_purchase_request_form"/>
            <field name="arch" type="xml">
                <field name="purchase_state" position="attributes">
                    <attribute name="attrs" string="PO Created" attrs="{'readonly': [('po_line.state','=', 'purchase')]}"/>
                </field>
            </field>
        </record>
</odoo>

Solution

  • I prefer use xpath:

    <record id="purchase_request_form_inherit" model="ir.ui.view">
        <field name="name">purchase.request.inherit</field>
        <field name="model">purchase.request</field>
        <field name="inherit_id" ref="purchase_request.view_purchase_request_form"/>
        <field name="arch" type="xml">
            <field expr="field[@name='purchase_state']" position="attributes">
                <!-- To change the String -->
                <attribute name="string">PO Created</attribute>
                <!-- To change the attrs -->
                <attribute name="attrs">{'readonly': [('po_line.state','=', 'purchase')]}</attribute>
            </field>
        </field>
    </record>
    

    I hope this answer could be helpful for you.