Community: Framework mailing list archives

Re: Inheritance by delegation views and active_id

Vauxoo S.A. de C.V., Jose Antonio Morales
- 09/04/2014 00:54:45
¿What are you try to do with this new model?

My question is because I think that you try to make the wheel again, you have three main models that can help you(res.partner, res.users and hr.employee), with these models you can do so much and I think that a simple inheritance(_inherit) you can extend one of these models and you can do whatever you want and something else without extra work.

Explain to me what you try to do and I can help you. We can extend one of the main models mentioned before or we can make to work your new model with Inheritance by delegation.

Best Regards.

On Wed, Sep 3, 2014 at 3:39 PM, Steve Haufe <> wrote:
No sorry, Here is some excerpt of code to help illustrate what my problem is.

The views below are dealing with two models MY.agent and res,partner. The first view is mine, but there are several others in add-ons that do the same thing. This one add a button to list the call for the partner. Call is expecting res.partner as the model and a partner ID. This works fine if your are working with a partner.

The second view inherits view_partner_form, but it working with MY.agent. All fields and buttons will be displayed. Problem is that when a button is clicked it's supplied the MY.agent id as the active_id, not the corresponding res.partner id. In this case crm.phonecall is using the wrong ID.

I would expect that when a view is being extended to a different model, the components that where added would work with the model of the view they are added to, not the model of the final. Otherwise, any component would need to work its way up the inheritance until it found the expected model.

class MY_agent(Model):

    _name    = "MY.agent"
    _inherits = {'res.partner': 'partner_id'}

    _columns = {
        'agent_code'        : fields.char('Agent Code', size=30),

<record id='view_MY_partner_form' model='ir.ui.view'>
    <field name="name">res.partner.form.inherit</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <xpath expr="//div[@name='buttons']" position="inside">
            <button class="oe_inline oe_stat_button" type="action"
                context="{'search_default_partner_id': active_id, 'default_duration': 1.0}">
                <field string="Scheduled Calls" name="number_schedule_phone_contact" widget="statinfo"/>

<record id='view_MY_agent_form' model='ir.ui.view'>
    <field name="name">MY.agent.form.inherit</field>
    <field name="model">MY.agent</field>
    <field name="mode">primary</field>
    <field name="inherit_id" ref="base.view_partner_form"/>           
    <field name="arch" type="xml">               
        <field name="website" position="after">
        <field name="agent_code"/>


On Wed, Sep 3, 2014 at 3:53 PM, Ricardo Martins <> wrote:
When u inherit you should'nt use the on the id of your view the id of the original view, because that replaces the original view. What you should and want to do is something like:


Hope it helps...

Bom trabalho e divirta-se! 
Ricardo Martins

2014-09-03 19:52 GMT+01:00 Steve Haufe <>:
Hi All,

I've created a child module of res.partner using Inheritance by delegation. I've created a view that inherits view_partner_form.

Problem is that when I'm viewing my child form the buttons that are referring to the res.partner model are using the id of my module and not res.partner. This is causing issues for meetings and calls.

I still want the all the functionally of res.partner to be associated with that model.

Is this a bug, or is there a some method I'm missing for fixing the new form.

I'm using 8, ccf91e067cc42794355af3f4a26a5056f2baf487


Post to:

Post to:

Post to:

Jose Morales
Senior Developer
Twitter: @joseamoralesp
Skype: joseamoralesp
Linux-Counter: 564569
Phone: +58 (426) 310 69 65