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

Hi,

I want to modify partner view website field. So "e.g. www.odoo.com" is replaced with "e.g. www.mycustomer.com".


I prepared the following view in my module:

<?xml version="1.0" encoding="utf-8"?>

<odoo>
    <!-- Remove www.odoo.com from website field -->

    <template id="my_module_view_partner_form" inherit_id="base.view_partner_form">
        <xpath expr="//field[@name='website']" position="replace">

            <field name="website" widget="url" placeholder="e.g. www.foo.com"/>

        </xpath>

    </template>
</odoo>

I loaded the module and I can see in debug how the view is inherited.

But browser still shows www.odoo.com.

I think it might be related to localization.

Any tip is welcomed.

아바타
취소
베스트 답변

Hi E.M.

First of all, why did you inherit an odoo view defined with the record tag with the template tag? it's not the same, in the record tag you have the freedom to set record field values like model and others that cannot be set while using the template tag. The template tag is a wrapper around a very basic ir.ui.view qweb record without been tied to any model, so when odoo view inheritance search for the view inherits of the same model will not find your template as an inheriting view

You could get it working like:

<record id="placeholder_view_partner_form" model="ir.ui.view">
    <field name="name">res.partner.form</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='website']" position="replace">
            <field name="website" widget="url" placeholder="e.g. www.foo.com"/>
        </xpath>
    </field>
</record>

or a better way

<record id="placeholder_view_partner_form" model="ir.ui.view">
    <field name="name">res.partner.form</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <field name="website" position="attributes">
            <attribute name="placeholder">e.g. www.foo.com</attribute>
        </field>
    </field>
</record>
아바타
취소
관련 게시물 답글 화면 활동
0
9월 24
1542
1
6월 22
3146
3
2월 18
4267
2
8월 17
5917
1
10월 23
1721