From 1dbaae147b88f90d354b3a43632f298722e4a4f1 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sun, 19 Dec 2010 22:07:51 +0200 Subject: [PATCH 1/3] ir.ui.menu: We don't need a "many2many_unique" class any more The parent many2many has been improved to avoid duplicate records. bzr revid: p_christ@hol.gr-20101219200751-0umvepzgtgjhnw78 --- bin/addons/base/ir/ir_ui_menu.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/bin/addons/base/ir/ir_ui_menu.py b/bin/addons/base/ir/ir_ui_menu.py index 9baff950c4f..99fc158042d 100644 --- a/bin/addons/base/ir/ir_ui_menu.py +++ b/bin/addons/base/ir/ir_ui_menu.py @@ -35,25 +35,6 @@ def one_in(setA, setB): return True return False -def cond(C, X, Y): - if C: return X - return Y - -class many2many_unique(fields.many2many): - def set(self, cr, obj, id, name, values, user=None, context=None): - if not values: - return - val = values[:] - for act in values: - if act[0]==4: - cr.execute('SELECT * FROM '+self._rel+' \ - WHERE '+self._id1+'=%s AND '+self._id2+'=%s', (id, act[1])) - if cr.fetchall(): - val.remove(act) - return super(many2many_unique, self).set(cr, obj, id, name, val, user=user, - context=context) - - class ir_ui_menu(osv.osv): _name = 'ir.ui.menu' @@ -298,7 +279,7 @@ class ir_ui_menu(osv.osv): 'sequence': fields.integer('Sequence'), 'child_id' : fields.one2many('ir.ui.menu', 'parent_id','Child IDs'), 'parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', select=True), - 'groups_id': many2many_unique('res.groups', 'ir_ui_menu_group_rel', + 'groups_id': fields.many2many('res.groups', 'ir_ui_menu_group_rel', 'menu_id', 'gid', 'Groups', help="If you have groups, the visibility of this menu will be based on these groups. "\ "If this field is empty, OpenERP will compute visibility based on the related object's read access."), 'complete_name': fields.function(_get_full_name, method=True, From 91a0d108bf1207dca8eb442e80e92c93fae5590c Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sun, 19 Dec 2010 22:08:42 +0200 Subject: [PATCH 2/3] workflow.instance: remove excess indices It is a table with 4 columns, doesn't worth 5 indices! I hope that these combined indexed plus the wkf_id one will allow Postgres to always come up with a good plan. bzr revid: p_christ@hol.gr-20101219200842-4vr72wqal2t8k2xq --- bin/addons/base/ir/workflow/workflow.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/addons/base/ir/workflow/workflow.py b/bin/addons/base/ir/workflow/workflow.py index e5bb3f25d67..c638855aacf 100644 --- a/bin/addons/base/ir/workflow/workflow.py +++ b/bin/addons/base/ir/workflow/workflow.py @@ -173,15 +173,15 @@ class wkf_instance(osv.osv): _log_access = False _columns = { 'wkf_id': fields.many2one('workflow', 'Workflow', ondelete='cascade', select=True), - 'res_id': fields.integer('Resource ID', select=True), - 'res_type': fields.char('Resource Object', size=64, select=True), - 'state': fields.char('State', size=32, select=True), + 'res_id': fields.integer('Resource ID'), + 'res_type': fields.char('Resource Object', size=64), + 'state': fields.char('State', size=32), } def _auto_init(self, cr, context=None): super(wkf_instance, self)._auto_init(cr, context) - cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_id_res_type_state_index\'') + cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_type_res_id_state_index\'') if not cr.fetchone(): - cr.execute('CREATE INDEX wkf_instance_res_id_res_type_state_index ON wkf_instance (res_id, res_type, state)') + cr.execute('CREATE INDEX wkf_instance_res_type_res_id_state_index ON wkf_instance (res_type, res_id, state)') cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_id_wkf_id_index\'') if not cr.fetchone(): cr.execute('CREATE INDEX wkf_instance_res_id_wkf_id_index ON wkf_instance (res_id, wkf_id)') From aaac6a602f3836ae6f9c8919fcf6c1af5896ac51 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sun, 19 Dec 2010 22:11:27 +0200 Subject: [PATCH 3/3] trml2pdf: Support EAN13 and QRcode barcodes, fix unicode warning [Bug 532559] Since ReportLab supports them, include it in our list, too. Also, fix the warning that has been appearing in buildbot, about "code128.py:257: UnicodeWarning ..." The issue is that string-capable barcodes will only support ASCII chars, not Unicode. So, cast to str() and let ReportLab's code be happy. Code was based on patch by: Omar (Pexego), on 22-06-2010 bzr revid: p_christ@hol.gr-20101219201127-mmrsn206a9vldr43 --- bin/report/render/rml2pdf/trml2pdf.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/report/render/rml2pdf/trml2pdf.py b/bin/report/render/rml2pdf/trml2pdf.py index d01317f8257..497a4ba98c2 100644 --- a/bin/report/render/rml2pdf/trml2pdf.py +++ b/bin/report/render/rml2pdf/trml2pdf.py @@ -733,22 +733,26 @@ class _rml_flowable(object): from reportlab.graphics.barcode import common from reportlab.graphics.barcode import fourstate from reportlab.graphics.barcode import usps - except Exception, e: + from reportlab.graphics.barcode import createBarcodeDrawing + + except ImportError: self._logger.warning("Cannot use barcode renderers:", exc_info=True) return None args = utils.attr_get(node, [], {'ratio':'float','xdim':'unit','height':'unit','checksum':'int','quiet':'int','width':'unit','stop':'bool','bearers':'int','barWidth':'float','barHeight':'float'}) codes = { 'codabar': lambda x: common.Codabar(x, **args), 'code11': lambda x: common.Code11(x, **args), - 'code128': lambda x: code128.Code128(x, **args), - 'standard39': lambda x: code39.Standard39(x, **args), - 'standard93': lambda x: code93.Standard93(x, **args), + 'code128': lambda x: code128.Code128(str(x), **args), + 'standard39': lambda x: code39.Standard39(str(x), **args), + 'standard93': lambda x: code93.Standard93(str(x), **args), 'i2of5': lambda x: common.I2of5(x, **args), - 'extended39': lambda x: code39.Extended39(x, **args), - 'extended93': lambda x: code93.Extended93(x, **args), + 'extended39': lambda x: code39.Extended39(str(x), **args), + 'extended93': lambda x: code93.Extended93(str(x), **args), 'msi': lambda x: common.MSI(x, **args), 'fim': lambda x: usps.FIM(x, **args), 'postnet': lambda x: usps.POSTNET(x, **args), + 'ean13': lambda x: createBarcodeDrawing('EAN13', value=str(x), **args), + 'qrcode': lambda x: createBarcodeDrawing('QR', value=x, **args), } code = 'code128' if node.get('code'):