[FIX] crm_reveal: warn user on missing GeoIP
The GeoIP lib is necessary for this module to run but there is zero documentation on that specificity. This commit adds a bus notification to inform the user of the absence of the package through the webclient notification system. closes odoo/odoo#34968 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import re
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from math import floor, log10
|
||||
|
||||
from odoo import api, fields, models, tools, _
|
||||
from odoo import api, fields, models, tools, _, _geoip_resolver
|
||||
from odoo.addons.iap import jsonrpc
|
||||
from odoo.addons.crm.models import crm_stage
|
||||
from odoo.exceptions import ValidationError
|
||||
@@ -72,9 +72,18 @@ class CRMRevealRule(models.Model):
|
||||
except Exception:
|
||||
raise ValidationError(_('Enter Valid Regex.'))
|
||||
|
||||
@api.model
|
||||
def _assert_geoip(self):
|
||||
if not _geoip_resolver:
|
||||
message = _('Lead Generation requires a GeoIP resolver which could not be found on your system. Please consult https://pypi.org/project/GeoIP/.')
|
||||
self.env['bus.bus'].sendone(
|
||||
(self._cr.dbname, 'res.partner', self.env.user.partner_id.id),
|
||||
{'type': 'simple_notification', 'title': _('Missing Library'), 'message': message, 'sticky': True, 'warning': True})
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
self.clear_caches() # Clear the cache in order to recompute _get_active_rules
|
||||
self._assert_geoip()
|
||||
return super(CRMRevealRule, self).create(vals)
|
||||
|
||||
def write(self, vals):
|
||||
@@ -83,6 +92,7 @@ class CRMRevealRule(models.Model):
|
||||
}
|
||||
if set(vals.keys()) & fields_set:
|
||||
self.clear_caches() # Clear the cache in order to recompute _get_active_rules
|
||||
self._assert_geoip()
|
||||
return super(CRMRevealRule, self).write(vals)
|
||||
|
||||
def unlink(self):
|
||||
|
||||
Reference in New Issue
Block a user