social/mail_activity_board/views/mail_activity_view.xml
Laurent Mignon (ACSONE) 7ae75aa371 [IMP] mail_activity_board: Direct access to related model instance
Add a direct access from activity calendar and form views to the linked model instance.

Bedore this change, it was not possible to access to the model instance linked to an activity from the calendar view nor from the view opened by clicling on the activity into the calendar

[IMP] mail_activiy_board: Restrict related_model_instance selection to models supporting mail acitvities

Co-Authored-By: Miquel Raïch <miquel.raich@eficent.com>
2022-11-29 18:51:29 -03:00

337 lines
15 KiB
XML

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!--
VIEWS
-->
<!-- FORM POP
Add a link to the related model instance to ease navigation
-->
<record id="mail_activity_view_form_popup" model="ir.ui.view">
<field
name="name"
>mail.activity.view.form.popup (in mail_activity_board)</field>
<field name="model">mail.activity</field>
<field name="inherit_id" ref="mail.mail_activity_view_form_popup" />
<field name="arch" type="xml">
<field name="activity_type_id" position="before">
<field
name="related_model_instance"
attrs="{'invisible': [('related_model_instance','=', False)]}"
/>
</field>
</field>
</record>
<!-- CALENDAR VIEW
Add a link to the related model instance to ease navigation
-->
<record id="mail_activity_view_calendar" model="ir.ui.view">
<field
name="name"
>mail.activity.view.form.calendar (in mail_activity_board)</field>
<field name="model">mail.activity</field>
<field name="inherit_id" ref="mail.mail_activity_view_calendar" />
<field name="arch" type="xml">
<field name="res_name" position="before">
<field name="related_model_instance" />
</field>
<field name="res_name" position="attributes">
<attribute name="invisible">1</attribute>
</field>
</field>
</record>
<!-- FORM VIEW -->
<record id="mail_activity_view_form_board" model="ir.ui.view">
<field name="name">mail.activity.boards.view.form</field>
<field name="model">mail.activity</field>
<field name="priority">30</field>
<field name="arch" type="xml">
<form string="Activity Form" create="false" edit="false" delete="false">
<sheet string="Activity">
<button
name="open_origin"
type="object"
class="centre oe_link"
nolabel="1"
>
<h1><field name="res_name" /></h1>
</button>
<field name="activity_category" invisible="1" />
<field name="res_model" invisible="1" />
<field name="res_model_id" invisible="1" />
<field name="res_id" invisible="1" />
<group>
<group>
<field
name="activity_type_id"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field name="res_model_id_name" />
<field name="calendar_event_id" invisible="1" />
<field name="create_date" invisible="1" />
</group>
<group>
<field
name="date_deadline"
attrs="{'invisible': [('activity_category', '=', 'meeting')]}"
/>
<field
name="calendar_event_id_start"
string="Start meeting"
attrs="{'invisible': [('calendar_event_id','=', False)]}"
/>
<field
name="duration"
widget="float_time"
attrs="{'invisible': ['|',('duration', '=', False),
('calendar_event_id','=', False)]}"
/>
<field name="user_id" options="{'no_open': True}" />
</group>
</group>
<group
attrs="{'invisible': ['|',('calendar_event_id','=', False),('calendar_event_id_partner_ids','=', False)]}"
>
<field name="calendar_event_id_partner_ids" mode="kanban" />
</group>
<group>
<field name="summary" placeholder="e.g. Discuss proposal" />
<field name="note" placeholder="Log a note..." />
</group>
</sheet>
</form>
</field>
</record>
<!-- TREE VIEW -->
<record id="mail_activity_view_tree" model="ir.ui.view">
<field name="name">mail.activity.boards.view.tree</field>
<field name="model">mail.activity</field>
<field name="inherit_id" ref="mail.mail_activity_view_tree" />
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="default_order" />
<attribute
name="decoration-danger"
>(date_deadline &lt; current_date)</attribute>
<attribute
name="decoration-warning"
>(date_deadline == current_date)</attribute>
<attribute
name="decoration-success"
>(date_deadline &gt; current_date)</attribute>
</xpath>
<field name="res_name" position="before">
<field name="related_model_instance" />
</field>
<field name="res_name" position="attributes">
<attribute name="invisible">1</attribute>
</field>
</field>
</record>
<!-- KANBAN VIEW -->
<record id="mail_activity_view_kanban" model="ir.ui.view">
<field name="name">mail.activity.boards.view.kanban</field>
<field name="model">mail.activity</field>
<field name="priority" eval="10" />
<field name="arch" type="xml">
<kanban
default_group_by="activity_type_id"
class="_kanban_small_column o_opportunity_kanban"
create="0"
_order="date_deadline"
group_create="false"
group_delete="false"
group_edit="false"
>
<field name="user_id" />
<field name="res_id" />
<field name="res_name" />
<field name="res_model" />
<field name="summary" />
<field name="date_deadline" />
<field name="state" />
<field name="icon" />
<field name="activity_type_id" />
<field name="activity_category" />
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_content oe_kanban_global_click">
<div class="oe_kanban_content">
<div>
<strong class="o_kanban_record_subtitle">
<span
t-attf-class="fa #{record.icon.raw_value}"
/>
<field name="summary" />
</strong>
</div>
<div>
<strong class="o_kanban_record_title"><field
name="res_name"
/></strong>
</div>
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left">
<t
t-set="act_date"
t-value="new Date(record.date_deadline.raw_value)"
/>
<t t-if="act_date &lt; (new Date())">
<span t-attf-class="text-danger"><i
title="date"
class="fa fa-clock-o"
/></span>
<t
t-if="record.activity_category.raw_value!='meeting'"
>
<span t-attf-class="text-danger">
<field
name="date_deadline"
t-options='{"widget": "date"}'
/>
</span>
</t>
<t t-else="">
<span t-attf-class="text-danger">
<field
name="calendar_event_id_start"
t-options='{"widget": "date"}'
/>
</span>
</t>
</t>
<t t-else="">
<span><i
title="date"
class="fa fa-clock-o"
/></span>
<t
t-if="record.activity_category.raw_value!='meeting'"
>
<span>
<field
name="date_deadline"
t-options='{"widget": "date"}'
/>
</span>
</t>
<t t-else="">
<field
name="calendar_event_id_start"
t-options='{"widget": "date"}'
/>
</t>
</t>
</div>
<div class="oe_kanban_bottom_right">
<img
t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)"
t-att-title="record.user_id.value"
t-att-alt="record.user_id.value"
width="24"
height="24"
class="oe_kanban_avatar"
/>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!-- SEARCH VIEW -->
<record id="mail_activity_view_search" model="ir.ui.view">
<field name="name">mail.activity.boards.view.search</field>
<field name="model">mail.activity</field>
<field name="inherit_id" ref="mail.mail_activity_view_search" />
<field name="priority" eval="2" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr='//field[@name="res_model"]' position='before'>
<field name="user_id" />
<field name="res_name" string="Origin" />
</xpath>
<xpath expr='//filter[@name="activities_overdue"]' position='before'>
<filter
string="Act. next month"
name="activities_month"
domain="[('date_deadline', '&lt;', (context_today()+datetime.timedelta(days=30)).strftime('%Y-%m-%d'))]"
help="Show activities scheduled for next month."
/>
<filter
string="Act. next 6 months"
name="activities_6_month"
domain="[('date_deadline', '&lt;', (context_today()+datetime.timedelta(days=180)).strftime('%Y-%m-%d'))]"
help="Show activities scheduled for next 6 months."
/>
<separator />
</xpath>
<xpath expr='//search/group' position='inside'>
<filter
string="User"
name='assigned_user'
context="{'group_by':'user_id'}"
/>
<filter
string="Origin"
name='origin'
context="{'group_by': 'res_model_id'}"
/>
</xpath>
</field>
</record>
<!--
ACTION
-->
<record model="ir.actions.act_window" id="open_boards_activities">
<field name="name">Activities</field>
<field name="res_model">mail.activity</field>
<field name="view_mode">kanban,form</field>
<field name="domain">[]</field>
<field name="context">{}</field>
<field
name="view_ids"
eval="[(5, 0, 0),
(0, 0, {'view_mode': 'kanban', 'view_id': ref('mail_activity_view_kanban')}),
(0, 0, {'view_mode': 'tree', 'view_id': ref('mail_activity_view_tree')}),
(0, 0, {'view_mode': 'form', 'view_id': ref('mail_activity_view_form_board')}),
(0, 0, {'view_mode': 'calendar'}),
(0, 0, {'view_mode': 'pivot'}),
(0, 0, {'view_mode': 'graph'})]"
/>
<field name="search_view_id" ref="mail_activity_view_search" />
</record>
<!--
Menus
-->
<menuitem
id="board_menu_activities"
name="Activities"
parent="base.menu_board_root"
action="open_boards_activities"
sequence="1"
/>
</odoo>