Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
37505 Vizualizări

I inherited a view and added some new (existing) fields to a list, but I would like to change the default labels for these fields because they are too long.  I tried adding _<label for="product_name" string="Product Name"/>_ in my XML file, but this causes the server to throw an Invalid XML Architecture error. Is it a problem with the syntax of the _<label>_ tag, or do I have to use the _<xpath>_ element?

          <field name="arch" type="xml">
                        <field name="name" position="after">
                            <field name="product_name" string="Product Name"/>
                            <!--<label for="product_name" string="Product Name"/>-->
                            <field name="product_code"/>
                        </field>
           </field>

Imagine profil
Abandonează

Could you post the whole code block? What are you trying to accomplish with the

The label tag that is.

Autor

I posted the "arch" bit. The default label for "product_name" is "Supplier Product Name". I was trying to shorten that with the label tag to either "Product Name" or simply, "Name".

Cel mai bun răspuns

You just need to change the string attribute of the field in the XML.

If product_name is the field you are trying to change, simply write this:

<field name="arch" type="xml">
        <field name="product_name" position="attributes">
                <attribute name="string">New Field Label</attribute>
        </field>
</field>

Then, start another <field></field> block for the fields you want to add.

Imagine profil
Abandonează
Autor

Thanks, Ray! Great tip! I knew it must be possible to do in the view XML!

btw what if we doing with extended views?

@Ahson Mahmood: Then you would do this:

<field name="arch" type="xml">
<xpath expr="//field[@name='product_name']" position="attributes">
<attribute name="string">New Product Name</attribute>
</xpath>
</field>

Cel mai bun răspuns

Try inheriting the class product_supplierinfo and overriding the 'product_name' column by turing this:

        'product_name': fields.char('Supplier Product Name', size=128, help="This supplier's product name will be used when printing a request for quotation. Keep empty to use the internal one.")

Into:

        'product_name': fields.char('Product Name', size=128, help="This supplier's product name will be used when printing a request for quotation. Keep empty to use the internal one.")

Imagine profil
Abandonează
Autor

Yeah, I thought about that. I just thought it might also be possible from the XML view definition. It's just a text string for display, after all! Thanks again! I'll try out your answer.

Autor

Overriding the field in Python code works. :)