1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- # -*- coding: utf-8 -*-
- ##############################################################################
- #
- # BizzAppDev
- # Copyright (C) 2015-TODAY bizzappdev(<http://www.bizzappdev.com>).
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Affero General Public License as
- # published by the Free Software Foundation, either version 3 of the
- # License, or (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- ##############################################################################
- import openerp
- from openerp import SUPERUSER_ID, api, models
- from openerp.tools import config
- DEVELOP = True
- TEST = False
- class res_users(models.Model):
- _inherit = 'res.users'
- @api.model
- def set_test_password(self):
- users = self.search([])
- for user in users:
- user.write({'password': 'Qw3r7y'})
- return True
- def __set_from_config_test(self, db):
- cr = openerp.registry(db).cursor()
- config_parameters = self.pool.get("ir.config_parameter")
- if DEVELOP:
- config_parameters.set_param(
- cr, SUPERUSER_ID, "develop", DEVELOP)
- if TEST:
- config_parameters.set_param(
- cr, SUPERUSER_ID, "test", TEST)
- if not config.get('test'):
- config['test'] = {}
- if not config.get('develop'):
- config['develop'] = {}
- if db not in config['test']:
- ir_config_val = self.pool.get("ir.config_parameter").get_param(
- cr, SUPERUSER_ID, "test", default=None)
- config['test'][db] = ir_config_val
- if db not in config['develop']:
- ir_config_val = self.pool.get("ir.config_parameter").get_param(
- cr, SUPERUSER_ID, "develop", default=None)
- config['develop'][db] = ir_config_val
- cr.close()
- def check(self, db, uid, passwd):
- self.__set_from_config_test(db)
- return super(res_users, self).check(db, uid, passwd)
- def authenticate(self, db, login, password, user_agent_env):
- self.__set_from_config_test(db)
- return super(res_users, self).authenticate(db, login, password,
- user_agent_env)
- res_users()
- # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|