diff --git a/pos_chatter/README.rst b/pos_chatter/README.rst new file mode 100644 index 000000000..89c9411bf --- /dev/null +++ b/pos_chatter/README.rst @@ -0,0 +1,25 @@ +============== +POS Chatter v9 +============== +This module adds chat interface in Point of sale screen. + +Installation +============ +Just select it from available modules to install it, there is no need to extra installations. + +Configuration +============= +Nothing to configure. + +Usage +===== +* Chat Button on POS screen. +* On clicking chat button,display chat list on the screen. +* On clicking an item in chat list, chat window open in pos screen. + +Credits +======= +Developer: Aswani pc @ cybrosys +Guidance: Nilmar Shereef @ cybrosys, shereef@cybrosys.in + + diff --git a/pos_chatter/__init__.py b/pos_chatter/__init__.py new file mode 100644 index 000000000..06839078f --- /dev/null +++ b/pos_chatter/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + diff --git a/pos_chatter/__openerp__.py b/pos_chatter/__openerp__.py new file mode 100644 index 000000000..debc4b2cc --- /dev/null +++ b/pos_chatter/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2008-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': "POS Chat", + 'summary': """Chat in POS""", + 'description': "This module adds chat interface in Point of sale screen.", + 'author': "Cybrosys Techno Solutions", + 'company': "Cybrosys Techno Solutions", + 'website': "http://www.cybrosys.com", + 'category': 'Point Of Sale', + 'version': '0.3', + 'depends': ['base', 'point_of_sale'], + 'data': ['views/pos_chat.xml'], + 'qweb': ['static/src/xml/pos_msg.xml'], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, +} diff --git a/pos_chatter/static/description/banner.jpg b/pos_chatter/static/description/banner.jpg new file mode 100644 index 000000000..78370eb22 Binary files /dev/null and b/pos_chatter/static/description/banner.jpg differ diff --git a/pos_chatter/static/description/cybro_logo.png b/pos_chatter/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/pos_chatter/static/description/cybro_logo.png differ diff --git a/pos_chatter/static/description/icon.png b/pos_chatter/static/description/icon.png new file mode 100644 index 000000000..070786c96 Binary files /dev/null and b/pos_chatter/static/description/icon.png differ diff --git a/pos_chatter/static/description/index.html b/pos_chatter/static/description/index.html new file mode 100644 index 000000000..4dc944767 --- /dev/null +++ b/pos_chatter/static/description/index.html @@ -0,0 +1,48 @@ +
+
+

POS Chat

+

Easily communicate each other without going outside of POS Screen.

+

Cybrosys Technologies , www.cybrosys.com

+
+

Features:

+
    +
  • We can easily communicate each other in POS.
  • +
  • Nothing to configure.
  • +
+
+
+
+ +
+
+

Chat Button on POS screen

+
+ +
+
+
+ +
+
+

On clicking an item in chatlist, chat window open in pos screen

+
+ +
+
+
+ +
+

Need Any Help?

+ + +
diff --git a/pos_chatter/static/description/pos_chat_01.png b/pos_chatter/static/description/pos_chat_01.png new file mode 100644 index 000000000..7a5e39974 Binary files /dev/null and b/pos_chatter/static/description/pos_chat_01.png differ diff --git a/pos_chatter/static/description/pos_chat_02.png b/pos_chatter/static/description/pos_chat_02.png new file mode 100644 index 000000000..74c3ba5bc Binary files /dev/null and b/pos_chatter/static/description/pos_chat_02.png differ diff --git a/pos_chatter/static/src/css/message.css b/pos_chatter/static/src/css/message.css new file mode 100644 index 000000000..d6b9a3884 --- /dev/null +++ b/pos_chatter/static/src/css/message.css @@ -0,0 +1,82 @@ +.pos .message-box{ + position: absolute; + right: -350px; + top: 50px; + width: 100%; + height:100%; + background-color: rgba(0,0,0,0); + z-index:1000; +} +.pos .message-box .message{ + position:relative; + top:0;left: 0; right: 0; bottom:0; + margin: auto; + width:350px; + font-size:22px; + background-color: #F0EEEE; + box-shadow: 0px 10px 20px rgba(0,0,0,0.4); + z-index:1200; + font-family: 'Lato'; + font-family: Lato; +} +.pos .message .title { + background: #FFFFFF; + margin: 0; + padding: 4px; + border-bottom: solid 1px rgba(60,60,60,0.1); +} +.pos .pos-new_message{ + margin-left :90px; + color: #337ab7 + } + +.pos .message a { + text-decoration: none; + font-size: 11px; + cursor: pointer; + padding: 4px 10px; + +} +.pos .message a:hover { + color: #337ab7; +} + +.pos .pos-selected { + font-weight: bold; + color : #337ab7; + } + +.pos .fa-close { + margin-right: 10px; + cursor: pointer; + } + + +.ui-widget{ + font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif; + background:#FFFFFF; + font-size: 13px; + width:200px; + z-index: 10000; + +} +.ui-menu{ + padding: 2px 0; + margin-top: 4px; + } +.ui-menu-item{ + display: block; + background:#FFFFFF; + color: #000000; : +} + +.ui-menu-item:hover{ + display: block; + background:#7f82ac; + color:#FFFFFF; +} +.ui-menu .ui-menu-item a{ + height:10px; + padding: 1px 16px; +} + diff --git a/pos_chatter/static/src/js/pos_chat.js b/pos_chatter/static/src/js/pos_chat.js new file mode 100644 index 000000000..17c4ef395 --- /dev/null +++ b/pos_chatter/static/src/js/pos_chat.js @@ -0,0 +1,185 @@ +odoo.define('point_of_sale.pos_chatter', function (require) { +"use strict"; +var chrome = require('point_of_sale.chrome'); +var core = require('web.core'); +var chat_manager = require('mail.chat_manager'); +var window_manager = require('mail.window_manager'); +var ajax = require('web.ajax'); +var gui = require('point_of_sale.gui'); +var popup = require('point_of_sale.popups'); +var PosBaseWidget = require('point_of_sale.BaseWidget'); +var QWeb = core.qweb; +var _t = core._t; + +chrome.Chrome.include({ + events: { + "click .pos-message": "on_click_pos_message", + }, + renderElement: function(){ + var self = this; + this.filter = false; + chat_manager.bus.on("update_channel_unread_counter", this, this.update_counter); + chat_manager.is_ready.then(this.update_counter.bind(this)); + return this._super(); + }, + + is_open: function () { + return this.$el.hasClass('open'); + }, + + update_counter: function () { + var counter = chat_manager.get_unread_conversation_counter(); + this.$('.o_notification_counter').text(counter); + this.$el.toggleClass('o_no_notification', !counter); + this.$el.toggleClass('o_unread_chat', !!chat_manager.get_chat_unread_counter()); + if (this.is_open()) { + this.update_channels_preview(); + } + }, + + update_channels_preview: function () { + var self = this; + this.$('.o_mail_navbar_dropdown_channels').html(QWeb.render('mail.chat.Spinner')); + chat_manager.is_ready.then(function () { + var channels = _.filter(chat_manager.get_channels(), function (channel) { + if (self.filter === 'chat') { + return channel.is_chat; + } else if (self.filter === 'channels') { + return !channel.is_chat && channel.type !== 'static'; + } else { + return channel.type !== 'static'; + } + }); + chat_manager.get_channels_preview(channels).then(self._render_channels_preview.bind(self)); + }); + }, + + _render_channels_preview: function (channels_preview) { + channels_preview.sort(function (c1, c2) { + return Math.min(1, c2.unread_counter) - Math.min(1, c1.unread_counter) || + c2.is_chat - c1.is_chat || + c2.last_message.date.diff(c1.last_message.date); + }); + + _.each(channels_preview, function (channel) { + channel.last_message_preview = chat_manager.get_message_body_preview(channel.last_message.body); + if (channel.last_message.date.isSame(new Date(), 'd')) { // today + channel.last_message_date = channel.last_message.date.format('LT'); + } else { + channel.last_message_date = channel.last_message.date.format('lll'); + } + }); + this.gui.show_popup('message',{list:channels_preview}); + }, + + on_click_pos_message: function () { + var self = this; + if (this.gui.current_popup) { + this.gui.close_popup(); + } + else{ + this.update_channels_preview(); + } + }, + + on_click_new_message: function () { + chat_manager.bus.trigger('open_chat'); + }, + + +}); + + +var MessageWidget = PosBaseWidget.extend({ + template:'MessageWidget', + events: { + "click .o_mail_channel_preview": "on_click_message_item", + "click .pos-new_message": "on_click_new_message", + "click .pos-filter": "on_click_filter", + }, + renderElement: function(){ + var self = this; + return this._super(); + }, + show: function(options){ + options = options || {}; + var self = this; + this._super(options); + this.list = options.list || []; + this.renderElement(); + + }, + on_click_new_message: function () { + this.gui.close_popup(); + chat_manager.bus.trigger('open_chat'); + }, + + on_click_filter: function (event) { + event.stopPropagation(); + this.$(".pos-filter").removeClass('pos-selected'); + var $target = $(event.currentTarget); + $target.addClass('pos-selected'); + this.filter = $target.data('filter'); + this.update_channels_preview(); + }, + + update_channels_preview: function () { + var self = this; + this.$('.o_mail_navbar_dropdown_channels').html(QWeb.render('mail.chat.Spinner')); + chat_manager.is_ready.then(function () { + var channels = _.filter(chat_manager.get_channels(), function (channel) { + if (self.filter === 'chat') { + return channel.is_chat; + } else if (self.filter === 'channels') { + return !channel.is_chat && channel.type !== 'static'; + } else { + return channel.type !== 'static'; + } + }); + chat_manager.get_channels_preview(channels).then(self._render_channels_preview.bind(self)); + }); + }, + + _render_channels_preview: function (channels_preview) { + + channels_preview.sort(function (c1, c2) { + return Math.min(1, c2.unread_counter) - Math.min(1, c1.unread_counter) || + c2.is_chat - c1.is_chat || + c2.last_message.date.diff(c1.last_message.date); + }); + + _.each(channels_preview, function (channel) { + channel.last_message_preview = chat_manager.get_message_body_preview(channel.last_message.body); + if (channel.last_message.date.isSame(new Date(), 'd')) { // today + channel.last_message_date = channel.last_message.date.format('LT'); + } else { + channel.last_message_date = channel.last_message.date.format('lll'); + } + }); + this.$('.o_mail_navbar_dropdown_channels').html(QWeb.render('mail.chat.ChannelsPreview', { + channels: channels_preview, + })); +}, + + close: function(){ + if (this.$el) { + this.$el.addClass('oe_hidden'); + } + }, + + on_click_message_item: function(event){ + event.stopPropagation(); + var $target = $(event.currentTarget); + var channel_id = $target.data('channel_id'); + var channel = chat_manager.get_channel(channel_id); + if (channel) { + this.gui.close_popup(); + chat_manager.open_channel(channel); + } + }, +}); + +gui.define_popup({name:'message', widget: MessageWidget}); + + +}); diff --git a/pos_chatter/static/src/less/message.less b/pos_chatter/static/src/less/message.less new file mode 100644 index 000000000..e63e6acca --- /dev/null +++ b/pos_chatter/static/src/less/message.less @@ -0,0 +1,122 @@ +@gray: #52575C; +@gray-light: lighten(#000, 46.7%); // #777 +@gray-lighter: lighten(#000, 93.5%); // #eee +@screen-xs-max: 767px; +@screen-sm: 768px; +@screen-sm-min: @screen-sm; +@text-color: #C8C8C8; + +@navbar-default-link-color: @text-color; +@navbar-default-link-hover-color: #fff; +@navbar-default-link-hover-bg: transparent; +@navbar-default-link-active-color: #fff; +@navbar-default-link-active-bg: transparent; +@navbar-default-link-disabled-color: @gray-light; +@navbar-default-link-disabled-bg: transparent; + +@border-radius-base: 4px; + +@navbar-height: 44px; +.text-muted { + color: @gray-light; +} +.box-sizing(@boxmodel) { + -webkit-box-sizing: @boxmodel; + -moz-box-sizing: @boxmodel; + box-sizing: @boxmodel; +} + +.o_chat_window { + &,* { + .box-sizing(border-box); + } + .o_chat_header { + height: 28px; + .fa-close { + text-decoration: none; + font-weight: bold; + + } + > span { + margin: auto 0; + } + } +} + +.btn-link { + color: @navbar-default-link-color; + &:hover, + &:focus { + color: @navbar-default-link-hover-color; + } + &[disabled], + fieldset[disabled] & { + &:hover, + &:focus { + color: @navbar-default-link-disabled-color; + } + } +} + + + +.o_mail_navbar_dropdown_channels { + .o-flex(0, 1, auto); + background: #FFFFFF; + max-height: 400px; + min-height: 50px; + overflow-y: auto; + + @media (max-width: @screen-xs-max) { + max-height: none; + } + + .o_mail_channel_preview { + .o-flex-display(); + height: 40px; + align-items: center; + padding: 5px; + cursor: pointer; + font-size: 12px; + overflow: hidden; + &~.o_mail_channel_preview { + border-top: 1px solid lightgray; + } + &.o_channel_unread { + background-color: lighten(lightgray, 10%); + } + &:hover { + background-color: lighten(lightgray, 5%); + } + + .o_channel_image { + .o-flex(0, 0, 36px); + max-height: 36px; + } + .o_channel_info { + .o-flex(1, 1, 100%); + margin-left: 5px; + overflow: hidden; + + .o_channel_title { + .o-flex-display(); + .o_channel_name { + .o-flex(1, 1, auto); + .o-text-overflow(); + } + .o_last_message_date { + .o-flex(0, 0, auto); + padding-top: 3px; + font-size: xx-small; + color: @odoo-main-color-muted; + } + } + .o_last_message_preview { + width: 100%; + color: @odoo-main-color-muted; + .o-text-overflow(); + } + } + } +} + diff --git a/pos_chatter/static/src/xml/pos_msg.xml b/pos_chatter/static/src/xml/pos_msg.xml new file mode 100644 index 000000000..a0cd0310b --- /dev/null +++ b/pos_chatter/static/src/xml/pos_msg.xml @@ -0,0 +1,58 @@ + + + + + + + diff --git a/pos_chatter/views/pos_chat.xml b/pos_chatter/views/pos_chat.xml new file mode 100644 index 000000000..04a452be0 --- /dev/null +++ b/pos_chatter/views/pos_chat.xml @@ -0,0 +1,21 @@ + + + +