Created
July 1, 2017 20:41
-
-
Save litnimax/b6581d6ded1a2745ae815b6710dce399 to your computer and use it in GitHub Desktop.
Odoo settings ir.config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from openerp import models, fields, api | |
| PARAMS = [ | |
| ("login", "apps_odoo_com.login"), | |
| ("password", "apps_odoo_com.password"), | |
| ] | |
| class Settings(models.TransientModel): | |
| _name = 'apps_odoo_com.settings' | |
| _inherit = 'res.config.settings' | |
| login = fields.Char("Login") | |
| password = fields.Char("Password") | |
| @api.multi | |
| def set_params(self): | |
| self.ensure_one() | |
| for field_name, key_name in PARAMS: | |
| value = getattr(self, field_name, '').strip() | |
| self.env['ir.config_parameter'].set_param(key_name, value) | |
| def get_default_params(self, cr, uid, fields, context=None): | |
| res = {} | |
| for field_name, key_name in PARAMS: | |
| res[field_name] = self.env['ir.config_parameter'].get_param(key_name, '').strip() | |
| return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment