Skip to Content
Menu
This question has been flagged
12 Replies
32534 Views

I'm trying to modify a view from the CRM module from a custom module with no luck.  Currently, from the debugging interface, I can see that my inherited views are being created alongside the views they are meant to modify and end up being straight copies of the inherited view with no modifications.

Here is the view's code:

<!-- Phonecalls Form View -->
    <record model="ir.ui.view" id="crm_case_phone_form_view">
        <field name="name">CRM - Phone Call Form</field>
        <field name="model">crm.phonecall</field>
        <field name="type">form</field>
        <field name="inherited_id" ref="crm.crm_case_phone_form_view"/>
        <field name="arch" type="xml">
            <field name="partner_phone" position="replace"/>
            <field name="user_id" position="replace"/>
            <field name="duration" position="replace"/>
            <field name="partner_mobile" position="replace"/>
            <field name="priority" position="replace"/>
        </field>
    </record>

As you can see, I'm just tryting to remove a few fields, but after restarting openerp and updating my module nothing changes at all on the view.

 

EDIT:

Here are the four files that I have in my module.

__openerp__.py

{
    "name" : "Hotel CRM Customizations",
    "version" : "0.01",
    "category" : "Generic Modules/Hotel Management",
    "description": """
    Module to to customize the CRM module to be more useful for the hotel industry
    """,
    "depends" : ["crm"],
    "data": [
        "crm_phonecall_menu.xml",
        "crm_phonecall_view.xml",
    ],
    "auto_install": False,
    "installable": True
}

__init__.py is blank

crm_phonecall_menu.xml (this modification actually works)

<?xml version="1.0"?>
<openerp>
    <data>
        <!-- PHONE CALLS (menu)  -->
        <menuitem name="Call Log" id="crm.menu_crm_case_phone"
            groups="base.group_sale_salesman"
            parent="base.menu_base_partner" sequence="4" />
    </data>
</openerp>

crm_phonecall_view.xml

<?xml version="1.0"?>
<openerp>
    <data>

    <!-- Phonecalls Form View -->
    <record model="ir.ui.view" id="crm_case_phone_form_view_inherit">
        <field name="name">CRM - Phone Call Form</field>
        <field name="model">crm.phonecall</field>
        <field name="sequence">14</field>
        <field name="inherited_id" ref="crm.crm_case_phone_form_view"/>
        <field name="arch" type="xml">
            <field name="partner_phone" position="attributes">
                <attribute name="invisible">True</attribute>
            </field>
            <field name="user_id" position="attributes">
                <attribute name="invisible">True</attribute>
            </field>
            <field name="duration" position="replace"/>
            <field name="partner_mobile" position="replace"/>
            <field name="priority" position="replace"/>
        </field>
    </record>
    </data>
</openerp>

Avatar
Discard

Seems like some of the comment has been trimmed, so usage is .

Ah, very well spotted on the inherit! On the position tag, it is a common way to do that. This is the equivalent of . You could also use Xpath, but the OpenERP built-in is much easier!

Author

"inherited_id" was the problem. After changing it to "inherit_id" everything is working properly. Thank you so much for noticing that!

Author

First, when you inherit a view, use field name="inherit_id" instead of inherited_id. Second, remove sequence from the xml view - you do not need that for inherited view, which deals with attributes. Third, i do not understand your position="replace" usage of fields like duration partner_mobile or priority - if you use replace, the schema is like

Author

I tried to convert your, Mariusz's, comment to an answer, but it created it under my name for some reason. I've accepted your answer instead.

Best Answer

Easiest way to do that is to use attributes for that. For example, if you want to hide partner_phone just type:

<field name="partner_phone" position="attributes">

<attribute name="invisible">True</attribute>

</field>

That way the field you want to dissapear will be hidden in the form view.

Avatar
Discard
Author

I updated my original post to include all of my file contents including your suggested change. Unfortunately, it's still not working yet, though.

Best Answer

And you are 100% sure the view gets loaded? (as in: its in an installed module AND in the __openerp__.py "data" or "update_xml" list?)

If so, try to add the priority (or sequence?) field to your view. The syntax is something like <field name="sequence">15</field>. Give it a low number so it gets picked up last.

Also try to make the id of the xml record unique. I do not know if that matters, but I always tend to make it unique. Just add something like _inherit to the end of it.

[EDIT]

Try to enclose the view adjustments with the <data> tag, like so:

        <field name="arch" type="xml">

           <data>
                <field name="partner_phone" position="replace"/>
                <field name="user_id" position="replace"/>
                <field name="duration" position="replace"/>
                <field name="partner_mobile" position="replace"/>
                <field name="priority" position="replace"/>

            </data>
        </field>

Other than that I would not see why this would not work. I'm unfortunately not in the position to test it currently.

Avatar
Discard
Author

I've edited my original post to include the contents of all four files in the module. Also, I tried your suggested changes, but nothing has worked so far. The module is installed, and the view id changed in the debugging interface when I made it unique, so it is getting some of the file updates.

I've edited my original answer. If that fails then I don't know what would be wrong. Assuming you did not make any typo's in the XML names. Can you check the database to verify the view itself is actually loaded?

The view is actually loaded, but it doesn't have an inherited_id for some reason.  It's weird when I preview my view from the debugging interface my changes aren't showing up there either.  Perhaps it is using my view changes, but my view changes aren't formatted properly so their not having their intended effect.


Here is the row for the created view:
"933";"crm.phonecall";
"data";
"<?xml version="1.0"?>
<data>
                <field name="partner_phone" position="attributes">
                    <attribute name="invisible">True</attribute>
                </field>
                <field name="user_id" position="attributes">
                    <attribute name="invisible">True</attribute>
                </field>
                <field name="duration" position="replace"/>
                <field name="partner_mobile" position="replace"/>
                <field name="priority" position="replace"/>
            </data>
        ";
"";
16;1;
"2014-08-01 13:43:59.672517";
"2014-08-01 14:28:33.136775";
1;
; <-- This should be the inherited_id
"CRM - Phone Call Form"

Here is the row for the view I'm trying to inherit from:
"928";
"crm.phonecall";
"form";
"<?xml version="1.0"?>
<form string="Phone Call" version="7.0">
                <header>
                    <button name="case_close" string="Call Done" type="object" class="oe_highlight" states="open,pending"/>
                    <button name="case_reset" string="Reset to Todo" type="object" states="cancel"/>
                    <button name="case_cancel" string="Cancel Call" type="object" states="draft,open,pending"/>
                    <field name="state" widget="statusbar" nolabel="1" statusbar_visible="open,done"/>
                </header>
                <sheet string="Phone Call">
                    <div class="oe_right">
                        <button string="Convert to Opportunity" type="object" name="action_button_convert2opportunity" attrs="{'invisible':[ '|', ('opportunity_id','!=',False), ('state', 'not in', ('open', 'done'))]}"/>
                        <button string="Schedule Other Call" name="505" type="action"/>
                        <button string="Schedule a Meeting" name="action_make_meeting" type="object"/>
                    </div>
                    <div class="oe_title">
                        <div class="oe_edit_only">
                            <label for="name"/>
                        </div>
                        <h1><field name="name" required="1"/></h1>
                        <div class="oe_edit_only">
                            <label for="partner_phone" string="Phone"/>
                        </div>
                        <h2><field name="partner_phone"/></h2>
                    </div>

                    <group col="4">
                        <field name="date"/>
                        <field name="user_id"/>
                        <field name="duration" widget="float_time"/>
                        <field name="section_id" colspan="1" widget="selection"/>
                        <field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
                        <field name="email_from" invisible="1"/> <!--not needed because of the chatter, thus invisible, but must be in the view as it's returned by onchange_partner_id()-->
                        <field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'crm.phonecall')]"/>
                        <field name="partner_mobile"/>
                        <field name="priority"/>
                        <field name="opportunity_id" on_change="on_change_opportunity(opportunity_id)"/>
                    </group>
                    <field name="description" placeholder="Description..."/>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers"/>
                    <field name="message_ids" widget="mail_thread"/>
                </div>
            </form>
        ";
"";
16;
1;
"2014-07-27 16:22:20.594678";
"2014-07-27 16:22:20.594678";
1;
;
"CRM - Phone Call Form"

Thanks for your help,
Seth


On Fri, Aug 1, 2014 at 8:22 AM, Ludo - Neobis <ludo@neobis.nl> wrote:

I've edited my original answer. If that fails then I don't know what would be wrong. Assuming you did not make any typo's in the XML names. Can you check the database to verify the view itself is actually loaded?

--
Ludo - Neobis Sent by OpenERP S.A. using Odoo. Access your messages and documents in Odoo

Best Answer

You should use "replace", but leaving a blank space inside

<field name="partner_phone" position="replace">

</field>
Avatar
Discard
Related Posts Replies Views Activity
1
Mar 20
1993
1
Jul 16
5609
1
Mar 15
6242
0
Mar 15
3028
1
Mar 15
2709