Browse Source

Merge branch '7.0'

pull/14/head
Stéphane Bidoul 11 years ago
parent
commit
58f7c295c9
  1. 15
      .coveragerc
  2. 21
      .travis.yml
  3. 12
      README.md
  4. 0
      __unported__/ir_config_parameter_viewer/__init__.py
  5. 0
      __unported__/ir_config_parameter_viewer/__openerp__.py
  6. 0
      __unported__/ir_config_parameter_viewer/i18n/ir_config_parameter_viewer.pot
  7. 0
      __unported__/ir_config_parameter_viewer/ir_config_parameter_view.xml
  8. 0
      __unported__/security_protector/__init__.py
  9. 0
      __unported__/security_protector/__openerp__.py
  10. 0
      __unported__/security_protector/data.xml
  11. 0
      __unported__/security_protector/i18n/security_protector.pot
  12. 0
      __unported__/security_protector/security_protector.py
  13. 0
      __unported__/security_protector/security_view.xml
  14. 0
      __unported__/server_env_base_external_referentials/__init__.py
  15. 0
      __unported__/server_env_base_external_referentials/__openerp__.py
  16. 0
      __unported__/server_env_base_external_referentials/base_external_referentials.py
  17. 0
      __unported__/server_env_base_external_referentials/i18n/server_env_base_external_referentials.pot
  18. 22
      configuration_helper/__init__.py
  19. 82
      configuration_helper/__openerp__.py
  20. 114
      configuration_helper/config.py
  21. 1
      cron_run_manually/__openerp__.py
  22. 1
      email_template_template/__openerp__.py
  23. 6
      server_environment/serv_config.py
  24. 1
      web_context_tunnel/__openerp__.py

15
.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:

21
.travis.yml

@ -0,0 +1,21 @@
language: python
python:
- "2.7"
virtualenv:
system_site_packages: true
install:
- 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 /tmp/odoo.cfg
after_success:
coveralls

12
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
-...

0
ir_config_parameter_viewer/__init__.py → __unported__/ir_config_parameter_viewer/__init__.py

0
ir_config_parameter_viewer/__openerp__.py → __unported__/ir_config_parameter_viewer/__openerp__.py

0
ir_config_parameter_viewer/i18n/ir_config_parameter_viewer.pot → __unported__/ir_config_parameter_viewer/i18n/ir_config_parameter_viewer.pot

0
ir_config_parameter_viewer/ir_config_parameter_view.xml → __unported__/ir_config_parameter_viewer/ir_config_parameter_view.xml

0
security_protector/__init__.py → __unported__/security_protector/__init__.py

0
security_protector/__openerp__.py → __unported__/security_protector/__openerp__.py

0
security_protector/data.xml → __unported__/security_protector/data.xml

0
security_protector/i18n/security_protector.pot → __unported__/security_protector/i18n/security_protector.pot

0
security_protector/security_protector.py → __unported__/security_protector/security_protector.py

0
security_protector/security_view.xml → __unported__/security_protector/security_view.xml

0
server_env_base_external_referentials/__init__.py → __unported__/server_env_base_external_referentials/__init__.py

0
server_env_base_external_referentials/__openerp__.py → __unported__/server_env_base_external_referentials/__openerp__.py

0
server_env_base_external_referentials/base_external_referentials.py → __unported__/server_env_base_external_referentials/base_external_referentials.py

0
server_env_base_external_referentials/i18n/server_env_base_external_referentials.pot → __unported__/server_env_base_external_referentials/i18n/server_env_base_external_referentials.pot

22
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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import config # noqa

82
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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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 <david.beal@akretion.com>
* Sébastien BEAU <sebastien.beau@akretion.com>
* 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,
}

114
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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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

1
cron_run_manually/__openerp__.py

@ -33,4 +33,5 @@ of the scheduler.
""", """,
'depends': ['base'], 'depends': ['base'],
'data': ['view/ir_cron.xml'], 'data': ['view/ir_cron.xml'],
'installable': True,
} }

1
email_template_template/__openerp__.py

@ -95,5 +95,6 @@ In your template template:
'view/email_template.xml', 'view/email_template.xml',
], ],
"license": 'AGPL-3', "license": 'AGPL-3',
'installable': True,
} }
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

6
server_environment/serv_config.py

@ -23,7 +23,7 @@ import os
import ConfigParser import ConfigParser
from lxml import etree 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 openerp.tools.config import config as system_base_config
from .system_info import get_server_environment from .system_info import get_server_environment
@ -52,6 +52,7 @@ if not os.path.exists(ck_path) :
"please add a folder %s" % ck_path "please add a folder %s" % ck_path
) )
def setboolean(obj, attr, _bool=_boolean_states): def setboolean(obj, attr, _bool=_boolean_states):
"""Replace the attribute with a boolean.""" """Replace the attribute with a boolean."""
res = _bool[getattr(obj, attr).lower()] res = _bool[getattr(obj, attr).lower()]
@ -115,7 +116,7 @@ class ServerConfiguration(orm.TransientModel):
_conf_defaults = _Defaults() _conf_defaults = _Defaults()
def __init__(self, pool, cr): 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'] self.running_env = system_base_config['running_env']
# Only show passwords in development # Only show passwords in development
self.show_passwords = self.running_env in ('dev',) self.show_passwords = self.running_env in ('dev',)
@ -187,7 +188,6 @@ class ServerConfiguration(orm.TransientModel):
res['fields'] = xfields res['fields'] = xfields
return res return res
def default_get(self, cr, uid, fields_list, context=None): def default_get(self, cr, uid, fields_list, context=None):
res = {} res = {}
for key in self._conf_defaults: for key in self._conf_defaults:

1
web_context_tunnel/__openerp__.py

@ -88,5 +88,6 @@ https://github.com/openerpbrasil/l10n_br_core/compare/develop...feature%2Fsale-w
], ],
'css': [], 'css': [],
'auto_install': False, 'auto_install': False,
'installable': True,
'web_preload': False, 'web_preload': False,
} }
Loading…
Cancel
Save