Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
6699 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
zář 24
1257
1
čvn 22
2870
3
úno 18
3976
2
srp 17
5637
1
říj 23
1464