summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/odoo_referral/__init__.py2
-rw-r--r--addons/odoo_referral/__manifest__.py3
-rw-r--r--addons/odoo_referral/controllers/referral.py11
-rw-r--r--addons/odoo_referral/models/__init__.py4
-rw-r--r--addons/odoo_referral/models/res_users.py58
-rw-r--r--addons/odoo_referral/static/src/js/systray.js62
-rw-r--r--addons/odoo_referral/static/src/xml/systray.xml10
-rw-r--r--addons/odoo_referral_portal/__init__.py (renamed from addons/odoo_referral/controllers/__init__.py)2
8 files changed, 0 insertions, 152 deletions
diff --git a/addons/odoo_referral/__init__.py b/addons/odoo_referral/__init__.py
index bb0aae7ee63..67dee8c60db 100644
--- a/addons/odoo_referral/__init__.py
+++ b/addons/odoo_referral/__init__.py
@@ -1,4 +1,2 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from . import controllers
-from . import models
diff --git a/addons/odoo_referral/__manifest__.py b/addons/odoo_referral/__manifest__.py
index 7b1a47bb876..fb4045a11b4 100644
--- a/addons/odoo_referral/__manifest__.py
+++ b/addons/odoo_referral/__manifest__.py
@@ -9,8 +9,5 @@
'data': [
'views/templates.xml',
],
- 'qweb': [
- "static/src/xml/systray.xml",
- ],
'auto_install': True,
}
diff --git a/addons/odoo_referral/controllers/referral.py b/addons/odoo_referral/controllers/referral.py
deleted file mode 100644
index 7364d500b1e..00000000000
--- a/addons/odoo_referral/controllers/referral.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-from odoo.http import Controller, request, route
-
-
-class Referral(Controller):
-
- @route(['/odoo_referral/go'], type='json', auth='user', method='POST', website=True)
- def referral_go(self):
- return {'link': request.env.user._get_referral_link(reset_count=True)}
diff --git a/addons/odoo_referral/models/__init__.py b/addons/odoo_referral/models/__init__.py
deleted file mode 100644
index 74f3017f7e6..00000000000
--- a/addons/odoo_referral/models/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-from . import res_users
diff --git a/addons/odoo_referral/models/res_users.py b/addons/odoo_referral/models/res_users.py
deleted file mode 100644
index 522ba458806..00000000000
--- a/addons/odoo_referral/models/res_users.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-import logging
-import uuid
-import requests
-import hmac
-import threading
-
-from hashlib import sha1
-from werkzeug.urls import url_encode
-
-from odoo import api, models, tools
-
-
-DEST_SERVER_URL = 'https://www.odoo.com'
-_logger = logging.getLogger(__name__)
-
-
-class Users(models.Model):
- _inherit = 'res.users'
-
- @api.model
- def get_referral_updates_count_for_current_user(self):
- if tools.config.options['test_enable']:
- return 0
- token = self.env.user._get_or_generate_referral_token()
- if not token:
- return 0
-
- try:
- response = requests.get(DEST_SERVER_URL + '/referral/notifications/' + token, timeout=10)
- except Exception as e:
- if not getattr(threading.currentThread(), 'testing', False):
- _logger.exception("Failed to fetch referral gift notifications")
- return 0
- if not response.ok:
- return 0
-
- return response.json().get('updates_count', 0)
-
- def _get_or_generate_referral_token(self):
- self.ensure_one()
- db_secret = self.env['ir.config_parameter'].sudo().get_param('database.secret').encode('utf-8')
- db_uuid = self.env['ir.config_parameter'].sudo().get_param('database.uuid')
- message = (db_uuid + self.env.user.email).encode('utf-8')
- return hmac.new(db_secret, message, sha1).hexdigest()
-
- def _get_referral_link(self, reset_count=False):
- self.ensure_one()
- params = {
- 'token': self._get_or_generate_referral_token(),
- 'referrer_email': self.partner_id.email,
- }
- if reset_count:
- params['reset_count'] = 1
-
- return DEST_SERVER_URL + '/referral/register?' + url_encode(params)
diff --git a/addons/odoo_referral/static/src/js/systray.js b/addons/odoo_referral/static/src/js/systray.js
index 689a5a93a33..e69de29bb2d 100644
--- a/addons/odoo_referral/static/src/js/systray.js
+++ b/addons/odoo_referral/static/src/js/systray.js
@@ -1,62 +0,0 @@
-odoo.define('systray.systray_odoo_referral', function (require) {
- "use strict";
- var core = require('web.core');
- var localStorage = require('web.local_storage');
- var SystrayMenu = require('web.SystrayMenu');
- var Widget = require('web.Widget');
-
- var _t = core._t;
- var ActionMenu = Widget.extend({
- template: 'systray_odoo_referral.gift_icon',
- events: {
- 'click .gift_icon': 'onclick_gifticon',
- },
-
- start: function (parent) {
- var self = this;
- var lastFetch = localStorage.getItem('odoo_referral.updates_last_fetch');
- var updatesCount = localStorage.getItem('odoo_referral.updates_count');
- var hasClicked = localStorage.getItem('odoo_referral.has_clicked');
- if (hasClicked && (!lastFetch || Date(parseInt(lastFetch)) < Date(new Date().getTime() - (24 * 60 * 60 * 1000)))) {
- this._rpc({
- model: 'res.users',
- method: 'get_referral_updates_count_for_current_user'
- }, {
- shadow: true,
- }).then(function (count) {
- localStorage.setItem('odoo_referral.updates_last_fetch', Date.now());
- localStorage.setItem('odoo_referral.updates_count', count);
- if (count > 0) {
- self.$('.o_notification_counter').text(count);
- }
- });
- } else {
- if (updatesCount && updatesCount > 0) {
- self.$('.o_notification_counter').text(updatesCount);
- }
- }
- return this._super.apply(this, arguments);
- },
-
- onclick_gifticon: function () {
- var self = this;
- localStorage.setItem('odoo_referral.updates_count', 0);
- this._rpc({
- route: '/odoo_referral/go/'
- }).then(function (result) {
- localStorage.setItem('odoo_referral.has_clicked', 1);
- self.$('.o_notification_counter').text('');
- var w = window.open(result.link, '_blank', 'noreferrer noopener');
- if (!w || w.closed || typeof w.closed === 'undefined') {
- var message = _t('A popup window has been blocked. You ' +
- 'may need to change your browser settings to allow ' +
- 'popup windows for this page.');
- self.do_warn(false, message, true);
- }
- });
- },
- });
-
- SystrayMenu.Items.push(ActionMenu);
- return ActionMenu;
-});
diff --git a/addons/odoo_referral/static/src/xml/systray.xml b/addons/odoo_referral/static/src/xml/systray.xml
deleted file mode 100644
index 9e34ac8f856..00000000000
--- a/addons/odoo_referral/static/src/xml/systray.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<templates>
- <t t-name="systray_odoo_referral.gift_icon">
- <li class="gift_icon o_mail_systray_item">
- <a role="button" href="javascript:void(0)" class="gift_icon" title="Odoo Referral Program">
- <i class="fa fa-gift" aria-label="Odoo Referral Program" /> <span id="gift_notification_counter" class="o_notification_counter badge badge-pill"/>
- </a>
- </li>
- </t>
-</templates>
diff --git a/addons/odoo_referral/controllers/__init__.py b/addons/odoo_referral_portal/__init__.py
index 5e307cd5a18..67dee8c60db 100644
--- a/addons/odoo_referral/controllers/__init__.py
+++ b/addons/odoo_referral_portal/__init__.py
@@ -1,4 +1,2 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-from . import referral