Odoo Help


Place two models on one view

on 4/18/13, 6:07 PM 6,729 views

Hello all. I need to do some interesting feature, and I hope you help me. I have some models with dates, for example project, task, resource.leaves, my custom models, etc. And my customer wants to see all this records on one gantt-view. For example, if I need to place task, I need to see resource.leaves to prevent placing task in busy employee's time. Openerp documentation says it is impossible. But this is nesessary feature, and in spite of documentation I will trying to realize this. May be somebody already released this, or have been trying to release - I will glad to see your experience.



| 2 1 4
Buenos Aires, Argentina

Python developer, big fan of sailing

On 4/18/13, 7:29 PM

What you can do is a third model that is populated by a SQL View that joins the two models. That's the best way to relate models in a view

On 4/25/13, 4:18 PM

Thank you, I forgot about this possibility. I have tried to do this, and it is working. If you are interesting, this is example of code (it is data from crm module. Report contains phonecalls, meeting and lead events on one calendar view):


from osv import fields,osv
import tools

class crm_summary(osv.osv):
<tab indent must be started here>
_name = "crm.summary"
_auto = False

_columns = {
    'type': fields.char('Type', size=128, readonly=True),
    'name': fields.char('Name', size=512, readonly=True),
    'date': fields.datetime('Date', readonly=True),

_order = "date DESC"

def init(self, cr):
    tools.sql.drop_view_if_exists(cr, 'crm_summary')
        CREATE view crm_summary as
          (SELECT l.id || 'l' as id,
          'lead' as type,
          l.title_action as name,
          l.date_action as date
          FROM crm_lead l
          GROUP BY l.id, type, l.title_action, l.date_action
          (SELECT c.id || 'c' as id, 
          'call' as type,
          c.name as name,
          c.date as date
          FROM crm_phonecall c
          GROUP BY c.id, type, c.name, c.date
          SELECT m.id || 'm' as id, 
          'meeting' as type,
          m.name as name,
          m.date as date
          FROM crm_meeting m
          GROUP BY m.id, type, m.name, m.date

<tab indent must be ended here>


<record id="crm_summary_calendar" model="ir.ui.view">
        <field name="name">Crm summary calendar</field>
        <field name="model">crm.summary</field>
        <field name="type">calendar</field>
        <field name="arch" type="xml">
            <calendar string="Crm summary" color="type" date_start="date">
                <field name="name"/>

This doesn't work: the ids seems to overlap, and the tree view show only the last model added by union directive.

on 7/31/15, 4:12 AM

IT Libertas

--IT Libertas--
| 4 3 7
Saint Petersburg, Russian Federation
--IT Libertas--

Visit us: itlibertas.com

IT Libertas is a team of developers and automation experts to help you to unlock Odoo ERP system's potential. We have been communicating with end users to whom the software became a main business tool since 2012. As a result, we are proud of dozens of successful implementations.

IT Libertas guarantees deadlines predictability and transparent pricing. We rely upon the best international practices and invest in local markets' study. That is why the company's services are in demand of European, Asian, American and African entrepreneurs.

We are open for cooperation and keep searching for new solutions to the end that IT Libertas clients go ahead of the curve, deal with less routine and generate more profit.

IT Libertas
On 7/3/16, 8:49 AM

Have a look at the app https://apps.odoo.com/apps/modules/9.0/joint_calendar/

On 7/31/15, 4:45 AM

Building on @duh386 answer.

Ids would overlap, here's my solution:

"""CREATE VIEW my_summary AS
SELECT *, row_number() OVER (ORDER BY name ASC) AS id
              foo.name AS name,
bar.name AS name, 
This creates an unique id for each row in the view.

Bonnet Denis

--Bonnet Denis--
| 5 6 8
St avé, France
--Bonnet Denis--

CEO/ODOO expert at Talyes.in

Bonnet Denis
On 5/13/13, 8:02 AM

You can use Super_calendar module. you can see it here. https://launchpad.net/server-env-tools

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/18/13, 6:07 PM
Seen: 6729 times
Last updated: 7/3/16, 8:49 AM