From e14eb006b063e8f0719a5236da77c46c08fd7f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?= Date: Wed, 16 Nov 2011 11:07:41 +0100 Subject: [PATCH] [MRG] From last LP trunk (lp:c2c-addons/6.1 rev 13) --- .../__init__.py | 21 +++++++++ .../__openerp__.py | 45 ++++++++++++++++++ .../base_external_referentials.py | 47 +++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 server_env_base_external_referentials/__init__.py create mode 100644 server_env_base_external_referentials/__openerp__.py create mode 100644 server_env_base_external_referentials/base_external_referentials.py diff --git a/server_env_base_external_referentials/__init__.py b/server_env_base_external_referentials/__init__.py new file mode 100644 index 000000000..74e3c6a64 --- /dev/null +++ b/server_env_base_external_referentials/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Guewen Baconnier. Copyright Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +import base_external_referentials \ No newline at end of file diff --git a/server_env_base_external_referentials/__openerp__.py b/server_env_base_external_referentials/__openerp__.py new file mode 100644 index 000000000..5c8eb7442 --- /dev/null +++ b/server_env_base_external_referentials/__openerp__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Guewen Baconnier. Copyright Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + "name": "Server environment for base_external_referential", + "version": "1.0", + "depends": ["base", 'server_environment', 'base_external_referentials'], + "author": "Camptocamp", + "description": """This module is based on the server_environment module to use files for configuration. +Thus we can have a different file for each environment (dev, test, staging, prod). +This module define the config variables for the base_external_referential module. +In the configuration file, you can configure the url, login and password of the referentials + +Exemple of the section to put in the configuration file : + +[external_referential.name_of_my_external_referential] +location = http://localhost/magento/ +apiusername = my_api_login +apipass = my_api_password + """, + "website": "http://www.camptocamp.com", + "category": "Tools", + "init_xml": [], + "demo_xml": [], + "update_xml": [], + "installable": True, + "active": False, +} diff --git a/server_env_base_external_referentials/base_external_referentials.py b/server_env_base_external_referentials/base_external_referentials.py new file mode 100644 index 000000000..735306fdb --- /dev/null +++ b/server_env_base_external_referentials/base_external_referentials.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Guewen Baconnier. Copyright Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields, osv +from server_environment import serv_config + + +class external_referential(osv.osv): + _inherit = 'external.referential' + + def _get_environment_config_by_name(self, cr, uid, ids, field_names, arg, context): + values = {} + for referential in self.browse(cr, uid, ids, context): + values[referential.id] = {} + for field_name in field_names: + section_name = '.'.join((self._name.replace('.', '_'), referential.name)) + value = serv_config.get(section_name, field_name) + values[referential.id].update({field_name: value}) + return values + + _columns = { + 'location': fields.function(_get_environment_config_by_name, type='char', size=200, + method=True, string='Location', multi='connection_config'), + 'apiusername': fields.function(_get_environment_config_by_name, type='char', size=64, + method=True, string='User Name', multi='connection_config'), + 'apipass': fields.function(_get_environment_config_by_name, type='char', size=64, + method=True, string='Password', multi='connection_config'), + } + +external_referential()