Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Inherited views

By
Andrea Dalseno
on 10/17/15, 10:31 AM 444 views

Hi I'm trying to make an inherited view of res.partner.

My model (to begin) is as simple as this:

class genial_2015(osv.osv):

"""Db test genial_2015 """

_name = 'genial.2015'

_inherit = 'res.partner'

_columns = {

'titolo': fields.char ('Titolo', size = 31)

}

So it inherits from res.partner. And it works fine (I will have more fields later).

I'm trying to inherit the "base.view_partner_form" view (so that I will have all the fields properly formatted and the view design in place) and add my custom field to it.

This is my view

<record model="ir.ui.view" id="view_genial_2015_form">

<field name="name">genial.2015.form</field>

<field name="model">genial.2015</field>

<field name="priority" eval="1"/>

<field name="type">form</field>

<field name="inherit_id" ref="base.view_partner_form"/>

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

<form string="Partners">

<xpath expr="//field[@name='website']" position="after">

<field name="titolo" />

</xpath>

</form>

</field>

</record>

The module installs and I can see the form, but it's not the well formatted and designed res.partner.from, it's a mess with all the fields confused. Why? What am I doing wrong? Or what am I missing? This is a link to my window (hope it works).

http://postimg.org/image/s6ugg0iod/

My action definition is:

<record model="ir.actions.act_window" id="action_genial_2015">

<field name="name">genial.2015</field>

<field name="type">ir.actions.act_window</field>

<field name="res_model">genial.2015</field>

<field name="view_type">form</field>

<field name="view_mode">form</field>

</record>

I tried to give the view the same name as res.partner with the same model. In such a case I can see the view properly formatted, but there is no way to show my custom field. If I try with <field genial_2015_name="titolo" /> I got an error!

I tried to give the view a lower priority, but nothing changed. Of course modifying res.partner model will solve the problem, but I'd like to understand why I can't make it work with an inherited model.

I'm running  Odoo Version 8.0-a2115ef on Ubuntu 14.04 (Bitnami stack)

Thanks.

0
Andrea Dalseno
On 10/17/15, 11:14 AM

I tired to remove the _name declaration form my model as suggested here:

https://www.odoo.com/forum/help-1/question/view-inherit-from-res-partner-appears-all-one-page-with-no-styling-or-formatting-30444

But it didn't work either.

Ok, after reading a post here, I managed to have my view properly formatted. View does not inherit the design so you have to recreate yourself (I wonder what inheritance means?) and here is the result with my field under the website field.

http://postimg.org/image/95lfipgh5/

The problem is that I installed a couple of modules that modified the res.partner view (a tab for geolocalization data and a button for a map). This is the res.partner view:

http://postimg.org/image/7hhtugqqx/

What do I have to do to have them in my view too? Copy and paste the code again? What inheritance means then? At this point I had better modify res.partner instead of create my own model, hadn't I?

Any suggestion?

Thanks.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/17/15, 10:31 AM
Seen: 444 times
Last updated: 10/17/15, 3:41 PM