From d984b6d8d0e4fa589c3d3f176e470b69a228bb13 Mon Sep 17 00:00:00 2001 From: "Rvo (Open ERP)" Date: Mon, 5 Apr 2010 11:31:06 +0530 Subject: [PATCH 1/5] Removed print statement bzr revid: rvo@tinyerp.co.in-20100405060106-pz1vz05wue71p0kc --- bin/osv/orm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index af3ca7ec6dc..ebc24530cd9 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1119,7 +1119,6 @@ class orm_template(object): for r in res.keys(): if r not in fields: del res[r] - print 'Result from fields get', res return res # @@ -2902,7 +2901,7 @@ class orm(orm_template): :raise UserError: if the record is default property for other records """ - + if not ids: return True if isinstance(ids, (int, long)): From 13a43dfdc36b751cb9ed6c55169e76b48094b829 Mon Sep 17 00:00:00 2001 From: "DSH(OpenERP)" <> Date: Tue, 6 Apr 2010 12:03:36 +0530 Subject: [PATCH 2/5] Support tiny report tag in add_header, prevent server crash on wrong report type selection lp bug: https://launchpad.net/bugs/510834 fixed bzr revid: hda@tinyerp.com-20100406063336-sh9u8tyfqdybtrp7 --- bin/report/report_sxw.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index 98d960db1a4..a85bac84f5c 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -297,11 +297,7 @@ class rml_parse(object): rml_head = self.rml_header2 else: rml_head = self.rml_header - if self.logo and (rml_head.find('company.logo')<0 or rml_head.find('',''' [[company.logo]] ''') - if not self.logo and rml_head.find('company.logo')>=0: - rml_head = rml_head.replace('','') + head_dom = etree.XML(rml_head) for tag in head_dom: found = rml_dom.find('.//'+tag.tag) @@ -443,9 +439,10 @@ class report_sxw(report_rml, preprocess.report): rml_parser = self.parser(cr, uid, self.name2, context=context) objs = self.getObjects(cr, uid, ids, context) rml_parser.set_context(objs, data, ids, report_xml.report_type) - processed_rml = self.preprocess_rml(etree.XML(rml),report_xml.report_type) + processed_rml = etree.XML(rml) if report_xml.header: rml_parser._add_header(processed_rml) + processed_rml = self.preprocess_rml(processed_rml,report_xml.report_type) if rml_parser.logo: logo = base64.decodestring(rml_parser.logo) create_doc = self.generators[report_xml.report_type] @@ -462,13 +459,18 @@ class report_sxw(report_rml, preprocess.report): sxw_z = zipfile.ZipFile(sxw_io, mode='r') rml = sxw_z.read('content.xml') meta = sxw_z.read('meta.xml') + mime_type = sxw_z.read('mimetype') + if mime_type == 'application/vnd.sun.xml.writer': + mime_type = 'sxw' + else : + mime_type = 'odt' sxw_z.close() rml_parser = self.parser(cr, uid, self.name2, context=context) rml_parser.parents = sxw_parents rml_parser.tag = sxw_tag objs = self.getObjects(cr, uid, ids, context) - rml_parser.set_context(objs, data, ids,report_xml.report_type) + rml_parser.set_context(objs, data, ids, mime_type) rml_dom_meta = node = etree.XML(meta) elements = node.findall(rml_parser.localcontext['name_space']["meta"]+"user-defined") @@ -489,7 +491,7 @@ class report_sxw(report_rml, preprocess.report): for n in rml_dom.iterdescendants(): if n.tag == key1: elements.append(n) - if report_type == 'odt': + if mime_type == 'odt': for pe in elements: e = pe.findall(key2) for de in e: @@ -520,8 +522,8 @@ class report_sxw(report_rml, preprocess.report): if de.getparent(): pp.remove(de) - rml_dom = self.preprocess_rml(rml_dom,report_type) - create_doc = self.generators[report_type] + rml_dom = self.preprocess_rml(rml_dom, mime_type) + create_doc = self.generators[mime_type] odt = etree.tostring(create_doc(rml_dom, rml_parser.localcontext), encoding='utf-8', xml_declaration=True) sxw_z = zipfile.ZipFile(sxw_io, mode='a') @@ -547,7 +549,7 @@ class report_sxw(report_rml, preprocess.report): sxw_z.close() final_op = sxw_io.getvalue() sxw_io.close() - return (final_op, report_type) + return (final_op, mime_type) def create_single_html2html(self, cr, uid, ids, data, report_xml, context=None): if not context: From b7133378a2281aca219357c8da27a5455accb309 Mon Sep 17 00:00:00 2001 From: "DSH(OpenERP)" <> Date: Tue, 6 Apr 2010 15:03:56 +0530 Subject: [PATCH 3/5] Added removeParentNode in company header logo bzr revid: hda@tinyerp.com-20100406093356-lz9cdk9ldswks2m3 --- bin/addons/base/res/res_company.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/addons/base/res/res_company.py b/bin/addons/base/res/res_company.py index dccf08ed2ed..ea64aa5eb16 100644 --- a/bin/addons/base/res/res_company.py +++ b/bin/addons/base/res/res_company.py @@ -209,7 +209,7 @@ class res_company(osv.osv): - [[company.logo]] + [[ company.logo or removeParentNode('image') ]] From 91a88a3f8dbd4d2438ddd273d3683fe7a16d03ba Mon Sep 17 00:00:00 2001 From: "HDA (OpenERP)" Date: Tue, 6 Apr 2010 15:56:21 +0530 Subject: [PATCH 4/5] Improved docstring of orm bzr revid: hda@tinyerp.com-20100406102621-0n65uvesduhpv987 --- bin/osv/orm.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 589681ebfaf..29eab99a7d1 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -2493,12 +2493,12 @@ class orm(orm_template): def default_get(self, cr, uid, fields_list, context=None): """ - Get default field values of the given field list of the model + To Get default field values of given fields list of the model :param cr: database cursor :param uid: current user id :param fields_list: a list of fields to get the default value - :type fields_list: a list (example ['field_name_1', ...]) + :type fields_list: a list (example ['field1','field2',]) :param context: context arguments, like lang, time zone :return: a dictionary of the default values for fields (set on the object class, by the user preferences, or via the context) @@ -2872,9 +2872,9 @@ class orm(orm_template): def check_access_rule(self, cr, uid, ids, operation, context=None): """Verifies that the operation given by ``operation`` is allowed for the user according to ir.rules. - @param ``operation``: one of ``'read'``, ``'write'``, ``'unlink'`` - @raise ``except_orm``: if current ir.rules do not permit this operation. - @return: ``None`` if the operation is allowed + :param operation: one of ``'read'``, ``'write'``, ``'unlink'`` + :raise except_orm: * if current ir.rules do not permit this operation. + :return: None if the operation is allowed """ where_clause, where_params, tables = self.pool.get('ir.rule').domain_get(cr, uid, self._name, operation, context=context) if where_clause: @@ -2955,9 +2955,9 @@ class orm(orm_template): :param cr: database cursor :param user: current user id :type user: integer (example 1) - :param ids: id or a list of ids - :param vals: a dictionary of field values to update - :type vals: a dictionary (example {'field_name':'value', ...}) + :param ids: id or list of ids + :param vals: dictionary of field values to update + :type vals: dictionary (example {'field_name':'value', ...}) :param context(optional, highly recommended): context arguments, like lang, time zone :return: True :raise AccessError: * if user has no write rights on the requested object @@ -3165,10 +3165,10 @@ class orm(orm_template): :param cr: database cursor :param user: current user id :type user: integer (example 1) - :param vals: a dictionary for new record {'field_name':field_value, ...} - :type vals: a dictionary (example {'field_name':field_value, ...}) + :param vals: dictionary for new record {'field_name':field_value, ...} + :type vals: dictionary (example {'field_name':field_value, ...}) :param context(optional, highly recommended): context arguements, like lang, time zone - :type context: a dictionary (example {'lang':'en_us', ...}) + :type context: dictionary (example {'lang':'en_us', ...}) :return: id of new record created :raise AccessError: * if user has no create rights on the requested object * if user tries to bypass access rules for create on the requested object @@ -3532,10 +3532,10 @@ class orm(orm_template): :param cr: database cursor :param user: current user id - :param args: a list of tuples specifying search criteria [('field_name', 'operator', 'value'), ...] - :param offset: optional number of records to skip + :param args: list of tuples specifying search criteria [('field_name', 'operator', 'value'), ...] + :param offset: optional number from search starts :param limit: optional max number of records to return - :param order: optional columns to sort by (default: self._order ) + :param order: optional columns to sort by (default: self._order=id ) :param context(optional, highly recommended): context arguments, like lang, time zone :param count: if True, returns only the number of records matching the criteria, not their ids :return: id or a list of ids of records matching the criteria From 927227cef9f80780a265e9407d46487012892a86 Mon Sep 17 00:00:00 2001 From: "Rvo (Open ERP)" Date: Tue, 6 Apr 2010 18:00:28 +0530 Subject: [PATCH 5/5] [IMP]:improved orm's public methods docstrings bzr revid: rvo@tinyerp.co.in-20100406123028-1mroxby4v4ijbxtr --- bin/osv/orm.py | 97 +++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 29eab99a7d1..59f64d704d6 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -139,7 +139,7 @@ class browse_record(object): def __init__(self, cr, uid, id, table, cache, context=None, list_class = None, fields_process={}): ''' table : the object (inherited from orm) - context : a dictionary with an optional context + context : dictionary with an optional context ''' if not context: context = {} @@ -506,9 +506,9 @@ class orm_template(object): :param cr: database cursor :param user: current user id - :param select: id or a list of ids + :param select: id or list of ids :param context: context arguments, like lang, time zone - :rtype: object or a list of objects requested + :rtype: object or list of objects requested """ if not context: @@ -631,10 +631,10 @@ class orm_template(object): :param cr: database cursor :param uid: current user id - :param ids: a list of ids - :param fields_to_export: a list of fields + :param ids: list of ids + :param fields_to_export: list of fields :param context: context arguments, like lang, time zone, may contain import_comp(default: False) to make exported data compatible with import_data() - :rtype: a dictionary with a *datas* matrix + :rtype: dictionary with a *datas* matrix This method is used when exporting data via client menu @@ -673,15 +673,15 @@ class orm_template(object): :param cr: database cursor :param uid: current user id - :param ids: a list of ids - :param fields: a list of fields + :param ids: list of ids + :param fields: list of fields :param data: data to import :param mode: 'init' or 'update' for record creation :param current_module: module name :param noupdate: flag for record creation :param context: context arguments, like lang, time zone, :param filename: optional file to store partial import state for recovery - :rtype: a tuple + :rtype: tuple This method is used when importing data via client menu @@ -1362,9 +1362,9 @@ class orm_template(object): :param view_id: id of the view or None :param view_type: type of the view to return if view_id is None ('form', tree', ...) :param context: context arguments, like lang, time zone - :param toolbar: true to include concextual actions + :param toolbar: true to include contextual actions :param submenu: example (portal_project module) - :return: a dictionary describing the composition of the requested view (including inherited views and extensions) + :return: dictionary describing the composition of the requested view (including inherited views and extensions) :raise AttributeError: * if the inherited view has unknown position to work with other than 'before', 'after', 'inside', 'replace' * if some tag other than 'position' is found in parent view @@ -1934,22 +1934,22 @@ class orm(orm_template): def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): """ - Get the list of records in list view sorted by the given fields + Get the list of records in list view grouped by the given ``groupby`` fields :param cr: database cursor :param uid: current user id - :param domain: a list specifying search criteria [['field_name', 'operator', 'value'], ...] - :param fields: a list of fields present in the list view specified on the object - :param groupby: a list of fields on which to sort the records - :type fields_list: a list (example ['field_name_1', ...]) + :param domain: list specifying search criteria [['field_name', 'operator', 'value'], ...] + :param fields: list of fields present in the list view specified on the object + :param groupby: list of fields on which to groupby the records + :type fields_list: list (example ['field_name_1', ...]) :param offset: optional number of records to skip :param limit: optional max number of records to return :param context: context arguments, like lang, time zone - :return: a list of dictionaries(one dictionary for each record) containing: + :return: list of dictionaries(one dictionary for each record) containing: - * the values of fields sorted out by the fields in groupby arguement - * __domain: a list of tuples specifying the search criteria - * __context: a dictionary with argument like 'groupby' + * the values of fields grouped by the fields in ``groupby`` argument + * __domain: list of tuples specifying the search criteria + * __context: dictionary with argument like ``groupby`` :rtype: [{'field_name_1': value, ...] :raise AccessError: * if user has no read rights on the requested object * if user tries to bypass access rules for read on the requested object @@ -2035,7 +2035,7 @@ class orm(orm_template): Adds missing table select and join clause(s) for reaching the field coming from an '_inherits' parent table. - :param tables: a list of table._table names enclosed in double quotes as returned + :param tables: list of table._table names enclosed in double quotes as returned by _where_calc() """ @@ -2497,10 +2497,10 @@ class orm(orm_template): :param cr: database cursor :param uid: current user id - :param fields_list: a list of fields to get the default value - :type fields_list: a list (example ['field1','field2',]) + :param fields_list: list of fields to get the default value + :type fields_list: list (example ['field1', 'field2',]) :param context: context arguments, like lang, time zone - :return: a dictionary of the default values for fields (set on the object class, by the user preferences, or via the context) + :return: dictionary of the default values for fields (set on the object class, by the user preferences, or via the context) """ if not context: @@ -2599,9 +2599,9 @@ class orm(orm_template): :param cr: database cursor :param user: current user id - :param fields: a list of fields + :param fields: list of fields :param context: context arguments, like lang, time zone - :return: a dictionary of field dictionaries, each one describing a field of the business object + :return: dictionary of field dictionaries, each one describing a field of the business object :raise AccessError: * if user has no create/write rights on the requested object """ @@ -2616,11 +2616,11 @@ class orm(orm_template): :param cr: database cursor :param user: current user id - :param ids: id or a list of the ids of the records to read + :param ids: id or list of the ids of the records to read :param fields: optional list of field names to return (default: all fields would be returned) - :type fields: a list (example ['field_name_1', ...]) + :type fields: list (example ['field_name_1', ...]) :param context(optional, highly recommended): context arguments, like lang, time zone - :return: a list of dictionaries((a dictionary per record asked)) with requested field values + :return: list of dictionaries((dictionary per record asked)) with requested field values :rtype: [{‘name_of_the_field’: value, ...}, ...] :raise AccessError: * if user has no read rights on the requested object * if user tries to bypass access rules for read on the requested object @@ -2819,8 +2819,8 @@ class orm(orm_template): :param ids: id or list of ids :param context: context arguments, like lang, time zone :param details: if True, *_uid fields are replaced with the name of the user - :return: a list of ownership dictionaries for each requested record - :rtype: a list of dictionaries with the following keys: + :return: list of ownership dictionaries for each requested record + :rtype: list of dictionaries with the following keys: * id: object id * create_uid: user who created the record @@ -2872,7 +2872,8 @@ class orm(orm_template): def check_access_rule(self, cr, uid, ids, operation, context=None): """Verifies that the operation given by ``operation`` is allowed for the user according to ir.rules. - :param operation: one of ``'read'``, ``'write'``, ``'unlink'`` + + :param operation: one of ``write``, ``unlink`` :raise except_orm: * if current ir.rules do not permit this operation. :return: None if the operation is allowed """ @@ -2894,7 +2895,7 @@ class orm(orm_template): :param cr: database cursor :param uid: current user id - :param ids: id or a list of ids + :param ids: id or list of ids :param context(optional, highly recommended): context arguments, like lang, time zone :return: True :raise AccessError: * if user has no unlink rights on the requested object @@ -2957,7 +2958,7 @@ class orm(orm_template): :type user: integer (example 1) :param ids: id or list of ids :param vals: dictionary of field values to update - :type vals: dictionary (example {'field_name':'value', ...}) + :type vals: dictionary (example {'field_name': 'value', ...}) :param context(optional, highly recommended): context arguments, like lang, time zone :return: True :raise AccessError: * if user has no write rights on the requested object @@ -3165,10 +3166,10 @@ class orm(orm_template): :param cr: database cursor :param user: current user id :type user: integer (example 1) - :param vals: dictionary for new record {'field_name':field_value, ...} - :type vals: dictionary (example {'field_name':field_value, ...}) - :param context(optional, highly recommended): context arguements, like lang, time zone - :type context: dictionary (example {'lang':'en_us', ...}) + :param vals: dictionary for new record {'field_name': field_value, ...} + :type vals: dictionary (example {'field_name': field_value, ...}) + :param context(optional, highly recommended): context arguments, like lang, time zone + :type context: dictionary (example {'lang': 'en_us', ...}) :return: id of new record created :raise AccessError: * if user has no create rights on the requested object * if user tries to bypass access rules for create on the requested object @@ -3538,8 +3539,8 @@ class orm(orm_template): :param order: optional columns to sort by (default: self._order=id ) :param context(optional, highly recommended): context arguments, like lang, time zone :param count: if True, returns only the number of records matching the criteria, not their ids - :return: id or a list of ids of records matching the criteria - :rtype: integer or a list of integers + :return: id or list of ids of records matching the criteria + :rtype: integer or list of integers :raise AccessError: * if user tries to bypass access rules for read on the requested object. Operators: @@ -3602,7 +3603,7 @@ class orm(orm_template): :param cr: database cursor :param user: current user id :type user: integer (example 1) - :param ids: a list of ids + :param ids: list of ids :param context: context arguments, like lang, time zone :return: tuples with the text representation of requested objects for to-many relationships @@ -3622,11 +3623,11 @@ class orm(orm_template): :param cr: database cursor :param user: current user id :param name: object name to search - :param args: a list of tuples specifying search criteria [('field_name', 'operator', 'value'), ...] + :param args: list of tuples specifying search criteria [('field_name', 'operator', 'value'), ...] :param operator: operator for search criterion :param context: context arguments, like lang, time zone :param limit: optional max number of records to return - :return: a list of object names matching the search criteria, used to provide completition for to-many relationships + :return: list of object names matching the search criteria, used to provide completion for to-many relationships This method is equivalent of search() on name + name_get() @@ -3649,9 +3650,9 @@ class orm(orm_template): :param cr: database cursor :param user: current user id :param ids: id of the record to copy - :param default: a dictionary of field values to update before saving the duplicate object + :param default: dictionary of field values to update before saving the duplicate object :param context: context arguments, like lang, time zone - :return: a dictionary containing all the field values + :return: dictionary containing all the field values """ if not context: @@ -3731,8 +3732,8 @@ class orm(orm_template): :param cr: database cursor :param uid: current user id :param id: id of the record to copy - :param default: a dictionary of field values to update before saving the duplicate object - :type default: a dictionary (example {'field_name':field_value, ...}) + :param default: dictionary of field values to update before saving the duplicate object + :type default: dictionary (example {'field_name': field_value, ...}) :param context: context arguments, like lang, time zone :return: True @@ -3756,7 +3757,7 @@ class orm(orm_template): :param cr: database cursor :param uid: current user id - :param ids: a list of ids of records + :param ids: list of ids of records :param parent: parent field name :return: True or False based on recursion detection """