From c79a80f86327247b662f79d17f991dea32f4e5b4 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Mon, 7 Jul 2014 19:56:10 +0200 Subject: [PATCH 1/7] add missing installable and move unported in __unported__ --- .../ir_config_parameter_viewer}/__init__.py | 0 .../ir_config_parameter_viewer}/__openerp__.py | 0 .../i18n/ir_config_parameter_viewer.pot | 0 .../ir_config_parameter_viewer}/ir_config_parameter_view.xml | 0 .../security_protector}/__init__.py | 0 .../security_protector}/__openerp__.py | 0 {security_protector => __unported__/security_protector}/data.xml | 0 .../security_protector}/i18n/security_protector.pot | 0 .../security_protector}/security_protector.py | 0 .../security_protector}/security_view.xml | 0 .../server_env_base_external_referentials}/__init__.py | 0 .../server_env_base_external_referentials}/__openerp__.py | 0 .../base_external_referentials.py | 0 .../i18n/server_env_base_external_referentials.pot | 0 cron_run_manually/__openerp__.py | 1 + email_template_template/__openerp__.py | 1 + web_context_tunnel/__openerp__.py | 1 + 17 files changed, 3 insertions(+) rename {ir_config_parameter_viewer => __unported__/ir_config_parameter_viewer}/__init__.py (100%) rename {ir_config_parameter_viewer => __unported__/ir_config_parameter_viewer}/__openerp__.py (100%) rename {ir_config_parameter_viewer => __unported__/ir_config_parameter_viewer}/i18n/ir_config_parameter_viewer.pot (100%) rename {ir_config_parameter_viewer => __unported__/ir_config_parameter_viewer}/ir_config_parameter_view.xml (100%) rename {security_protector => __unported__/security_protector}/__init__.py (100%) rename {security_protector => __unported__/security_protector}/__openerp__.py (100%) rename {security_protector => __unported__/security_protector}/data.xml (100%) rename {security_protector => __unported__/security_protector}/i18n/security_protector.pot (100%) rename {security_protector => __unported__/security_protector}/security_protector.py (100%) rename {security_protector => __unported__/security_protector}/security_view.xml (100%) rename {server_env_base_external_referentials => __unported__/server_env_base_external_referentials}/__init__.py (100%) rename {server_env_base_external_referentials => __unported__/server_env_base_external_referentials}/__openerp__.py (100%) rename {server_env_base_external_referentials => __unported__/server_env_base_external_referentials}/base_external_referentials.py (100%) rename {server_env_base_external_referentials => __unported__/server_env_base_external_referentials}/i18n/server_env_base_external_referentials.pot (100%) diff --git a/ir_config_parameter_viewer/__init__.py b/__unported__/ir_config_parameter_viewer/__init__.py similarity index 100% rename from ir_config_parameter_viewer/__init__.py rename to __unported__/ir_config_parameter_viewer/__init__.py diff --git a/ir_config_parameter_viewer/__openerp__.py b/__unported__/ir_config_parameter_viewer/__openerp__.py similarity index 100% rename from ir_config_parameter_viewer/__openerp__.py rename to __unported__/ir_config_parameter_viewer/__openerp__.py diff --git a/ir_config_parameter_viewer/i18n/ir_config_parameter_viewer.pot b/__unported__/ir_config_parameter_viewer/i18n/ir_config_parameter_viewer.pot similarity index 100% rename from ir_config_parameter_viewer/i18n/ir_config_parameter_viewer.pot rename to __unported__/ir_config_parameter_viewer/i18n/ir_config_parameter_viewer.pot diff --git a/ir_config_parameter_viewer/ir_config_parameter_view.xml b/__unported__/ir_config_parameter_viewer/ir_config_parameter_view.xml similarity index 100% rename from ir_config_parameter_viewer/ir_config_parameter_view.xml rename to __unported__/ir_config_parameter_viewer/ir_config_parameter_view.xml diff --git a/security_protector/__init__.py b/__unported__/security_protector/__init__.py similarity index 100% rename from security_protector/__init__.py rename to __unported__/security_protector/__init__.py diff --git a/security_protector/__openerp__.py b/__unported__/security_protector/__openerp__.py similarity index 100% rename from security_protector/__openerp__.py rename to __unported__/security_protector/__openerp__.py diff --git a/security_protector/data.xml b/__unported__/security_protector/data.xml similarity index 100% rename from security_protector/data.xml rename to __unported__/security_protector/data.xml diff --git a/security_protector/i18n/security_protector.pot b/__unported__/security_protector/i18n/security_protector.pot similarity index 100% rename from security_protector/i18n/security_protector.pot rename to __unported__/security_protector/i18n/security_protector.pot diff --git a/security_protector/security_protector.py b/__unported__/security_protector/security_protector.py similarity index 100% rename from security_protector/security_protector.py rename to __unported__/security_protector/security_protector.py diff --git a/security_protector/security_view.xml b/__unported__/security_protector/security_view.xml similarity index 100% rename from security_protector/security_view.xml rename to __unported__/security_protector/security_view.xml diff --git a/server_env_base_external_referentials/__init__.py b/__unported__/server_env_base_external_referentials/__init__.py similarity index 100% rename from server_env_base_external_referentials/__init__.py rename to __unported__/server_env_base_external_referentials/__init__.py diff --git a/server_env_base_external_referentials/__openerp__.py b/__unported__/server_env_base_external_referentials/__openerp__.py similarity index 100% rename from server_env_base_external_referentials/__openerp__.py rename to __unported__/server_env_base_external_referentials/__openerp__.py diff --git a/server_env_base_external_referentials/base_external_referentials.py b/__unported__/server_env_base_external_referentials/base_external_referentials.py similarity index 100% rename from server_env_base_external_referentials/base_external_referentials.py rename to __unported__/server_env_base_external_referentials/base_external_referentials.py diff --git a/server_env_base_external_referentials/i18n/server_env_base_external_referentials.pot b/__unported__/server_env_base_external_referentials/i18n/server_env_base_external_referentials.pot similarity index 100% rename from server_env_base_external_referentials/i18n/server_env_base_external_referentials.pot rename to __unported__/server_env_base_external_referentials/i18n/server_env_base_external_referentials.pot diff --git a/cron_run_manually/__openerp__.py b/cron_run_manually/__openerp__.py index 9fa6ed24a..eb53e939b 100644 --- a/cron_run_manually/__openerp__.py +++ b/cron_run_manually/__openerp__.py @@ -33,4 +33,5 @@ of the scheduler. """, 'depends': ['base'], 'data': ['view/ir_cron.xml'], + 'installable': True, } diff --git a/email_template_template/__openerp__.py b/email_template_template/__openerp__.py index 329915bc4..a193404c1 100644 --- a/email_template_template/__openerp__.py +++ b/email_template_template/__openerp__.py @@ -95,5 +95,6 @@ In your template template: 'view/email_template.xml', ], "license": 'AGPL-3', + 'installable': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/web_context_tunnel/__openerp__.py b/web_context_tunnel/__openerp__.py index 41519b664..3813782b6 100644 --- a/web_context_tunnel/__openerp__.py +++ b/web_context_tunnel/__openerp__.py @@ -88,5 +88,6 @@ https://github.com/openerpbrasil/l10n_br_core/compare/develop...feature%2Fsale-w ], 'css': [], 'auto_install': False, + 'installable': True, 'web_preload': False, } From 982a3492e3adb0a76b449758d9126df1e2e9261c Mon Sep 17 00:00:00 2001 From: "david.beal@akretion.com" Date: Fri, 11 Jul 2014 15:08:33 +0200 Subject: [PATCH 2/7] [ADD] config helper module --- configuration_helper/__init__.py | 22 ++++++ configuration_helper/__openerp__.py | 82 ++++++++++++++++++++ configuration_helper/config.py | 114 ++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+) create mode 100644 configuration_helper/__init__.py create mode 100644 configuration_helper/__openerp__.py create mode 100644 configuration_helper/config.py diff --git a/configuration_helper/__init__.py b/configuration_helper/__init__.py new file mode 100644 index 000000000..bfca433c9 --- /dev/null +++ b/configuration_helper/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: David BEAL +# Copyright 2014 Akretion +# +# 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 . +# +############################################################################## + +from . import config # noqa diff --git a/configuration_helper/__openerp__.py b/configuration_helper/__openerp__.py new file mode 100644 index 000000000..7ca0618fb --- /dev/null +++ b/configuration_helper/__openerp__.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: David BEAL +# Copyright 2014 Akretion +# +# 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 . +# +############################################################################## + +{ + 'name': 'Configuration Helper', + 'version': '0.8', + 'author': 'Akretion', + 'maintainer': 'Akretion', + 'category': 'server', + 'complexity': 'normal', + 'depends': ['base'], + 'description': """ +Configuration Helper +==================== + +*This module is intended for developer only. It does nothing used alone.* + +This module : + + * create automatically related fields in 'whatiwant.config.settings' + using those defined in 'res.company' : it avoid duplicated field definitions. + * company_id field with default value is created + * onchange_company_id is defined to update all related fields + * supported fields: char, text, integer, float, datetime, date, boolean, m2o + + +How to use +---------- + +.. code-block:: python + + from . company import ResCompany + + class WhatiwantClassSettings(orm.TransientModel): + _inherit = ['res.config.settings', 'abstract.config.settings'] + _name = 'whatiwant.config.settings' + # fields must be defined in ResCompany class + # related fields are automatically generated from previous definitions + _companyObject = ResCompany + + +Roadmap +------- + * support (or check support) for these field types : o2m, m2m, reference, property, selection + * automatically generate a default view for 'whatiwant.config.settings' (in --debug ?) + + +Contributors +------------ + +* David BEAL +* Sébastien BEAU +* Yannick Vaucher, Camptocamp, (code refactoring from his module 'delivery_carrier_label_postlogistics') + + """, + 'website': 'http://www.akretion.com/', + 'data': [ + ], + 'tests': [], + 'installable': True, + 'auto_install': False, + 'license': 'AGPL-3', + 'application': True, +} diff --git a/configuration_helper/config.py b/configuration_helper/config.py new file mode 100644 index 000000000..187d683ab --- /dev/null +++ b/configuration_helper/config.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: David BEAL, Copyright 2014 Akretion +# +# 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 . +# +############################################################################## +import re + +from openerp.osv import orm, fields + + +class AbstractConfigSettings(orm.AbstractModel): + _name = 'abstract.config.settings' + _description = 'Abstract configuration settings' + # prefix field name to differentiate fields in company with those in config + _prefix = 'setting_' + # this is the class name to import in your module + # (it should be ResCompany or res_company, depends of your code) + _companyObject = None + + def _filter_field(self, field_key): + """Inherit in your module to define for which company field + you don't want have a matching related field""" + return True + + def __init__(self, pool, cr): + super(AbstractConfigSettings, self).__init__(pool, cr) + if self._companyObject: + for field_key in self._companyObject._columns: + #allows to exclude some field + if self._filter_field(field_key): + args = ('company_id', field_key) + kwargs = { + 'string': self._companyObject._columns[field_key].string, + 'help': self._companyObject._columns[field_key].help, + 'type': self._companyObject._columns[field_key]._type, + } + if '_obj' in self._companyObject._columns[field_key].__dict__.keys(): + kwargs['relation'] = \ + self._companyObject._columns[field_key]._obj + if '_domain' in \ + self._companyObject._columns[field_key].__dict__.keys(): + kwargs['domain'] = \ + self._companyObject._columns[field_key]._domain + field_key = re.sub('^' + self._prefix, '', field_key) + self._columns[field_key] = \ + fields.related(*args, **kwargs) + + _columns = { + 'company_id': fields.many2one( + 'res.company', + 'Company', + required=True), + } + + def _default_company(self, cr, uid, context=None): + user = self.pool['res.users'].browse(cr, uid, uid, context=context) + return user.company_id.id + + _defaults = { + 'company_id': _default_company, + } + + def field_to_populate_as_related(self, cr, uid, field, company_cols, context=None): + """Only fields which comes from company with the right prefix + must be defined as related""" + if self._prefix + field in company_cols: + return True + return False + + def onchange_company_id(self, cr, uid, ids, company_id, context=None): + " update related fields " + values = {} + values['currency_id'] = False + if not company_id: + return {'value': values} + company_m = self.pool['res.company'] + company = company_m.browse( + cr, uid, company_id, context=context) + company_cols = company_m._columns.keys() + for field in self._columns: + if self.field_to_populate_as_related( + cr, uid, field, company_cols, context=context): + cpny_field = self._columns[field].arg[-1] + if self._columns[field]._type == 'many2one': + values[field] = company[cpny_field]['id'] or False + else: + values[field] = company[cpny_field] + return {'value': values} + + def create(self, cr, uid, values, context=None): + id = super(AbstractConfigSettings, self).create( + cr, uid, values, context=context) + # Hack: to avoid some nasty bug, related fields are not written + # upon record creation. Hence we write on those fields here. + vals = {} + for fname, field in self._columns.iteritems(): + if isinstance(field, fields.related) and fname in values: + vals[fname] = values[fname] + self.write(cr, uid, [id], vals, context) + return id From ceef79a487eb402c269dd579d64cda9625e0089b Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 11 Jul 2014 17:14:16 +0200 Subject: [PATCH 3/7] [PEP8] server_environment --- server_environment/serv_config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server_environment/serv_config.py b/server_environment/serv_config.py index 6d9181818..033cc91fe 100644 --- a/server_environment/serv_config.py +++ b/server_environment/serv_config.py @@ -23,7 +23,7 @@ import os import ConfigParser from lxml import etree -from openerp.osv import osv, fields, orm +from openerp.osv import fields, orm from openerp.tools.config import config as system_base_config from .system_info import get_server_environment @@ -46,12 +46,13 @@ if not system_base_config.get('running_env', False): ck_path = os.path.join(_dir, system_base_config['running_env']) -if not os.path.exists(ck_path) : +if not os.path.exists(ck_path): raise Exception( "Provided server environment does not exist, " "please add a folder %s" % ck_path ) + def setboolean(obj, attr, _bool=_boolean_states): """Replace the attribute with a boolean.""" res = _bool[getattr(obj, attr).lower()] @@ -115,7 +116,7 @@ class ServerConfiguration(orm.TransientModel): _conf_defaults = _Defaults() def __init__(self, pool, cr): - res = super(ServerConfiguration, self).__init__(pool, cr) + super(ServerConfiguration, self).__init__(pool, cr) self.running_env = system_base_config['running_env'] # Only show passwords in development self.show_passwords = self.running_env in ('dev',) @@ -187,7 +188,6 @@ class ServerConfiguration(orm.TransientModel): res['fields'] = xfields return res - def default_get(self, cr, uid, fields_list, context=None): res = {} for key in self._conf_defaults: From 176b7fdef4e6eafe514656773e98957dda86aba2 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Mon, 7 Jul 2014 19:39:41 +0200 Subject: [PATCH 4/7] add .travis.yml --- .travis.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..40cec99e3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +language: python +python: + - "2.7" + +virtualenv: + system_site_packages: true + +install: + - git clone https://github.com/OCA/maintainer-quality-tools.git $HOME/maintainer-quality-tools + - export PATH=$HOME/maintainer-quality-tools/travis:$PATH + - travis_install_nightly 7.0 + - pip install coveralls flake8 + - pip install python-ldap + +script: + - travis_run_flake8 + - travis_run_tests 7.0 + +after_success: + coveralls From 0a9354aeb0a526034688ca97de988f7b0aaabb72 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Mon, 7 Jul 2014 19:40:14 +0200 Subject: [PATCH 5/7] add .coveragerc --- .coveragerc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..277f2a902 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,15 @@ +[report] +include = + */OCA/server-tools/* + +omit = + */tests/* + *__init__.py + +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about null context checking + if context is None: From c9022a86c58cd2f830921aeebe52943bcb76885c Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Mon, 7 Jul 2014 20:07:13 +0200 Subject: [PATCH 6/7] add README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..140ba36b6 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +[![Build Status](https://travis-ci.org/OCA/server-tools.svg?branch=7.0)](https://travis-ci.org/OCA/server-tools) +[![Coverage Status](https://coveralls.io/repos/OCA/server-tools/badge.png?branch=7.0)](https://coveralls.io/r/OCA/server-tools?branch=7.0) + +Server Environment And Tools +============================ + +This project aim to deal with modules related to manage OpenERP server environment and provide useful tools. You'll find modules that: + + - Manage configuration depending on environment (devs, test, prod,..) + - Keep the security on update + - Manage email settings + -... From f3418af635bf758ce23ea06b7613723515d680f2 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 11 Jul 2014 16:51:01 +0200 Subject: [PATCH 7/7] add conf file --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 40cec99e3..32f023adc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,15 +6,16 @@ virtualenv: system_site_packages: true install: - - git clone https://github.com/OCA/maintainer-quality-tools.git $HOME/maintainer-quality-tools + - git clone https://github.com/yvaucher/maintainer-quality-tools.git $HOME/maintainer-quality-tools - export PATH=$HOME/maintainer-quality-tools/travis:$PATH - travis_install_nightly 7.0 - pip install coveralls flake8 - pip install python-ldap + - printf '[options]\n\nrunning_env = dev' > /tmp/odoo.cfg script: - travis_run_flake8 - - travis_run_tests 7.0 + - travis_run_tests 7.0 /tmp/odoo.cfg after_success: coveralls