[FIX] odoo_referral(_portal): remove referral
Remove referral feature. remove odoo_referral and odoo_portal feature closes odoo/odoo#60927 X-original-commit: dda0bb499b0964b3a1750431255ecfef6cc9eb46 Related: odoo/upgrade#1889 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Signed-off-by: Thibault Francois <tfr-odoo@users.noreply.github.com> Co-authored-by: Alex Tuyls <alt@odoo.com>
This commit is contained in:
co-authored by
Alex Tuyls
parent
725232bb1a
commit
0356e543c2
@@ -1,4 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import controllers
|
||||
from . import models
|
||||
@@ -1,16 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': "Odoo referral program",
|
||||
'summary': """Allow you to refer your friends to Odoo and get rewards""",
|
||||
'category': 'Hidden',
|
||||
'version': '1.0',
|
||||
'depends': ['base', 'web'],
|
||||
'data': [
|
||||
'views/templates.xml',
|
||||
],
|
||||
'qweb': [
|
||||
"static/src/xml/systray.xml",
|
||||
],
|
||||
'auto_install': True,
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import referral
|
||||
@@ -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)}
|
||||
@@ -1,53 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * odoo_referral
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-09-29 13:45+0000\n"
|
||||
"PO-Revision-Date: 2020-09-29 13:45+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: odoo_referral
|
||||
#. openerp-web
|
||||
#: code:addons/odoo_referral/static/src/js/systray.js:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"A popup window has been blocked. You may need to change your browser "
|
||||
"settings to allow popup windows for this page."
|
||||
msgstr ""
|
||||
|
||||
#. module: odoo_referral
|
||||
#: model:ir.model.fields,field_description:odoo_referral.field_res_users__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: odoo_referral
|
||||
#: model:ir.model.fields,field_description:odoo_referral.field_res_users__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: odoo_referral
|
||||
#: model:ir.model.fields,field_description:odoo_referral.field_res_users____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: odoo_referral
|
||||
#. openerp-web
|
||||
#: code:addons/odoo_referral/static/src/xml/systray.xml:0
|
||||
#: code:addons/odoo_referral/static/src/xml/systray.xml:0
|
||||
#, python-format
|
||||
msgid "Odoo Referral Program"
|
||||
msgstr ""
|
||||
|
||||
#. module: odoo_referral
|
||||
#: model:ir.model,name:odoo_referral.model_res_users
|
||||
msgid "Users"
|
||||
msgstr ""
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import res_users
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
});
|
||||
@@ -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>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<template id="assets_backend" name="systray_odoo_referral_icon" inherit_id="web.assets_backend">
|
||||
<xpath expr=".">
|
||||
<script type="text/javascript" src="/odoo_referral/static/src/js/systray.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user