Skip to content

Commit

Permalink
[MERGE] forward port of branch 8.0 up to e6396de
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Feb 27, 2015
2 parents 109dae2 + e6396de commit 1abe1ea
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 9 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ recursive-include openerp *.xml
recursive-include openerp *.yml
recursive-exclude * *.py[co]
recursive-exclude * *.hg*
graft openerp/cli/templates
32 changes: 29 additions & 3 deletions addons/base_import/tests/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ def test_csv_errors(self):
})
self.assertTrue('error' in result)

def test_csv_errors(self):
Import, id = self.make_import()

result = Import.parse_preview(self.cr, self.uid, id, {
'quoting': '"',
'separator': 'bob',
Expand Down Expand Up @@ -356,3 +353,32 @@ def test_falsefields(self):
Import._convert_import_data,
record, [False, False, False],
{'quoting': '"', 'separator': ',', 'headers': True,})

class test_failures(TransactionCase):
def test_big_attachments(self):
"""
Ensure big fields (e.g. b64-encoded image data) can be imported and
we're not hitting limits of the default CSV parser config
"""
import csv, cStringIO
from PIL import Image

im = Image.new('RGB', (1920, 1080))
fout = cStringIO.StringIO()

writer = csv.writer(fout, dialect=None)
writer.writerows([
['name', 'db_datas'],
['foo', im.tobytes().encode('base64')]
])

Import = self.env['base_import.import']
imp = Import.create({
'res_model': 'ir.attachment',
'file': fout.getvalue()
})
[results] = imp.do(
['name', 'db_datas'],
{'headers': True, 'separator': ',', 'quoting': '"'})
self.assertFalse(
results, "results should be empty on successful import")
2 changes: 1 addition & 1 deletion addons/mrp/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def _get_manufacture_pull_rule(self, cr, uid, warehouse, context=None):
route_obj = self.pool.get('stock.location.route')
data_obj = self.pool.get('ir.model.data')
try:
manufacture_route_id = data_obj.get_object_reference(cr, uid, 'stock', 'route_warehouse0_manufacture')[1]
manufacture_route_id = data_obj.get_object_reference(cr, uid, 'mrp', 'route_warehouse0_manufacture')[1]
except:
manufacture_route_id = route_obj.search(cr, uid, [('name', 'like', _('Manufacture'))], context=context)
manufacture_route_id = manufacture_route_id and manufacture_route_id[0] or False
Expand Down
2 changes: 1 addition & 1 deletion addons/sale/sales_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _get_invoices_data(self, cr, uid, ids, field_name, arg, context=None):

res = {}
for id in ids:
created_domain = [('team_id', '=', id), ('state', 'not in', ['draft', 'cancel']), ('date', '>=', date_begin), ('date', '<=', date_end)]
created_domain = [('type', 'in', ['out_invoice', 'out_refund']), ('team_id', '=', id), ('state', 'not in', ['draft', 'cancel']), ('date', '>=', date_begin), ('date', '<=', date_end)]
values = self.__get_bar_values(cr, uid, obj, created_domain, ['price_total', 'date'], 'price_total', 'date', context=context)
for value in values:
value['value'] = float_repr(value.get('value', 0), precision_digits=self.pool['decimal.precision'].precision_get(cr, uid, 'Account'))
Expand Down
21 changes: 21 additions & 0 deletions doc/cla/corporate/initos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Germany, 2015-02-26

initOS GmbH & Co. KG agrees to the terms of the Odoo Corporate
Contributor License Agreement v1.0.

I declare that I am authorized and able to make this agreement and sign this
declaration.

Signed,

Markus Schneider [email protected] https://github.com/OSguard

List of contributors:

Markus Schneider [email protected] https://github.com/OSguard
Thomas Rehn [email protected] https://github.com/tremlin
Katja Matthes [email protected] https://github.com/kmatthes
Frederik Kramer [email protected] https://github.com/OSevangelist
Nikolina Todorova [email protected] https://github.com/ntodorova
Peter Hahn [email protected] https://github.com/codingforfun
Claudia Haida [email protected]
11 changes: 11 additions & 0 deletions doc/cla/individual/Toilal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
France, 2015-02-20

I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.

I declare that I am authorized and able to make this agreement and sign this
declaration.

Signed,

Rémi Alvergnat [email protected] https://github.com/Toilal
11 changes: 11 additions & 0 deletions doc/cla/individual/leorochael.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Brazil, 2015-02-26

I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.

I declare that I am authorized and able to make this agreement and sign this
declaration.

Signed,

Leonardo Rochael Almeida [email protected] https://github.com/leorochael
11 changes: 11 additions & 0 deletions doc/cla/individual/vnsofthe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
China, 2015-02-27

I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.

I declare that I am authorized and able to make this agreement and sign this
declaration.

Signed,

vnsoft [email protected] https://github.com/vnsofthe
6 changes: 6 additions & 0 deletions openerp/cli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"""

import atexit
import csv
import logging
import os
import signal
Expand Down Expand Up @@ -141,6 +142,11 @@ def main(args):

config = openerp.tools.config

# the default limit for CSV fields in the module is 128KiB, which is not
# quite sufficient to import images to store in attachment. 500MiB is a
# bit overkill, but better safe than sorry I guess
csv.field_size_limit(500 * 1024 * 1024)

if config["db_name"]:
try:
openerp.service.db._create_empty_database(config["db_name"])
Expand Down
7 changes: 5 additions & 2 deletions openerp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import re
import time
from collections import defaultdict, MutableMapping
from inspect import getmembers
from inspect import getmembers, currentframe

import babel.dates
import dateutil.relativedelta
Expand All @@ -66,6 +66,7 @@
from .osv.query import Query
from .tools import frozendict, lazy_property, ormcache
from .tools.config import config
from .tools.func import frame_codeinfo
from .tools.misc import CountingStream, DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
from .tools.safe_eval import safe_eval as eval
from .tools.translate import _
Expand Down Expand Up @@ -5480,7 +5481,9 @@ def __eq__(self, other):
""" Test whether two recordsets are equivalent (up to reordering). """
if not isinstance(other, BaseModel):
if other:
_logger.warning("Comparing apples and oranges: %s == %s", self, other)
filename, lineno = frame_codeinfo(currentframe(), 1)
_logger.warning("Comparing apples and oranges: %r == %r (%s:%s)",
self, other, filename, lineno)
return False
return self._name == other._name and set(self._ids) == set(other._ids)

Expand Down
3 changes: 2 additions & 1 deletion openerp/tools/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def exec_pg_command(name, *args):
prog = find_pg_tool(name)
env = exec_pg_environ()
with open(os.devnull) as dn:
rc = subprocess.call((prog,) + args, env=env, stdout=dn, stderr=subprocess.STDOUT)
args2 = (prog,) + args
rc = subprocess.call(args2, env=env, stdout=dn, stderr=subprocess.STDOUT)
if rc:
raise Exception('Postgres subprocess %s error %s' % (args2, rc))

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Jinja2==2.7.3
Mako==1.0.1
MarkupSafe==0.23
Pillow==2.7.0
http://download.gna.org/pychart/PyChart-1.39.tar.gz
http://download.gna.org/pychart/PyChart-1.39.tar.gz#egg=PyChart
PyYAML==3.11
Werkzeug==0.9.6
argparse==1.2.1
Expand Down

0 comments on commit 1abe1ea

Please sign in to comment.