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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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
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):
report.py:
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')
cr.execute("""
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
)
UNION
(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
)
UNION(
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>
crm_summary()
report.xml:
<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"/>
</calendar>
</field>
</record>
This doesn't work: the ids seems to overlap, and the tree view show only the last model added by union directive.
Have a look at the app https://apps.odoo.com/apps/modules/9.0/joint_calendar/
Building on @duh386 answer.
Ids would overlap, here's my solution:
"""CREATE VIEW my_summary ASThis creates an unique id for each row in the view.
SELECT *, row_number() OVER (ORDER BY name ASC) AS id
FROM
(
SELECT
foo.name AS name,
FROM
foo
UNION
SELECT
bar.name AS name,
FROM
bar
)
AS
summary
"""
You can use Super_calendar module. you can see it here. https://launchpad.net/server-env-tools