1

因此,当purchase_state处于[purchase]时,我想将Purchase Status(Inside Purchase Request)中的“Purchase Order”字符串更改为“PO Created”之类的字符串,但我不知道该怎么做。我也想创建新的模块。

这是我到目前为止所尝试的。我创建了一个 XML 并继承了视图。

<?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>
4

1 回答 1

0

我更喜欢使用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>

我希望这个答案对你有帮助。

于 2022-01-26T04:11:15.823 回答