Community: Framework mailing list archives

expert-framework@mail.odoo.com

Re: Inheritance by delegation views and active_id

by
Steven Haufe
- 09/04/2014 08:51:22
I'm extending res.partner to agent because I don't want all the agent fields on every partner, (There is more than the one in my example) but I do want all the partner fields and functionality on every agent. My problem with simple inheritance (_inherit) is that it's not really inheriting, it's modifying the existing models and views.

I had done simple inheritance with this model before, it does work, but it's messy because I will have a small number of agents compared to the number of customers. As well the customer views will have access to the agent fields.

Thanks
Steve


On Thu, Sep 4, 2014 at 1:10 AM, Jose Antonio Morales <jose@vauxoo.com> wrote:
¿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 <shaufe@qualbe.com> 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"
                name="%(crm_schedule_phonecall_partner)d"
                icon="fa-phone"
                context="{'search_default_partner_id': active_id, 'default_duration': 1.0}">
                <field string="Scheduled Calls" name="number_schedule_phone_contact" widget="statinfo"/>
            </button>
           
        </xpath>   
    </field>
</record>


<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"/>

    </field>
</record>


On Wed, Sep 3, 2014 at 3:53 PM, Ricardo Martins <ricardo.nbs.martins@opencloud.pro> 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:

id=your_id
inheir=module.original_view

Hope it helps...

Bom trabalho e divirta-se! 
Ricardo Martins


2014-09-03 19:52 GMT+01:00 Steve Haufe <shaufe@qualbe.com>:
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

Thanks
Steve

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




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

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe