Browse Source

Merge pull request #12 from yvaucher/7.0-fix-flakes8

7.0 fix flakes8 (partial)
pull/22/head
Sandy 10 years ago
parent
commit
551b5eaeb5
  1. 7
      base_optional_quick_create/__openerp__.py
  2. 1
      base_optional_quick_create/model.py
  3. 1
      cron_run_manually/model/ir_cron.py
  4. 1
      dbfilter_from_header/__init__.py
  5. 29
      import_odbc/__openerp__.py
  6. 2
      import_odbc/import_odbc.py
  7. 7
      mail_environment/__openerp__.py
  8. 53
      mail_environment/env_mail.py
  9. 4
      mass_editing/__init__.py
  10. 3
      mass_editing/wizard/__init__.py
  11. 18
      scheduler_error_mailer/ir_cron.py

7
base_optional_quick_create/__openerp__.py

@ -24,8 +24,11 @@
'category': 'Tools', 'category': 'Tools',
'summary': "Avoid 'quick create' on m2o fields, on a 'by model' basis", 'summary': "Avoid 'quick create' on m2o fields, on a 'by model' basis",
'description': """ 'description': """
This module allows to avoid to 'quick create' new records, through many2one fields, for a specific model.
You can configure which models should allow 'quick create'. When specified, the 'quick create' option will always open the standard create form.
This module allows to avoid to 'quick create' new records, through many2one
fields, for a specific model.
You can configure which models should allow 'quick create'.
When specified, the 'quick create' option will always open the standard create
form.
Got the idea from https://twitter.com/nbessi/status/337869826028605441 Got the idea from https://twitter.com/nbessi/status/337869826028605441
""", """,

1
base_optional_quick_create/model.py

@ -22,6 +22,7 @@ from openerp.osv import orm, fields
from openerp import SUPERUSER_ID from openerp import SUPERUSER_ID
from openerp.tools.translate import _ from openerp.tools.translate import _
class ir_model(orm.Model): class ir_model(orm.Model):
_inherit = 'ir.model' _inherit = 'ir.model'

1
cron_run_manually/model/ir_cron.py

@ -27,6 +27,7 @@ from openerp.tools import SUPERUSER_ID
from openerp.tools.translate import _ from openerp.tools.translate import _
from openerp.tools.safe_eval import safe_eval from openerp.tools.safe_eval import safe_eval
class irCron(orm.Model): class irCron(orm.Model):
_inherit = 'ir.cron' _inherit = 'ir.cron'

1
dbfilter_from_header/__init__.py

@ -23,6 +23,7 @@ from openerp.addons.web.controllers import main as web_main
db_list_org = web_main.db_list db_list_org = web_main.db_list
def db_list(req, force=False): def db_list(req, force=False):
db_filter = req.httprequest.environ.get('HTTP_X_OPENERP_DBFILTER', '.*') db_filter = req.httprequest.environ.get('HTTP_X_OPENERP_DBFILTER', '.*')
dbs = db_list_org(req, force=force) dbs = db_list_org(req, force=force)

29
import_odbc/__openerp__.py

@ -29,11 +29,21 @@ Import data directly from other databases.
Installed in the Administration module, menu Configuration -> Import from SQL. Installed in the Administration module, menu Configuration -> Import from SQL.
Features: Features:
* Fetched data from the databases are used to build lines equivalent to regular import files. These are imported using the standard "import_data()" ORM method, benefiting from all its features, including xml_ids.
* Each table import is defined by an SQL statement, used to build the equivalent for an import file. Each column's name should match the column names you would use in an import file. The first column must provide an unique identifier for the record, and will be used to build its xml_id.
* SQL columns named "none" are ignored. This can be used for the first column of the SQL, so that it's used to build the XML Id but it's not imported to any OpenERP field.
* The last sync date is the last successfull execution can be used in the SQL using "%(sync)s", or ":sync" in the case of Oracle.
* When errors are found, only the record with the error fails import. The other correct records are commited. However, the "last sync date" will only be automaticaly updated when no errors are found.
* Fetched data from the databases are used to build lines equivalent to
regular import files. These are imported using the standard "import_data()"
ORM method, benefiting from all its features, including xml_ids.
* Each table import is defined by an SQL statement, used to build the
equivalent for an import file. Each column's name should match the column
names you would use in an import file. The first column must provide an
unique identifier for the record, and will be used to build its xml_id.
* SQL columns named "none" are ignored. This can be used for the first column
of the SQL, so that it's used to build the XML Id but it's not imported to
any OpenERP field.
* The last sync date is the last successfull execution can be used in the SQL
using "%(sync)s", or ":sync" in the case of Oracle.
* When errors are found, only the record with the error fails import. The
other correct records are commited. However, the "last sync date" will only
be automaticaly updated when no errors are found.
* The import execution can be scheduled to run automatically. * The import execution can be scheduled to run automatically.
Examples: Examples:
@ -54,9 +64,12 @@ Examples:
WHERE DATE_CHANGED >= %(sync)s WHERE DATE_CHANGED >= %(sync)s
Improvements ideas waiting for a contributor: Improvements ideas waiting for a contributor:
* Allow to import many2one fields (currently not supported). Done by adding a second SQL sentence to get child record list?
* Allow "import sets" that can be executed at different time intervals using different scheduler jobs.
* Allow to inactivate/delete OpenERP records when not present in an SQL result set.
* Allow to import many2one fields (currently not supported). Done by adding a
second SQL sentence to get child record list?
* Allow "import sets" that can be executed at different time intervals using
different scheduler jobs.
* Allow to inactivate/delete OpenERP records when not present in an SQL
result set.
Contributors Contributors
============ ============

2
import_odbc/import_odbc.py

@ -214,5 +214,3 @@ class import_odbc_dbtable(orm.Model):
'res_id': new_create_id, 'res_id': new_create_id,
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
} }
#EOF

7
mail_environment/__openerp__.py

@ -26,8 +26,10 @@
'description': """ 'description': """
Extend mail and fetch mail with server environment module. Extend mail and fetch mail with server environment module.
In config files, sections outgoint_mail and incoming_mails are default values for all Outgoing Mail Servers and Fetchmail Servers.
For each server, you can (re)define values with a section named "outgoing_mail.resource_name" where resource_name is the name of your server.
In config files, sections outgoint_mail and incoming_mails are default values
for all Outgoing Mail Servers and Fetchmail Servers.
For each server, you can (re)define values with a section named
"outgoing_mail.resource_name" where resource_name is the name of your server.
Exemple of config file : Exemple of config file :
@ -64,4 +66,3 @@ password = openerp
'installable': True, 'installable': True,
'active': False, 'active': False,
} }
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

53
mail_environment/env_mail.py

@ -52,34 +52,39 @@ class IrMail(osv.osv):
return res return res
_columns = { _columns = {
'smtp_host': fields.function(_get_smtp_conf,
'smtp_host': fields.function(
_get_smtp_conf,
method=True, method=True,
string='SMTP Server', string='SMTP Server',
type="char", type="char",
multi='outgoing_mail_config', multi='outgoing_mail_config',
size=128), size=128),
'smtp_port': fields.function(_get_smtp_conf,
'smtp_port': fields.function(
_get_smtp_conf,
method=True, method=True,
string='SMTP Port', string='SMTP Port',
type="integer", type="integer",
multi='outgoing_mail_config', multi='outgoing_mail_config',
help="SMTP Port. Usually 465 for SSL, and 25 or 587 for other cases.", help="SMTP Port. Usually 465 for SSL, and 25 or 587 for other cases.",
size=5), size=5),
'smtp_user': fields.function(_get_smtp_conf,
'smtp_user': fields.function(
_get_smtp_conf,
method=True, method=True,
string='Username', string='Username',
type="char", type="char",
multi='outgoing_mail_config', multi='outgoing_mail_config',
help="Optional username for SMTP authentication", help="Optional username for SMTP authentication",
size=64), size=64),
'smtp_pass': fields.function(_get_smtp_conf,
'smtp_pass': fields.function(
_get_smtp_conf,
method=True, method=True,
string='Password', string='Password',
type="char", type="char",
multi='outgoing_mail_config', multi='outgoing_mail_config',
help="Optional password for SMTP authentication", help="Optional password for SMTP authentication",
size=64), size=64),
'smtp_encryption' :fields.function(_get_smtp_conf,
'smtp_encryption': fields.function(
_get_smtp_conf,
method=True, method=True,
string='smtp_encryption', string='smtp_encryption',
type="char", type="char",
@ -108,13 +113,15 @@ class FetchmailServer(osv.osv):
key_types = {'port': int, key_types = {'port': int,
'is_ssl': lambda a: bool(int(a)), 'is_ssl': lambda a: bool(int(a)),
'attach': lambda a: bool(int(a)), 'attach': lambda a: bool(int(a)),
'original': lambda a: bool(int(a)),}
'original': lambda a: bool(int(a)),
}
# default vals # default vals
config_vals = {'port': 993, config_vals = {'port': 993,
'is_ssl': 0, 'is_ssl': 0,
'attach': 0, 'attach': 0,
'original': 0}
'original': 0,
}
if serv_config.has_section(global_section_name): if serv_config.has_section(global_section_name):
config_vals.update(serv_config.items(global_section_name)) config_vals.update(serv_config.items(global_section_name))
@ -152,19 +159,22 @@ class FetchmailServer(osv.osv):
return [('id', 'in', result_ids)] return [('id', 'in', result_ids)]
_columns = { _columns = {
'server': fields.function(_get_incom_conf,
'server': fields.function(
_get_incom_conf,
method=True, method=True,
string='Server', string='Server',
type="char", type="char",
multi='income_mail_config', multi='income_mail_config',
size=256, help="Hostname or IP of the mail server"), size=256, help="Hostname or IP of the mail server"),
'port': fields.function(_get_incom_conf,
'port': fields.function(
_get_incom_conf,
method=True, method=True,
string='Port', string='Port',
type="integer", type="integer",
multi='income_mail_config', multi='income_mail_config',
help="Hostname or IP of the mail server"), help="Hostname or IP of the mail server"),
'type': fields.function(_get_incom_conf,
'type': fields.function(
_get_incom_conf,
method=True, method=True,
string='Type', string='Type',
type="char", type="char",
@ -172,34 +182,41 @@ class FetchmailServer(osv.osv):
fnct_search=_type_search, fnct_search=_type_search,
size=64, size=64,
help="pop, imap, local"), help="pop, imap, local"),
'is_ssl': fields.function(_get_incom_conf,
'is_ssl': fields.function(
_get_incom_conf,
method=True, method=True,
string='Is SSL', string='Is SSL',
type="boolean", type="boolean",
multi='income_mail_config', multi='income_mail_config',
help='Connections are encrypted with SSL/TLS through' help='Connections are encrypted with SSL/TLS through'
' a dedicated port (default: IMAPS=993, POP3S=995)'), ' a dedicated port (default: IMAPS=993, POP3S=995)'),
'attach': fields.function(_get_incom_conf,
'attach': fields.function(
_get_incom_conf,
method=True, method=True,
string='Keep Attachments', string='Keep Attachments',
type="boolean", type="boolean",
multi='income_mail_config', multi='income_mail_config',
help="Whether attachments should be downloaded. " help="Whether attachments should be downloaded. "
"If not enabled, incoming emails will be stripped of any attachments before being processed"),
'original': fields.function(_get_incom_conf,
"If not enabled, incoming emails will be stripped of any "
"attachments before being processed"),
'original': fields.function(
_get_incom_conf,
method=True, method=True,
string='Keep Original', string='Keep Original',
type="boolean", type="boolean",
multi='income_mail_config', multi='income_mail_config',
help="Whether a full original copy of each email should be kept for reference"
"and attached to each processed message. This will usually double the size of your message database."),
'user': fields.function(_get_incom_conf,
help="Whether a full original copy of each email should be kept "
"for reference and attached to each processed message. This "
"will usually double the size of your message database."),
'user': fields.function(
_get_incom_conf,
method=True, method=True,
string='Username', string='Username',
type="char", type="char",
multi='income_mail_config', multi='income_mail_config',
size=64), size=64),
'password': fields.function(_get_incom_conf,
'password': fields.function(
_get_incom_conf,
method=True, method=True,
string='password', string='password',
type="char", type="char",

4
mass_editing/__init__.py

@ -18,9 +18,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/> # along with this program. If not, see <http://www.gnu.org/licenses/>
# #
############################################################################## ##############################################################################
import mass_editing import mass_editing
import wizard import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

3
mass_editing/wizard/__init__.py

@ -18,7 +18,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/> # along with this program. If not, see <http://www.gnu.org/licenses/>
# #
############################################################################## ##############################################################################
import mass_editing_wizard import mass_editing_wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

18
scheduler_error_mailer/ir_cron.py

@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
#################################################################################
##############################################################################
# #
# Scheduler Error Mailer module for OpenERP # Scheduler Error Mailer module for OpenERP
# Copyright (C) 2012-2013 Akretion (http://www.akretion.com/) # Copyright (C) 2012-2013 Akretion (http://www.akretion.com/)
@ -28,20 +28,21 @@ import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class ir_cron(orm.Model): class ir_cron(orm.Model):
_inherit = "ir.cron" _inherit = "ir.cron"
_columns = { _columns = {
'email_template': fields.many2one('email.template',
'email_template': fields.many2one(
'email.template',
'Error E-mail Template', 'Error E-mail Template',
help="Select the email template that will be sent when this scheduler fails."), help="Select the email template that will be sent when this scheduler fails."),
} }
def _handle_callback_exception(self, cr, uid, model_name, method_name, args, job_id, job_exception): def _handle_callback_exception(self, cr, uid, model_name, method_name, args, job_id, job_exception):
res = super(ir_cron, self)._handle_callback_exception(cr, uid,
model_name, method_name, args, job_id, job_exception)
res = super(ir_cron, self)._handle_callback_exception(
cr, uid, model_name, method_name, args, job_id, job_exception)
my_cron = self.browse(cr, uid, job_id) my_cron = self.browse(cr, uid, job_id)
@ -54,9 +55,9 @@ class ir_cron(orm.Model):
} }
logger.debug("Sending scheduler error email with context=%s" % context) logger.debug("Sending scheduler error email with context=%s" % context)
self.pool['email.template'].send_mail(cr, uid,
my_cron.email_template.id, my_cron.id, force_send=True,
context=context)
self.pool['email.template'].send_mail(
cr, uid, my_cron.email_template.id, my_cron.id,
force_send=True, context=context)
return res return res
@ -67,4 +68,3 @@ class res_users(orm.Model):
def test_scheduler_failure(self, cr, uid, context=None): def test_scheduler_failure(self, cr, uid, context=None):
"""This function is used to test and debug this module""" """This function is used to test and debug this module"""
raise orm.except_orm(_('Error :'), _("Task failure with UID = %d." % uid)) raise orm.except_orm(_('Error :'), _("Task failure with UID = %d." % uid))
Loading…
Cancel
Save