This question has been flagged
1 Reply
5258 Views

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.

Avatar
Discard
Best Answer

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>
Avatar
Discard