Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
37557 Visualizzazioni

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>

Avatar
Abbandona

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

The label tag that is.

Autore

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".

Risposta migliore

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.

Avatar
Abbandona
Autore

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>

Risposta migliore

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.")

Avatar
Abbandona
Autore

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.

Autore

Overriding the field in Python code works. :)