Skip to content

Commit

Permalink
Merge branch '7.0' to master
Browse files Browse the repository at this point in the history
Conflicts:
	.travis.yml
	__unported__/users_ldap_mail/__openerp__.py
	dbfilter_from_header/__init__.py
	disable_openerp_online/data/ir_ui_menu.xml
	mass_editing/__init__.py
	mass_editing/models/mass_object.py
	mass_editing/wizard/__init__.py
  • Loading branch information
gurneyalex committed Aug 18, 2014
2 parents 7841e39 + 9b6eee8 commit 5e310b4
Show file tree
Hide file tree
Showing 38 changed files with 596 additions and 466 deletions.
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
language: python

python:
- "2.7"

env:
- VERSION="8.0" ODOO_REPO="odoo/odoo"
- VERSION="8.0" ODOO_REPO="OCA/OCB"

virtualenv:
system_site_packages: true

Expand All @@ -10,15 +15,15 @@ env:
- VERSION="8.0" ODOO_REPO="OCA/OCB"

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
- pip install python-ldap
- printf '[options]\n\nrunning_env = dev' > /tmp/odoo.cfg
- 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 /tmp/odoo.cfg
- travis_run_flake8
- travis_run_tests ${VERSION}

after_success:
coveralls
2 changes: 1 addition & 1 deletion __unported__/auth_admin_passkey/model/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class res_users(Model):

# Private Function section
def _get_translation(self, cr, lang, text):
context = {'lang': lang}
context = {'lang': lang} # noqa: _() checks page for locals
return _(text)

def _send_email_passkey(self, cr, user_id, user_agent_env):
Expand Down
3 changes: 2 additions & 1 deletion __unported__/auth_from_http_basic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def init(self, params):
base_location=self.httprequest.url_root.rstrip('/'),
HTTP_HOST=self.httprequest.environ['HTTP_HOST'],
REMOTE_ADDR=self.httprequest.environ['REMOTE_ADDR']
))
)
)

WebRequest.init = init

Expand Down
2 changes: 1 addition & 1 deletion __unported__/base_external_dbsource/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
'base_external_dbsource_demo.xml',
],
'test': [
'dbsource_connect.yml',
'test/dbsource_connect.yml',
],
'installable': False,
'active': False,
Expand Down
22 changes: 11 additions & 11 deletions __unported__/base_external_dbsource/base_external_dbsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@
try:
import pymssql
CONNECTORS.append(('mssql', 'Microsoft SQL Server'))
except:
assert pymssql
except (ImportError, AssertionError):
_logger.info('MS SQL Server not available. Please install "pymssql"\
python package.')
try:
import MySQLdb
CONNECTORS.append(('mysql', 'MySQL'))
except:
assert MySQLdb
except (ImportError, AssertionError):
_logger.info('MySQL not available. Please install "mysqldb"\
python package.')
except:
Expand Down Expand Up @@ -90,15 +92,15 @@ class base_external_dbsource(orm.Model):
}

def conn_open(self, cr, uid, id1):
#Get dbsource record
# Get dbsource record
data = self.browse(cr, uid, id1)
#Build the full connection string
# Build the full connection string
connStr = data.conn_string
if data.password:
if '%s' not in data.conn_string:
connStr += ';PWD=%s'
connStr = connStr % data.password
#Try to connect
# Try to connect
if data.connector == 'cx_Oracle':
os.environ['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'
conn = cx_Oracle.connect(connStr)
Expand Down Expand Up @@ -134,13 +136,13 @@ def execute(self, cr, uid, ids, sqlquery, sqlparams=None, metadata=False,
for obj in data:
conn = self.conn_open(cr, uid, obj.id)
if obj.connector in ["sqlite", "mysql", "mssql"]:
#using sqlalchemy
# using sqlalchemy
cur = conn.execute(sqlquery, sqlparams)
if metadata:
cols = cur.keys()
rows = [r for r in cur]
else:
#using other db connectors
# using other db connectors
cur = conn.cursor()
cur.execute(sqlquery, sqlparams)
if metadata:
Expand All @@ -157,7 +159,7 @@ def connection_test(self, cr, uid, ids, context=None):
conn = False
try:
conn = self.conn_open(cr, uid, obj.id)
except Exception, e:
except Exception as e:
raise orm.except_orm(_("Connection test failed!"),
_("Here is what we got instead:\n %s")
% tools.ustr(e))
Expand All @@ -168,8 +170,6 @@ def connection_test(self, cr, uid, ids, context=None):
except Exception:
# ignored, just a consequence of the previous exception
pass
#TODO: if OK a (wizard) message box should be displayed
# TODO: if OK a (wizard) message box should be displayed
raise orm.except_orm(_("Connection test succeeded!"),
_("Everything seems properly set up!"))

#EOF
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
Connect to local Postgres.
-
!python {model: base.external.dbsource}: |
self.connection_test(cr, uid, [ref("demo_postgresql")]
from openerp.osv.orm import except_orm
try:
self.connection_test(cr, uid, [ref("demo_postgre")])
except except_orm as e:
assert e.value == u'Everything seems properly set up!'
7 changes: 5 additions & 2 deletions __unported__/base_optional_quick_create/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
'category': 'Tools',
'summary': "Avoid 'quick create' on m2o fields, on a 'by model' basis",
'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
""",
Expand Down
3 changes: 2 additions & 1 deletion __unported__/base_optional_quick_create/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
from openerp import SUPERUSER_ID
from openerp.tools.translate import _


class ir_model(orm.Model):

_inherit = 'ir.model'

_columns = {
'avoid_quick_create': fields.boolean('Avoid quick create'),
}
Expand Down
2 changes: 1 addition & 1 deletion __unported__/configuration_helper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ 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
# allows to exclude some field
if self._filter_field(field_key):
args = ('company_id', field_key)
kwargs = {
Expand Down
11 changes: 6 additions & 5 deletions __unported__/cron_run_manually/model/ir_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
from openerp.tools.translate import _
from openerp.tools.safe_eval import safe_eval


class irCron(orm.Model):
_inherit = 'ir.cron'

def run_manually(self, cr, uid, ids, context=None):
"""
Run a job from the cron form view.
Expand All @@ -51,7 +52,7 @@ def run_manually(self, cr, uid, ids, context=None):
_('Error'),
_('Only the admin user is allowed to '
'execute inactive cron jobs manually'))

try:
# Try to grab an exclusive lock on the job row
# until the end of the transaction
Expand All @@ -67,9 +68,9 @@ def run_manually(self, cr, uid, ids, context=None):
model = self.pool.get(job['model'])
method = getattr(model, job['function'])
args = safe_eval('tuple(%s)' % (job['args'] or ''))
method(cr, job['user_id'], *args)
except psycopg2.OperationalError, e:
method(cr, job['user_id'], *args)

except psycopg2.OperationalError as e:
# User friendly error if the lock could not be claimed
if e.pgcode == '55P03':
raise orm.except_orm(
Expand Down
11 changes: 8 additions & 3 deletions __unported__/email_template_template/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
::
Dear ${object.partner_id.name},
Your order has been booked on date ${object.date} for a total amount of ${object.sum}.
And it will be evaluated to
Expand All @@ -77,13 +77,18 @@
Example city
Example Corp footer
Given the way evaluation works internally (body_text of the template template is evaluated two times, first with the instance of email.template of your own template, then with the object your template refers to), you can do some trickery if you know that a template template is always used with the same kind of model (that is, models that have the same field name):
Given the way evaluation works internally (body_text of the template template
is evaluated two times, first with the instance of email.template of your own
template, then with the object your template refers to), you can do some
trickery if you know that a template template is always used with the same
kind of model (that is, models that have the same field name):
In your template template:
::
Dear ${'${object.name}'}, <-- gets evaluated to "${object.name}" in the first step, then to the content of object.name
Dear ${'${object.name}'}, <-- gets evaluated to "${object.name}" in the
first step, then to the content of object.name
${object.body_html}
Best,
Example Corp
Expand Down
4 changes: 2 additions & 2 deletions __unported__/email_template_template/model/email_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class email_template(Model):

def _get_is_template_template(self, cr, uid, ids, fields_name, arg,
context=None):
cr.execute('''select
cr.execute('''select
id, (select count(*) > 0 from email_template e
where email_template_id=email_template.id)
from email_template
Expand All @@ -45,7 +45,7 @@ def _get_is_template_template(self, cr, uid, ids, fields_name, arg,
def get_email_template(self, cr, uid, template_id=False, record_id=None,
context=None):
this = super(email_template, self).get_email_template(
cr, uid, template_id, record_id, context)
cr, uid, template_id, record_id, context)

if this.email_template_id and not this.is_template_template:
for field in ['body_html']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#
##############################################################################


class base(object):
name = None
'''Name shown to the user'''
Expand All @@ -30,7 +31,6 @@ class base(object):
readonly_fields = []
'''Fields on fetchmail_server folder that are readonly for this algorithm'''


def search_matches(self, cr, uid, conf, mail_message, mail_message_org):
'''Returns ids found for model with mail_message'''
return []
Expand All @@ -40,4 +40,4 @@ def handle_match(
mail_message, mail_message_org, msgid, context=None):
'''Do whatever it takes to handle a match'''
return folder.server_id.attach_mail(connection, object_id, folder,
mail_message, msgid)
mail_message, msgid)
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@

from email_exact import email_exact


class email_domain(email_exact):
'''Search objects by domain name of email address.
Beware of match_first here, this is most likely to get it wrong (gmail)'''
name = 'Domain of email address'

def search_matches(self, cr, uid, conf, mail_message, mail_message_org):
ids = super(email_domain, self).search_matches(
cr, uid, conf, mail_message, mail_message_org)
cr, uid, conf, mail_message, mail_message_org)
if not ids:
domains = []
for addr in self._get_mailaddresses(conf, mail_message):
domains.append(addr.split('@')[-1])
ids = conf.pool.get(conf.model_id.model).search(
cr, uid,
self._get_mailaddress_search_domain(
conf, mail_message,
operator='like',
values=['%@'+domain for domain in set(domains)]),
order=conf.model_order)
cr, uid,
self._get_mailaddress_search_domain(
conf, mail_message,
operator='like',
values=['%@'+domain for domain in set(domains)]),
order=conf.model_order)
return ids
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from openerp.tools.safe_eval import safe_eval
from openerp.tools.mail import email_split


class email_exact(base):
'''Search for exactly the mailadress as noted in the email'''

Expand All @@ -36,17 +37,17 @@ def _get_mailaddresses(self, conf, mail_message):
for field in fields:
if field in mail_message:
mailaddresses += email_split(mail_message[field])
return [ addr.lower() for addr in mailaddresses ]
return [addr.lower() for addr in mailaddresses]

def _get_mailaddress_search_domain(
self, conf, mail_message, operator='=', values=None):
mailaddresses = values or self._get_mailaddresses(
conf, mail_message)
conf, mail_message)
if not mailaddresses:
return [(0, '=', 1)]
search_domain = ((['|'] * (len(mailaddresses) - 1)) + [
(conf.model_field, operator, addr) for addr in mailaddresses] +
safe_eval(conf.domain or '[]'))
(conf.model_field, operator, addr) for addr in mailaddresses] +
safe_eval(conf.domain or '[]'))
return search_domain

def search_matches(self, cr, uid, conf, mail_message, mail_message_org):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@
##############################################################################

from base import base
from openerp.tools.safe_eval import safe_eval


class openerp_standard(base):
'''No search at all. Use OpenERP's standard mechanism to attach mails to
mail.thread objects. Note that this algorithm always matches.'''

name = 'OpenERP standard'
readonly_fields = ['model_field', 'mail_field', 'match_first', 'domain',
'model_order', 'flag_nonmatching']
readonly_fields = [
'model_field',
'mail_field',
'match_first',
'domain',
'model_order',
'flag_nonmatching',
]

def search_matches(self, cr, uid, conf, mail_message, mail_message_org):
'''Always match. Duplicates will be fished out by message_id'''
Expand All @@ -39,11 +45,12 @@ def handle_match(
self, cr, uid, connection, object_id, folder,
mail_message, mail_message_org, msgid, context):
result = folder.pool.get('mail.thread').message_process(
cr, uid,
folder.model_id.model, mail_message_org,
save_original=folder.server_id.original,
strip_attachments=(not folder.server_id.attach),
context=context)
cr, uid,
folder.model_id.model, mail_message_org,
save_original=folder.server_id.original,
strip_attachments=(not folder.server_id.attach),
context=context
)

if folder.delete_matching:
connection.store(msgid, '+FLAGS', '\\DELETED')
Expand Down
Loading

0 comments on commit 5e310b4

Please sign in to comment.