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.

3

<field name="mode">primary</field> can anyone explain the purpose of this ?

By
Annadurai
on 7/11/16, 1:09 AM 405 views

how it  works? and it's usages?

just saw the above link.. thanks for ur replay.

Annadurai
on 7/11/16, 8:09 AM
1

Axel Mendoza

--Axel Mendoza--
10228
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 7/11/16, 1:39 AM

That it's an interesting feature of the views inheritance that I like to call it view inheritance by prototype because it's like the model inheritance by prototype where you create a copy of a model using this syntanx:

from openerp import models

class model_class_name(models.Model)
    _name = 'model.name'
    _inherit = 'new.model.name'

    ...
    ...

Defining the view like using the mode primary is the same as the model example exposed and you will end with a new view that inherit from the inherit_id view reference. That view field is only used in conjunction with the inherit_id field. By default have the value extension that it's the most used and known use.

Let's put an example assuming that you need two views of the model res.partner with different changes in how they fields will be displayed or whatever you need, could be that you don't want to use groups or invisible in all the fields that you need to add or modify in boths of the views or their position varies

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

<field name="name">Client</field>

<field name="model">res.partner</field>

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

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

<form string="Patient">

<sheet>

<field name="image" widget='image' class="oe_left oe_avatar" options='{"preview_image": "image_medium", "size": [90, 90]}'/>

<div class="oe_left">

<label class="oe_edit_only" for="name" string="Name" colspan="4"/>

<div class="oe_inline">

<h2>

<field name="title" domain="[('domain', '=', 'contact')]" options='{"no_open": True}' placeholder="Title" nolabel="1" colspan="1"/>

<field name="name" default_focus="1" placeholder="Name" nolabel="1" colspan="5"/>

<field name="lastname" placeholder="Last Name" required="1" nolabel="1" colspan="6"/>

</h2>

</div>

<field name="category_id" widget="many2many_tags" placeholder="Tags..." colspan="6"/>

</div>

<div class="oe_right oe_button_box solt_oe_button_box" name="buttons">

<button class="oe_inline oe_stat_button" style="width: 250px !important;" type="action" name="322" icon="fa-phone" context="{'search_default_partner_id': partner_id, 'default_duration': 1.0}">

<field string="Calls" name="phonecall_count" widget="statinfo"/>

</button>

</div>

<div class="oe_clear"/>

<notebook>

<page string="Personal Information">

<group>

<field name="marital_status"/>

<field name="religion"/>

<field name="ethnic_group"/>

</group>

<label for="comments"/>

<field name="comments" placeholder="Comments"/>

</page>

</notebook>

</sheet>

<div name="message" class="oe_chatter">

<field name="message_follower_ids" widget="mail_followers" />

<field name="message_ids" widget="mail_thread" />

</div>

</form>

</field>

</record>

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

<field name="name">Client Extended</field>

<field name="model">res.partner</field>

<field name="priority">8</field>

<field name="inherit_id" ref="partner_base_view"/>

<field name="mode">primary</field>

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

<xpath expr="//form/sheet/notebook" position="inside">

<page string="Extra Info">

<field name="extra_info"/>

</page>

</xpath>

</field>

</record>


thank for ur reply Axel.. :)

Annadurai
on 7/11/16, 2:04 AM

Actually, you put model name= res.partner in both ui views. so what is the use of it? when I run it, it actually replaces partner_base_view. and only showing Partner_primary_mode_view..

Annadurai
on 7/11/16, 3:23 AM

i found it.. i forgot XPATH, same model inheritance. but tell me in which it will be useful for us.

Annadurai
on 7/11/16, 4:38 AM

it's useful to create a view based on another one for the same model without having to duplicate all the view code base or changing the original one by adding invisible conditions or groups to let the original view display without modifications, you will be creating another view, not changing the original one. It's just a feature, you need to find your own scenario to use it

Axel Mendoza
on 7/11/16, 6:45 AM

For example here is an example scenario that could be solved using this feature

https://www.odoo.com/es_ES/forum/ayuda-1/question/inherited-product-module-in-our-custom-module-104620

Axel Mendoza
on 7/11/16, 6:49 AM

just Saw.. thanks for your reply

Annadurai
on 7/11/16, 8:10 AM

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

2 follower(s)

Stats

Asked: 7/11/16, 1:09 AM
Seen: 405 times
Last updated: 7/27/16, 6:10 AM