[IMP] im_livechat : add nbr_sessions field on channel and modifications of various views
This commit is contained in:
@@ -85,6 +85,13 @@ class im_livechat_channel(osv.Model):
|
||||
"/im_livechat/support/%s/%i" % (cr.dbname, record.id)
|
||||
return res
|
||||
|
||||
def _compute_nbr_session(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
res[record.id] = len(record.session_ids)
|
||||
return res
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.char(string="Channel Name", size=200, required=True),
|
||||
'user_ids': fields.many2many('res.users', 'im_livechat_channel_im_user', 'channel_id', 'user_id', string="Users"),
|
||||
@@ -114,6 +121,8 @@ class im_livechat_channel(osv.Model):
|
||||
help="Small-sized photo of the group. It is automatically "\
|
||||
"resized as a 64x64px image, with aspect ratio preserved. "\
|
||||
"Use this field anywhere a small image is required."),
|
||||
'session_ids' : fields.one2many('im_chat.session', 'channel_id', 'Sessions'),
|
||||
'nbr_session' : fields.function(_compute_nbr_session, type='integer', string='Number of session', store=False),
|
||||
}
|
||||
|
||||
def _default_user_ids(self, cr, uid, context=None):
|
||||
|
||||
@@ -1,9 +1,95 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<menuitem id="im_livechat" name="Live Chat" parent="mail.mail_feeds_main" groups="group_im_livechat"/>
|
||||
<!--
|
||||
Views for im_chat.session
|
||||
-->
|
||||
<!-- History : form, list and search views -->
|
||||
<record id="action_session_history" model="ir.actions.act_window">
|
||||
<field name="name">History</field>
|
||||
<field name="res_model">im_chat.session</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="domain">[('channel_id', '!=', None)]</field>
|
||||
<field name="context">{'group_by': ['channel_id', 'create_date:month']}</field>
|
||||
</record>
|
||||
|
||||
<!-- Support Channel -->
|
||||
<record id="im_chat_session_search" model="ir.ui.view">
|
||||
<field name="name">im_chat.session.search</field>
|
||||
<field name="model">im_chat.session</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search history">
|
||||
<filter name="id" string="My sessions" domain="[('user_ids','in', uid)]"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter name="group_by_channel" string="Channel" domain="[]" context="{'group_by':'channel_id'}"/>
|
||||
<separator orientation="vertical" />
|
||||
<filter name="group_by_day" string="Creation date (day)" domain="[]" context="{'group_by':'create_date:day'}"/>
|
||||
<filter name="group_by_week" string="Creation date (week)" domain="[]" context="{'group_by':'create_date:week'}"/>
|
||||
<filter name="group_by_month" string="Creation date (month)" domain="[]" context="{'group_by':'create_date:month'}" />
|
||||
<filter name="group_by_year" string="Creation date (year)" domain="[]" context="{'group_by':'create_date:year'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="im_chat_session_list_view" model="ir.ui.view">
|
||||
<field name="name">im_chat.session.tree</field>
|
||||
<field name="model">im_chat.session</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="History" create="false">
|
||||
<field name="id"/>
|
||||
<field name="fullname"/>
|
||||
<field name="create_date"/>
|
||||
<field name="feedback_rating"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="im_chat_session_form_view" model="ir.ui.view">
|
||||
<field name="name">im_chat.session.form</field>
|
||||
<field name="model">im_chat.session</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Session Form" create="false" edit="false">
|
||||
<sheet>
|
||||
<group string="General">
|
||||
<field name="id"/>
|
||||
<field name="fullname" />
|
||||
<field name="create_date" readonly="1"/>
|
||||
</group>
|
||||
<group string="Feedback">
|
||||
<field name="feedback_rating"/>
|
||||
<field name="feedback_reason"/>
|
||||
</group>
|
||||
<field name="message_ids" type="tree">
|
||||
<tree string="History">
|
||||
<field name="create_date" />
|
||||
<field name="from_id" />
|
||||
<field name="message" />
|
||||
</tree>
|
||||
</field>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Session of a channel : list view -->
|
||||
<record id="action_session_channel" model="ir.actions.act_window">
|
||||
<field name="name">Sessions</field>
|
||||
<field name="res_model">im_chat.session</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="domain">[('channel_id','in',[active_id])]</field>
|
||||
<field name="context">{
|
||||
'search_default_channel_id': [active_id],
|
||||
'default_channel_id': active_id,
|
||||
}</field>
|
||||
<field name="search_view_id" ref="im_chat_session_search"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!--
|
||||
Views for im_livechat.channel
|
||||
-->
|
||||
<record id="action_support_channels" model="ir.actions.act_window">
|
||||
<field name="name">Live Chat Channels</field>
|
||||
<field name="res_model">im_livechat.channel</field>
|
||||
@@ -21,8 +107,6 @@
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
<menuitem name="Channels" parent="im_livechat" id="support_channels" action="action_support_channels" groups="group_im_livechat"/>
|
||||
|
||||
|
||||
<record id="support_channel_kanban" model="ir.ui.view">
|
||||
<field name="name">support_channel.kanban</field>
|
||||
@@ -33,21 +117,34 @@
|
||||
<field name="web_page" widget="url"/>
|
||||
<field name="are_you_inside"/>
|
||||
<field name="user_ids"/>
|
||||
<field name="nbr_session"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_group_image">
|
||||
<a type="open"><img t-att-src="kanban_image('im_livechat.channel', 'image_medium', record.id.value)" class="oe_group_photo"/></a>
|
||||
</div>
|
||||
<div class="oe_group_details">
|
||||
<h4><a type="open"><field name="name"/></a></h4>
|
||||
<div class="oe_kanban_footer_left">
|
||||
<span>
|
||||
<span class="oe_e">+</span> <t t-esc="(record.user_ids.raw_value || []).length"/>
|
||||
</span>
|
||||
</div>
|
||||
<div class="oe_group_button">
|
||||
<button t-if="record.are_you_inside.raw_value" name="quit" type="object" class="oe_group_join">Quit</button>
|
||||
<button t-if="! record.are_you_inside.raw_value" name="join" type="object">Join</button>
|
||||
<div class="oe_kanban_card oe_kanban_global_click">
|
||||
<div class="oe_module_vignette row">
|
||||
<div class="col-md-4">
|
||||
<div class="oe_module_icon">
|
||||
<img t-att-src="kanban_image('im_livechat.channel', 'image_medium', record.id.value)" class="img-responsive"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<h3><field name="name"/></h3>
|
||||
<div>
|
||||
<p>
|
||||
<i class="fa fa-user">
|
||||
<t t-esc="(record.user_ids.raw_value || []).length"/> Operators
|
||||
</i>
|
||||
<br/>
|
||||
<i class="fa fa-comments">
|
||||
<t t-esc="record.nbr_session.raw_value"/> Sessions
|
||||
</i>
|
||||
</p>
|
||||
<div style="margin-top:5px;">
|
||||
<button t-if="record.are_you_inside.raw_value" name="quit" type="object" class="btn btn-default btn-xs">Quit</button>
|
||||
<button t-if="! record.are_you_inside.raw_value" name="join" type="object" class="btn btn-info btn-xs">Join</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
@@ -56,7 +153,6 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="support_channel_form" model="ir.ui.view">
|
||||
<field name="name">support_channel.form</field>
|
||||
<field name="model">im_livechat.channel</field>
|
||||
@@ -76,7 +172,11 @@
|
||||
<field name="are_you_inside" invisible="1"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<button class="oe_inline oe_stat_button" type="action" attrs="{'invisible':[('nbr_session','=', 0)]}" name="%(action_session_channel)d" icon="fa-comments">
|
||||
<field string="Sessions" name="nbr_session" widget="statinfo"/>
|
||||
</button>
|
||||
</div>
|
||||
<group>
|
||||
<group string="Operators">
|
||||
<field name="user_ids" widget="many2many_kanban" nolabel="1" colspan="2">
|
||||
@@ -116,85 +216,18 @@
|
||||
<field name="web_page" readonly="1" class="oe_tag" widget="url"/>
|
||||
<p>For website built with Odoo CMS, please install the website_livechat module. Then go to Settings > Website Settings and select the Live Chat Channel you want to add on your website.</p>
|
||||
</div>
|
||||
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Session History for Support -->
|
||||
<record id="action_session_history" model="ir.actions.act_window">
|
||||
<field name="name">History</field>
|
||||
<field name="res_model">im_chat.session</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="domain">[('channel_id', '!=', None)]</field>
|
||||
<field name="context">{'group_by': ['channel_id', 'create_date:month']}</field>
|
||||
</record>
|
||||
<!-- Menu items -->
|
||||
<menuitem name="Live Chat" parent="mail.mail_feeds_main" id="im_livechat" groups="group_im_livechat"/>
|
||||
|
||||
<menuitem name="History" parent="im_livechat" id="session_history" action="action_session_history" groups="group_im_livechat"/>
|
||||
|
||||
<record id="im_chat_session_search" model="ir.ui.view">
|
||||
<field name="name">im_chat.session.search</field>
|
||||
<field name="model">im_chat.session</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search history">
|
||||
<filter name="id" string="My sessions" domain="[('user_ids','in', uid)]"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter name="group_by_channel" string="Channel" domain="[]" context="{'group_by':'channel_id'}"/>
|
||||
<separator orientation="vertical" />
|
||||
<filter name="group_by_day" string="Creation date (day)" domain="[]" context="{'group_by':'create_date:day'}"/>
|
||||
<filter name="group_by_week" string="Creation date (week)" domain="[]" context="{'group_by':'create_date:week'}"/>
|
||||
<filter name="group_by_month" string="Creation date (month)" domain="[]" context="{'group_by':'create_date:month'}" />
|
||||
<filter name="group_by_year" string="Creation date (year)" domain="[]" context="{'group_by':'create_date:year'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="im_chat_session_list_view" model="ir.ui.view">
|
||||
<field name="name">im_chat.session.tree</field>
|
||||
<field name="model">im_chat.session</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="History" create="false">
|
||||
<field name="id"/>
|
||||
<field name="fullname"/>
|
||||
<field name="uuid"/>
|
||||
<field name="create_date"/>
|
||||
<field name="feedback_rating"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="im_chat_session_form_view" model="ir.ui.view">
|
||||
<field name="name">im_chat.session.form</field>
|
||||
<field name="model">im_chat.session</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Session Form" version="7.0" create="false" edit="false">
|
||||
<sheet>
|
||||
<group>
|
||||
<group string="General">
|
||||
<field name="id"/>
|
||||
<field name="uuid" readonly="1"/>
|
||||
<field name="fullname" widget="html"/>
|
||||
<field name="create_date" readonly="1"/>
|
||||
</group>
|
||||
<group string="Feedback">
|
||||
<field name="feedback_rating"/>
|
||||
<field name="feedback_reason"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="message_ids" type="tree">
|
||||
<tree string="History">
|
||||
<field name="create_date" />
|
||||
<field name="from_id" />
|
||||
<field name="message" />
|
||||
</tree>
|
||||
</field>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<menuitem name="Channels" parent="im_livechat" id="support_channels" action="action_support_channels" groups="group_im_livechat"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user