Browse Source
Merge branch '7.0' of https://github.com/OCA/server-tools into 7.0-module_parent_dependencies
pull/8/head
Merge branch '7.0' of https://github.com/OCA/server-tools into 7.0-module_parent_dependencies
pull/8/head
Sylvain LE GAL
10 years ago
61 changed files with 1317 additions and 642 deletions
-
15.coveragerc
-
25.travis.yml
-
12README.md
-
2auth_admin_passkey/__openerp__.py
-
2auth_admin_passkey/model/res_users.py
-
3auth_from_http_basic/__init__.py
-
2base_external_dbsource/__openerp__.py
-
22base_external_dbsource/base_external_dbsource.py
-
6base_external_dbsource/test/dbsource_connect.yml
-
7base_optional_quick_create/__openerp__.py
-
15base_optional_quick_create/model.py
-
22configuration_helper/__init__.py
-
85configuration_helper/__openerp__.py
-
118configuration_helper/config.py
-
2cron_run_manually/__openerp__.py
-
11cron_run_manually/model/ir_cron.py
-
1dbfilter_from_header/__init__.py
-
18dbfilter_from_header/__openerp__.py
-
4disable_openerp_online/data/ir_ui_menu.xml
-
31email_template_template/__openerp__.py
-
6email_template_template/model/email_template.py
-
2fetchmail_attach_from_folder/__openerp__.py
-
8fetchmail_attach_from_folder/match_algorithm/base.py
-
15fetchmail_attach_from_folder/match_algorithm/email_domain.py
-
9fetchmail_attach_from_folder/match_algorithm/email_exact.py
-
23fetchmail_attach_from_folder/match_algorithm/openerp_standard.py
-
87fetchmail_attach_from_folder/model/fetchmail_server.py
-
99fetchmail_attach_from_folder/model/fetchmail_server_folder.py
-
97fetchmail_attach_from_folder/wizard/attach_mail_manually.py
-
29import_odbc/__openerp__.py
-
159import_odbc/import_odbc.py
-
15mail_environment/__openerp__.py
-
230mail_environment/env_mail.py
-
7mass_editing/__init__.py
-
15mass_editing/mass_editing.py
-
6mass_editing/wizard/__init__.py
-
3scheduler_error_mailer/__openerp__.py
-
36scheduler_error_mailer/ir_cron.py
-
19server_environment/serv_config.py
-
2server_environment/system_info.py
-
2server_environment_files/__init__.py
-
2super_calendar/__init__.py
-
39super_calendar/__openerp__.py
-
BINsuper_calendar/data/meetings.png
-
BINsuper_calendar/data/month_calendar.png
-
BINsuper_calendar/data/phone_calls.png
-
BINsuper_calendar/data/week_calendar.png
-
185super_calendar/super_calendar.py
-
11tree_view_record_id/__init__.py
-
58tree_view_record_id/__openerp__.py
-
64tree_view_record_id/orm.py
-
41users_ldap_groups/__openerp__.py
-
138users_ldap_groups/users_ldap_groups.py
-
51users_ldap_groups/users_ldap_groups_operators.py
-
30users_ldap_mail/__openerp__.py
-
26users_ldap_mail/users_ldap_model.py
-
11users_ldap_populate/__openerp__.py
-
8users_ldap_populate/model/populate_wizard.py
-
14users_ldap_populate/model/users_ldap.py
-
6web_context_tunnel/__openerp__.py
-
3web_context_tunnel/static/src/js/context_tunnel.js
@ -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: |
@ -0,0 +1,25 @@ |
|||
language: python |
|||
|
|||
python: |
|||
- "2.7" |
|||
|
|||
env: |
|||
- VERSION="7.0" ODOO_REPO="odoo/odoo" |
|||
- VERSION="7.0" ODOO_REPO="OCA/OCB" |
|||
|
|||
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 ${VERSION} |
|||
- sudo pip install python-ldap |
|||
- printf '[options]\n\nrunning_env = dev' > ${HOME}/.openerp_serverrc |
|||
|
|||
script: |
|||
- travis_run_flake8 |
|||
- travis_run_tests ${VERSION} |
|||
|
|||
after_success: |
|||
coveralls |
@ -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,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 |
@ -0,0 +1,85 @@ |
|||
# -*- 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, |
|||
} |
@ -0,0 +1,118 @@ |
|||
# -*- 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: |
|||
company_cols = self._companyObject._columns |
|||
for field_key in company_cols: |
|||
# allows to exclude some field |
|||
if self._filter_field(field_key): |
|||
args = ('company_id', field_key) |
|||
kwargs = { |
|||
'string': company_cols[field_key].string, |
|||
'help': company_cols[field_key].help, |
|||
'type': company_cols[field_key]._type, |
|||
} |
|||
if '_obj' in company_cols[field_key].__dict__: |
|||
kwargs['relation'] = \ |
|||
company_cols[field_key]._obj |
|||
if '_domain' in \ |
|||
company_cols[field_key].__dict__: |
|||
kwargs['domain'] = \ |
|||
company_cols[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,7 +1,7 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
<delete model="ir.ui.menu" id="base.module_mi" /> |
|||
<delete model="ir.ui.menu" id="base.menu_module_updates" /> |
|||
<delete model="ir.ui.menu" search="[('parent_id', '=', ref('base.menu_management')), ('name', '=', 'Apps')]" /> |
|||
<delete model="ir.ui.menu" search="[('parent_id', '=', ref('base.menu_management')), ('name', '=', 'Updates')]" /> |
|||
</data> |
|||
</openerp> |
After Width: 962 | Height: 374 | Size: 25 KiB |
After Width: 1064 | Height: 536 | Size: 70 KiB |
After Width: 960 | Height: 322 | Size: 26 KiB |
After Width: 1062 | Height: 566 | Size: 78 KiB |
@ -0,0 +1,11 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# licence AGPL version 3 or later |
|||
# see licence in __openerp__.py or http://www.gnu.org/licenses/agpl-3.0.txt |
|||
# Copyright (C) 2014 Akretion (http://www.akretion.com). |
|||
# @author David BEAL <david.beal@akretion.com> |
|||
# |
|||
############################################################################## |
|||
|
|||
import orm |
@ -0,0 +1,58 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################### |
|||
# |
|||
# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. |
|||
# All Rights Reserved |
|||
# @author David BEAL <david.beal@akretion.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/>. |
|||
# |
|||
############################################################################### |
|||
|
|||
{ |
|||
'name': 'Tree View Record Id', |
|||
'version': '0.1', |
|||
'category': 'Other modules', |
|||
'sequence': 10, |
|||
'author': 'Akretion', |
|||
'summary': "Adds id field to tree views", |
|||
'description': """ |
|||
Adds Id field in all tree views of any modules/models, except: |
|||
|
|||
* Arborescent tree views like 'Products by Category', 'Chart of accounts', etc. |
|||
* Tree views (like in wizard 'Change password') built on transient models |
|||
which don't have this column in their table. |
|||
|
|||
Id field is the primary key of standard sql tables |
|||
defined by the orm (Odoo model). |
|||
""", |
|||
'website': 'http://www.akretion.com', |
|||
'depends': [ |
|||
'base', |
|||
], |
|||
'data': [ |
|||
], |
|||
'demo': [ |
|||
], |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
'images': [ |
|||
], |
|||
'css': [ |
|||
], |
|||
'js': [ |
|||
], |
|||
'qweb': [ |
|||
], |
|||
} |
@ -0,0 +1,64 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# licence AGPL version 3 or later |
|||
# see licence in __openerp__.py or http://www.gnu.org/licenses/agpl-3.0.txt |
|||
# Copyright (C) 2014 Akretion (http://www.akretion.com). |
|||
# @author David BEAL <david.beal@akretion.com> |
|||
# |
|||
############################################################################## |
|||
|
|||
from openerp.osv import orm |
|||
from lxml import etree |
|||
import os |
|||
|
|||
""" procedural code is executed even if the module is not installed |
|||
|
|||
TRY TO SWITCH to _register_hook() in the model to avoid |
|||
execution when not installed in V 8.0 version |
|||
|
|||
""" |
|||
|
|||
|
|||
module_name = os.path.basename(os.path.dirname(os.path.abspath(__file__))) |
|||
|
|||
DUMMY_MODEL = 'module.%s.installed' % module_name.replace('_', '.') |
|||
|
|||
|
|||
class DummyModel(orm.Model): |
|||
""" Allow to check if module is installed or not |
|||
in fields_view_get method to avoid code execution if not |
|||
Only executed if the module is installed |
|||
""" |
|||
_name = DUMMY_MODEL |
|||
|
|||
|
|||
fields_view_get_orginal = orm.BaseModel.fields_view_get |
|||
|
|||
|
|||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', |
|||
context=None, toolbar=False, submenu=False): |
|||
res = fields_view_get_orginal( |
|||
self, cr, uid, view_id=view_id, view_type=view_type, context=context, |
|||
toolbar=toolbar, submenu=submenu) |
|||
if view_type == 'tree': |
|||
compatible_tree = res.get('field_parent', True) is False |
|||
# Tree views with res['field_parent'] different from False |
|||
# looks like 'Products by Category'. |
|||
# We don't modify these views |
|||
# to avoid to break them (js error) |
|||
if '_transient_max_count' in self.pool[res['model']].__dict__.keys(): |
|||
# model with '_transient_max_count' key are transient model |
|||
# transient models haven't 'id' column in mostly case |
|||
compatible_tree = False |
|||
if compatible_tree and DUMMY_MODEL in self.pool.models.keys(): |
|||
doc = etree.XML(res['arch']) |
|||
if (doc.xpath("//tree") and |
|||
len(doc.xpath("//field[@name='id']"))) == 0: |
|||
node = doc.xpath("//tree")[0] |
|||
node.append(etree.Element("field", name="id", string="Id")) |
|||
res['arch'] = etree.tostring(node) |
|||
return res |
|||
|
|||
|
|||
orm.BaseModel.fields_view_get = fields_view_get |
Write
Preview
Loading…
Cancel
Save
Reference in new issue