From 9d6734d9a779ea8e878ab9f505ea70479386a70a Mon Sep 17 00:00:00 2001 From: Kunjal Date: Mon, 13 Nov 2017 18:48:32 +0530 Subject: [PATCH] [FIX] : System Parameter. --- addons/base_setup/models/res_config_settings.py | 15 +++++++++++++++ .../views/res_config_settings_views.xml | 14 ++++++++++++++ addons/mail/data/mail_demo.xml | 8 -------- addons/mail/models/update.py | 4 ++-- flectra/addons/base/ir/ir_config_parameter.py | 1 - 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/addons/base_setup/models/res_config_settings.py b/addons/base_setup/models/res_config_settings.py index 3d8f52e7..f68eaf1a 100644 --- a/addons/base_setup/models/res_config_settings.py +++ b/addons/base_setup/models/res_config_settings.py @@ -2,6 +2,7 @@ # Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details. from flectra import api, fields, models, _ +import json class ResConfigSettings(models.TransientModel): @@ -35,17 +36,26 @@ class ResConfigSettings(models.TransientModel): help="Allows to work in a multi currency environment") paperformat_id = fields.Many2one(related="company_id.paperformat_id", string='Paper format') external_report_layout = fields.Selection(related="company_id.external_report_layout") + send_statistics = fields.Boolean( + "Send Statistics") @api.model def get_values(self): res = super(ResConfigSettings, self).get_values() params = self.env['ir.config_parameter'].sudo() default_external_email_server = params.get_param('base_setup.default_external_email_server', default=False) + send_statistics = params._get_param( + 'base_setup.send_statistics') + if send_statistics is None: + send_statistics = 'true' + if send_statistics in ['true', 'false']: + send_statistics = json.loads(send_statistics) default_user_rights = params.get_param('base_setup.default_user_rights', default=False) default_custom_report_footer = params.get_param('base_setup.default_custom_report_footer', default=False) res.update( default_external_email_server=default_external_email_server, default_user_rights=default_user_rights, + send_statistics=send_statistics, default_custom_report_footer=default_custom_report_footer, company_share_partner=not self.env.ref('base.res_partner_rule').active, ) @@ -57,6 +67,11 @@ class ResConfigSettings(models.TransientModel): self.env['ir.config_parameter'].sudo().set_param("base_setup.default_external_email_server", self.default_external_email_server) self.env['ir.config_parameter'].sudo().set_param("base_setup.default_user_rights", self.default_user_rights) self.env['ir.config_parameter'].sudo().set_param("base_setup.default_custom_report_footer", self.default_custom_report_footer) + send_statistics = 'true' + if not self.send_statistics: + send_statistics = 'false' + self.env['ir.config_parameter'].sudo().set_param( + "base_setup.send_statistics", send_statistics) self.env.ref('base.res_partner_rule').write({'active': not self.company_share_partner}) @api.multi diff --git a/addons/base_setup/views/res_config_settings_views.xml b/addons/base_setup/views/res_config_settings_views.xml index e9d1894e..e8527b64 100644 --- a/addons/base_setup/views/res_config_settings_views.xml +++ b/addons/base_setup/views/res_config_settings_views.xml @@ -218,6 +218,20 @@ +

System Parameter

+
+
+
+ +
+
+
+
+
diff --git a/addons/mail/data/mail_demo.xml b/addons/mail/data/mail_demo.xml index e33b1e36..cd0de0d9 100644 --- a/addons/mail/data/mail_demo.xml +++ b/addons/mail/data/mail_demo.xml @@ -2,14 +2,6 @@ - - - - - Base statistics - True - - Plan to install backup servers diff --git a/addons/mail/models/update.py b/addons/mail/models/update.py index 599f5670..9f9e6d21 100644 --- a/addons/mail/models/update.py +++ b/addons/mail/models/update.py @@ -96,8 +96,8 @@ class PublisherWarrantyContract(AbstractModel): try: # Code will be execute only if parameter value 'True' parameter_id = self.env['ir.config_parameter'].sudo().get_param( - "send_statistics") - if parameter_id != 'True': + 'base_setup.send_statistics') + if parameter_id != 'true': return True try: result = self._get_sys_logs() diff --git a/flectra/addons/base/ir/ir_config_parameter.py b/flectra/addons/base/ir/ir_config_parameter.py index 08c6851b..121d2410 100644 --- a/flectra/addons/base/ir/ir_config_parameter.py +++ b/flectra/addons/base/ir/ir_config_parameter.py @@ -20,7 +20,6 @@ _default_parameters = { "database.uuid": lambda: pycompat.text_type(uuid.uuid1()), "database.create_date": fields.Datetime.now, "web.base.url": lambda: "http://localhost:%s" % config.get('http_port'), - "send_statistics": lambda: "True", }