콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
37639 화면

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>

아바타
취소

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

The label tag that is.

작성자

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

베스트 답변

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.

아바타
취소
작성자

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>

베스트 답변

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

아바타
취소
작성자

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.

작성자

Overriding the field in Python code works. :)