From 325bcd1c5b5cb44f3165287620b957ea68f18537 Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Mon, 8 Mar 2010 13:59:39 +0530 Subject: [PATCH 1/6] [IMP]:change the way to calculate avg/sum bzr revid: nch@tinyerp.com-20100308082939-crtgxay16njypjt7 --- bin/osv/orm.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 0165d4e7a4a..5904ab5cf3a 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1871,13 +1871,9 @@ class orm(orm_template): fields_pre = [f for f in float_int_fields if f == self.CONCURRENCY_CHECK_FIELD or (f in self._columns and getattr(self._columns[f], '_classic_write'))] - avg_fields = context.get('avg',[]) for f in fields_pre: if f not in ['id','sequence']: - if f in avg_fields: - flist += ',avg('+f+') as '+f - else: - flist += ',sum('+f+') as '+f + flist += ',sum('+f+') as '+f cr.execute('select min(%s.id) as id,' % self._table + flist + ' from ' + ','.join(tables) + where_clause + ' group by '+ groupby + limit_str + offset_str, where_params) alldata = {} From 546b76d5d3ed95af3f8d7d38504f25732baac4da Mon Sep 17 00:00:00 2001 From: Julien Thewys Date: Mon, 8 Mar 2010 09:55:32 +0100 Subject: [PATCH 2/6] [REF] Reoarganized imports, catches yaml not found. bzr revid: jth@openerp.com-20100308085532-1yv9xv1tosz223vs --- bin/tools/yaml_import.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/tools/yaml_import.py b/bin/tools/yaml_import.py index 2c334c9cd3c..9632842bc80 100644 --- a/bin/tools/yaml_import.py +++ b/bin/tools/yaml_import.py @@ -1,15 +1,20 @@ # -*- encoding: utf-8 -*- import types -import yaml import time # used to eval time.strftime expressions import logging import pooler import netsvc import misc - from config import config +try: + import yaml +except ImportError, e: + msg = "Module yaml was not found." + e.args = (msg,) + raise e + logger_channel = 'tests' class YamlImportException(Exception): From 8856a549f738f983795d29da330044568147828a Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Mon, 8 Mar 2010 15:10:36 +0530 Subject: [PATCH 3/6] [IMP]:Avg/sum for groupby bzr revid: nch@tinyerp.com-20100308094036-hpvzsvlygup7s0e7 --- bin/osv/fields.py | 20 +++++++++++--------- bin/osv/orm.py | 5 +++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/bin/osv/fields.py b/bin/osv/fields.py index 5d373a168ea..ce02de20a27 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # 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 . +# along with this program. If not, see . # ############################################################################## @@ -80,6 +80,7 @@ class _column(object): self.view_load = 0 self.select = select self.selectable = True + self.group_operator = args.get('group_operator', False) for a in args: if args[a]: setattr(self, a, args[a]) @@ -177,6 +178,7 @@ class float(_column): self.digits = digits self.digits_compute = digits_compute + def digits_change(self, cr): if self.digits_compute: t = self.digits_compute(cr) @@ -320,8 +322,8 @@ class many2one(_column): except except_orm: record_name = {} record_name[record] = '// Access Denied //' - names.update(record_name) - + names.update(record_name) + for r in res.keys(): if res[r] and res[r] in names: res[r] = (res[r], names[res[r]]) @@ -629,7 +631,7 @@ class function(_column): self._multi = multi if 'relation' in args: self._obj = args['relation'] - + self.digits = args.get('digits', (16,2)) self.digits_compute = args.get('digits_compute', None) @@ -642,7 +644,7 @@ class function(_column): if not fnct_search and not store: self.selectable = False - + if store: self._classic_read = True self._classic_write = True @@ -681,14 +683,14 @@ class function(_column): if self._type == "many2one" : # Filtering only integer/long values if passed res_ids = [x for x in res.values() if x and isinstance(x, (int,long))] - + if res_ids: obj_model = obj.pool.get(self._obj) dict_names = dict(obj_model.name_get(cr, user, res_ids, context)) for r in res.keys(): if res[r] and res[r] in dict_names: res[r] = (res[r], dict_names[res[r]]) - + if self._type == 'binary' and context.get('bin_size', False): # convert the data returned by the function with the size of that data... res = dict(map( get_nice_size, res.items())) @@ -838,7 +840,7 @@ class dummy(function): def _fnct_read(self, obj, cr, uid, ids, field_name, args, context=None): return {} - + def __init__(self, *arg, **args): self.arg = arg self._relations = [] diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 5904ab5cf3a..7f412be0a7a 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1007,7 +1007,7 @@ class orm_template(object): if fields and f not in fields: continue res[f] = {'type': self._columns[f]._type} - for arg in ('string', 'readonly', 'states', 'size', 'required', + for arg in ('string', 'readonly', 'states', 'size', 'required', 'group_operator', 'change_default', 'translate', 'help', 'select', 'selectable'): if getattr(self._columns[f], arg): res[f][arg] = getattr(self._columns[f], arg) @@ -1873,7 +1873,8 @@ class orm(orm_template): or (f in self._columns and getattr(self._columns[f], '_classic_write'))] for f in fields_pre: if f not in ['id','sequence']: - flist += ',sum('+f+') as '+f + operator = fget[f].get('group_operator','sum') + flist += ','+operator+'('+f+') as '+f cr.execute('select min(%s.id) as id,' % self._table + flist + ' from ' + ','.join(tables) + where_clause + ' group by '+ groupby + limit_str + offset_str, where_params) alldata = {} From f36e7da6a81d8da5a51fd7ce96fb9757e9a18aa7 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Mon, 8 Mar 2010 15:52:15 +0530 Subject: [PATCH 4/6] [FIX] Base : Event Type form view should have key field editable lp bug: https://launchpad.net/bugs/531347 fixed bzr revid: jvo@tinyerp.com-20100308102215-k6yn58vks1th7sjw --- bin/addons/base/res/partner/crm_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/addons/base/res/partner/crm_view.xml b/bin/addons/base/res/partner/crm_view.xml index 4acb9004293..da4e08c7644 100644 --- a/bin/addons/base/res/partner/crm_view.xml +++ b/bin/addons/base/res/partner/crm_view.xml @@ -30,7 +30,7 @@
- + From 6307322cdbd471c1c9377a80eedf408a0366844a Mon Sep 17 00:00:00 2001 From: Julien Thewys Date: Mon, 8 Mar 2010 12:29:28 +0100 Subject: [PATCH 5/6] [REF] Reorganized imports (and undo previous non-sense change). bzr revid: jth@openerp.com-20100308112928-ewsboa2xxnuot4wi --- bin/tools/yaml_import.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/bin/tools/yaml_import.py b/bin/tools/yaml_import.py index 9632842bc80..8296a205830 100644 --- a/bin/tools/yaml_import.py +++ b/bin/tools/yaml_import.py @@ -8,12 +8,7 @@ import netsvc import misc from config import config -try: - import yaml -except ImportError, e: - msg = "Module yaml was not found." - e.args = (msg,) - raise e +import yaml logger_channel = 'tests' From a8d9eb604f59e5a282f20618cb450b419228a517 Mon Sep 17 00:00:00 2001 From: "noz@tinyerp.com" <> Date: Mon, 8 Mar 2010 17:23:00 +0530 Subject: [PATCH 6/6] [IMP] Added HTML View for Form view (example code). bzr revid: noz@tinyerp.com-20100308115300-su95aa69otmzx2ke --- bin/addons/base/res/partner/partner_view.xml | 37 ++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/res/partner/partner_view.xml b/bin/addons/base/res/partner/partner_view.xml index 91c7532219e..6d8e6b00b19 100644 --- a/bin/addons/base/res/partner/partner_view.xml +++ b/bin/addons/base/res/partner/partner_view.xml @@ -251,10 +251,43 @@ res.partner form -
+ + +
+ HTML Form Example +
+ + + + + +
+ + + + + + +
+ + OpenERP + + + + Tiny + +
+
+
+ -