[FIX] : System Parameter.
This commit is contained in:
parent
3590c60b50
commit
689472ef2c
@ -30,35 +30,41 @@ class PublisherWarrantyContract(AbstractModel):
|
|||||||
db_create_date = IrParamSudo.get_param('database.create_date')
|
db_create_date = IrParamSudo.get_param('database.create_date')
|
||||||
limit_date = datetime.datetime.now()
|
limit_date = datetime.datetime.now()
|
||||||
limit_date = limit_date - datetime.timedelta(15)
|
limit_date = limit_date - datetime.timedelta(15)
|
||||||
limit_date_str = limit_date.strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT)
|
limit_date_str = limit_date.strftime(
|
||||||
|
misc.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||||
nbr_users = Users.search_count([('active', '=', True)])
|
nbr_users = Users.search_count([('active', '=', True)])
|
||||||
nbr_active_users = Users.search_count([("login_date", ">=", limit_date_str), ('active', '=', True)])
|
nbr_active_users = Users.search_count(
|
||||||
|
[("login_date", ">=", limit_date_str), ('active', '=', True)])
|
||||||
nbr_share_users = 0
|
nbr_share_users = 0
|
||||||
nbr_active_share_users = 0
|
nbr_active_share_users = 0
|
||||||
if "share" in Users._fields:
|
if "share" in Users._fields:
|
||||||
nbr_share_users = Users.search_count([("share", "=", True), ('active', '=', True)])
|
nbr_share_users = Users.search_count(
|
||||||
nbr_active_share_users = Users.search_count([("share", "=", True), ("login_date", ">=", limit_date_str), ('active', '=', True)])
|
[("share", "=", True), ('active', '=', True)])
|
||||||
|
nbr_active_share_users = Users.search_count(
|
||||||
|
[("share", "=", True), ("login_date", ">=", limit_date_str),
|
||||||
|
('active', '=', True)])
|
||||||
user = self.env.user
|
user = self.env.user
|
||||||
domain = [('application', '=', True), ('state', 'in', ['installed', 'to upgrade', 'to remove'])]
|
domain = [('application', '=', True),
|
||||||
|
('state', 'in', ['installed', 'to upgrade', 'to remove'])]
|
||||||
apps = self.env['ir.module.module'].sudo().search_read(domain, ['name'])
|
apps = self.env['ir.module.module'].sudo().search_read(domain, ['name'])
|
||||||
|
demo_domain = [('name', 'ilike', 'base'), ('demo', '=', True)]
|
||||||
enterprise_code = IrParamSudo.get_param('database.enterprise_code')
|
demo_data_ids = self.env['ir.module.module'].sudo().search(demo_domain)
|
||||||
|
demo_data = True
|
||||||
|
if not demo_data_ids:
|
||||||
|
demo_data = False
|
||||||
|
support_code = IrParamSudo.get_param('database.support_code')
|
||||||
|
|
||||||
web_base_url = IrParamSudo.get_param('web.base.url')
|
web_base_url = IrParamSudo.get_param('web.base.url')
|
||||||
msg = {
|
msg = {"dbuuid": dbuuid, "nbr_users": nbr_users,
|
||||||
"dbuuid": dbuuid,
|
"nbr_active_users": nbr_active_users,
|
||||||
"nbr_users": nbr_users,
|
"nbr_share_users": nbr_share_users,
|
||||||
"nbr_active_users": nbr_active_users,
|
"nbr_active_share_users": nbr_active_share_users,
|
||||||
"nbr_share_users": nbr_share_users,
|
"dbname": self._cr.dbname, "db_create_date": db_create_date,
|
||||||
"nbr_active_share_users": nbr_active_share_users,
|
"version": release.version, "language": user.lang,
|
||||||
"dbname": self._cr.dbname,
|
"web_base_url": web_base_url,
|
||||||
"db_create_date": db_create_date,
|
"apps": [app['name'] for app in apps],
|
||||||
"version": release.version,
|
"support_code": support_code,
|
||||||
"language": user.lang,
|
"demo_data": demo_data}
|
||||||
"web_base_url": web_base_url,
|
|
||||||
"apps": [app['name'] for app in apps],
|
|
||||||
"enterprise_code": enterprise_code,
|
|
||||||
}
|
|
||||||
if user.partner_id.company_id:
|
if user.partner_id.company_id:
|
||||||
company_id = user.partner_id.company_id
|
company_id = user.partner_id.company_id
|
||||||
msg.update(company_id.read(["name", "email", "phone"])[0])
|
msg.update(company_id.read(["name", "email", "phone"])[0])
|
||||||
@ -89,16 +95,19 @@ class PublisherWarrantyContract(AbstractModel):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Code will be execute only if parameter value 'True'
|
# Code will be execute only if parameter value 'True'
|
||||||
parameter_id = self.env.ref("mail.config_update_notification")
|
parameter_id = self.env['ir.config_parameter'].sudo().get_param(
|
||||||
if parameter_id and parameter_id.value != 'True':
|
"send_statistics")
|
||||||
|
if parameter_id != 'True':
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
result = self._get_sys_logs()
|
result = self._get_sys_logs()
|
||||||
except Exception:
|
except Exception:
|
||||||
if cron_mode: # we don't want to see any stack trace in cron
|
if cron_mode: # we don't want to see any stack trace in cron
|
||||||
return False
|
return False
|
||||||
_logger.debug("Exception while sending a get logs messages", exc_info=1)
|
_logger.debug("Exception while sending a get logs messages",
|
||||||
raise UserError(_("Error during communication with the publisher warranty server."))
|
exc_info=1)
|
||||||
|
raise UserError(_(
|
||||||
|
"Error during communication with the publisher warranty server."))
|
||||||
# old behavior based on res.log; now on mail.message, that is not necessarily installed
|
# old behavior based on res.log; now on mail.message, that is not necessarily installed
|
||||||
user = self.env['res.users'].sudo().browse(SUPERUSER_ID)
|
user = self.env['res.users'].sudo().browse(SUPERUSER_ID)
|
||||||
poster = self.sudo().env.ref('mail.channel_all_employees')
|
poster = self.sudo().env.ref('mail.channel_all_employees')
|
||||||
@ -108,19 +117,24 @@ class PublisherWarrantyContract(AbstractModel):
|
|||||||
poster = user
|
poster = user
|
||||||
for message in result["messages"]:
|
for message in result["messages"]:
|
||||||
try:
|
try:
|
||||||
poster.message_post(body=message, subtype='mt_comment', partner_ids=[user.partner_id.id])
|
poster.message_post(body=message, subtype='mt_comment',
|
||||||
|
partner_ids=[user.partner_id.id])
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if result.get('enterprise_info'):
|
if result.get('support_info'):
|
||||||
# Update expiration date
|
# Update expiration date
|
||||||
set_param = self.env['ir.config_parameter'].sudo().set_param
|
set_param = self.env['ir.config_parameter'].sudo().set_param
|
||||||
set_param('database.expiration_date', result['enterprise_info'].get('expiration_date'))
|
set_param('database.expiration_date',
|
||||||
set_param('database.expiration_reason', result['enterprise_info'].get('expiration_reason', 'trial'))
|
result['support_info'].get('expiration_date'))
|
||||||
set_param('database.enterprise_code', result['enterprise_info'].get('enterprise_code'))
|
set_param('database.expiration_reason',
|
||||||
|
result['support_info'].get('expiration_reason',
|
||||||
|
'trial'))
|
||||||
|
set_param('database.support_code',
|
||||||
|
result['support_info'].get('support_code'))
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
if cron_mode:
|
if cron_mode:
|
||||||
return False # we don't want to see any stack trace in cron
|
return False # we don't want to see any stack trace in cron
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
return True
|
return True
|
||||||
|
@ -20,6 +20,7 @@ _default_parameters = {
|
|||||||
"database.uuid": lambda: pycompat.text_type(uuid.uuid1()),
|
"database.uuid": lambda: pycompat.text_type(uuid.uuid1()),
|
||||||
"database.create_date": fields.Datetime.now,
|
"database.create_date": fields.Datetime.now,
|
||||||
"web.base.url": lambda: "http://localhost:%s" % config.get('http_port'),
|
"web.base.url": lambda: "http://localhost:%s" % config.get('http_port'),
|
||||||
|
"send_statistics": lambda: "True",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +74,8 @@ class configmanager(object):
|
|||||||
self.options = {
|
self.options = {
|
||||||
'admin_passwd': 'admin',
|
'admin_passwd': 'admin',
|
||||||
'csv_internal_sep': ',',
|
'csv_internal_sep': ',',
|
||||||
'publisher_warranty_url': 'http://services.flectrahq.com/publisher-warranty/',
|
'publisher_warranty_url':
|
||||||
|
'http://services.flectrahq.com/publisher-warranty/',
|
||||||
'reportgz': False,
|
'reportgz': False,
|
||||||
'root_path': None,
|
'root_path': None,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user