From b7489580822088c01baf8149a8b38351d165dc93 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Thu, 18 Mar 2010 18:39:33 +0100 Subject: [PATCH 01/11] [REF] hr,hr_attendance,hr_expense,hr_holidays,hr_timesheets,stock: Review some layouts bzr revid: stephane@openerp.com-20100318173933-5mdevsd8oeon8vu7 --- addons/hr/hr_view.xml | 50 +++++++------ addons/hr_attendance/hr_attendance.py | 8 +++ addons/hr_attendance/hr_attendance_view.xml | 10 ++- addons/hr_expense/hr_expense_view.xml | 70 ++++++++++--------- addons/hr_holidays/hr_view.xml | 45 ++++++------ addons/hr_holidays/wizard/holidays_summary.py | 4 +- .../wizard/holidays_summary_employees.py | 4 +- .../hr_timesheet_sheet_view.xml | 16 ++--- .../report/report_stock_picking_view.xml | 4 +- 9 files changed, 119 insertions(+), 92 deletions(-) diff --git a/addons/hr/hr_view.xml b/addons/hr/hr_view.xml index f98150f815b..ce12d776baf 100644 --- a/addons/hr/hr_view.xml +++ b/addons/hr/hr_view.xml @@ -38,20 +38,6 @@ - - - - - - - - - - - - - - @@ -62,6 +48,13 @@ + + + + + + + @@ -70,6 +63,14 @@ + + + + + + + + @@ -87,10 +88,11 @@ - + + @@ -101,18 +103,18 @@ search - - - - - - - - + + + + + + + + @@ -152,6 +154,7 @@ form tree,form [] + + + + Partner + res.partner diff --git a/bin/addons/base/res/partner/partner_demo.xml b/bin/addons/base/res/partner/partner_demo.xml index f76b4a04e64..c6de312bc4c 100644 --- a/bin/addons/base/res/partner/partner_demo.xml +++ b/bin/addons/base/res/partner/partner_demo.xml @@ -4,7 +4,7 @@ - + Customer @@ -43,7 +43,7 @@ Bad customers - + Supplier @@ -59,12 +59,12 @@ Textile Suppliers - - + + - + ASUStek @@ -177,12 +177,12 @@ Université de Liège - - + + - + Bruxelles Michel Schumacher @@ -349,6 +349,15 @@ Université de Liège - + + + + + ASUSTEK-Subject + + res.partner,2 + diff --git a/bin/addons/base/test/base_test.xml b/bin/addons/base/test/base_test.xml new file mode 100644 index 00000000000..d3c1df9bd21 --- /dev/null +++ b/bin/addons/base/test/base_test.xml @@ -0,0 +1,14 @@ + + + + + + + + ASUStek + + + + \ No newline at end of file From 16749901c7f77b6bf85aa6d82894a23142950259 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 1 Apr 2010 14:00:24 +0200 Subject: [PATCH 03/11] [FIX] changed loglevel to debug for missing module descriptor messages bzr revid: odo@openerp.com-20100401120024-6s60u16p29t6mvkt --- bin/addons/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index e07fdd07bbc..b599a1002cc 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -306,7 +306,10 @@ def load_information_from_description_file(module): if os.path.isfile(description_file): return eval(tools.file_open(description_file).read()) - logging.warning('The module %s does not contain a description file: __openerp__.py or __terp__.py (deprecated)' % module) + #TODO: refactor the logger in this file to follow the logging guidelines + # for 6.0 + logging.getLogger('addons').debug('The module %s does not contain a description file:'\ + '__openerp__.py or __terp__.py (deprecated)', module) return {} def get_modules_with_version(): From d74b2824048b43e9df4a6090a327ec572500bd21 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 1 Apr 2010 17:08:54 +0200 Subject: [PATCH 04/11] [IMP] spellchecked error messages and made logging compliant according to new logging in 6.0 bzr revid: odo@openerp.com-20100401150854-ob4184vyir37jkjo --- bin/osv/osv.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bin/osv/osv.py b/bin/osv/osv.py index 493db9fcdf4..9d625c5541b 100644 --- a/bin/osv/osv.py +++ b/bin/osv/osv.py @@ -57,8 +57,7 @@ class osv_pool(netsvc.Service): return f(self, dbname, *args, **kwargs) except orm.except_orm, inst: if inst.name == 'AccessError': - tb_s = "AccessError\n" + "".join(traceback.format_exception(*sys.exc_info())) - self.logger.notifyChannel('web-services', netsvc.LOG_DEBUG, tb_s) + self.logger.debug("AccessError", exc_info=True) self.abortResponse(1, inst.name, 'warning', inst.value) except except_osv, inst: self.abortResponse(1, inst.name, inst.exc_type, inst.value) @@ -68,8 +67,7 @@ class osv_pool(netsvc.Service): self.abortResponse(1, 'Constraint Error', 'warning', self._sql_error[key]) self.abortResponse(1, 'Integrity Error', 'warning', inst[0]) except Exception, e: - tb_s = "".join(traceback.format_exception(*sys.exc_info())) - self.logger.notifyChannel('web-services', netsvc.LOG_ERROR, tb_s) + self.logger.exception("Uncaught exception") raise return wrapper @@ -84,7 +82,7 @@ class osv_pool(netsvc.Service): self._store_function = {} self._init = True self._init_parent = {} - self.logger = netsvc.Logger() + self.logger = logging.getLogger("web-services") netsvc.Service.__init__(self, 'object_proxy', audience='') self.exportMethod(self.obj_list) self.exportMethod(self.exec_workflow) @@ -116,11 +114,10 @@ class osv_pool(netsvc.Service): try: try: if method.startswith('_'): - raise except_osv('Method Error', 'Private method %s can not be calleble.' % (method,)) + raise except_osv('Access Denied', 'Private methods (such as %s) cannot be called remotely.' % (method,)) res = pool.execute_cr(cr, uid, obj, method, *args, **kw) if res is None: - self.logger.notifyChannel("web-services", netsvc.LOG_WARNING, - 'Method can not return a None value (crash in XML-RPC)') + self.logger.warning('RPC methods cannot return `None` at the moment!') cr.commit() except Exception: cr.rollback() From e1aa0bd19a1e90a2d2f433149bd0646734d86140 Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Fri, 2 Apr 2010 12:38:23 +0530 Subject: [PATCH 05/11] [FIX]: missing import logging bzr revid: nch@tinyerp.com-20100402070823-106ezqymrkhk6yql --- bin/osv/osv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/osv/osv.py b/bin/osv/osv.py index 9d625c5541b..a528d418089 100644 --- a/bin/osv/osv.py +++ b/bin/osv/osv.py @@ -29,7 +29,7 @@ import pooler import copy import sys import traceback - +import logging from psycopg2 import IntegrityError from tools.func import wraps From 35bab1e92d629371a0f67754d07b37c4c33f6a68 Mon Sep 17 00:00:00 2001 From: "RVO(OpenERP)" <> Date: Fri, 2 Apr 2010 19:24:12 +0530 Subject: [PATCH 06/11] Added docstring in public methods of orm bzr revid: hda@tinyerp.com-20100402135412-sndekigkmxf5twb2 --- bin/osv/orm.py | 299 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 285 insertions(+), 14 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 32efe32558b..af3ca7ec6dc 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -501,6 +501,16 @@ class orm_template(object): self._table = self._name.replace('.', '_') def browse(self, cr, uid, select, context=None, list_class=None, fields_process={}): + """ + Fetch records as objects allowing to use dot notation to browse fields and relations + + :param cr: database cursor + :param user: current user id + :param select: id or a list of ids + :param context: context arguments, like lang, time zone + :rtype: object or a list of objects requested + + """ if not context: context = {} self._list_class = list_class or browse_record_list @@ -616,6 +626,19 @@ class orm_template(object): return [data] + lines def export_data(self, cr, uid, ids, fields_to_export, context=None): + """ + Export fields for selected objects + + :param cr: database cursor + :param uid: current user id + :param ids: a list of ids + :param fields_to_export: a 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 + + This method is used when exporting data via client menu + + """ if not context: context = {} imp_comp = context.get('import_comp',False) @@ -645,6 +668,24 @@ class orm_template(object): return {'datas':datas} def import_data(self, cr, uid, fields, datas, mode='init', current_module='', noupdate=False, context=None, filename=None): + """ + Import given data in given module + + :param cr: database cursor + :param uid: current user id + :param ids: a list of ids + :param fields: a 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 + + This method is used when importing data via client menu + + """ if not context: context = {} fields = map(lambda x: x.split('/'), fields) @@ -984,16 +1025,13 @@ class orm_template(object): self._invalids.clear() def default_get(self, cr, uid, fields_list, context=None): - """ Set default values for the object's fields. + """ + Set default values for the object's fields. - Returns a dict of {field_name:default_value} + :param fields_list: fields for which the object doesn't have any value yet, and default values need to be provided. + If fields outside this list are returned, the user-provided values will be overwritten. + :rtype: a dict of {field_name:default_value} - Arguments: - `fields_list`: the fields for which the object doesn't have - any value yet, and default values need to be - provided. If fields outside this list are - returned, the user-provided values will be - overwritten. """ return {} @@ -1081,6 +1119,7 @@ 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 # @@ -1316,6 +1355,23 @@ class orm_template(object): # if view_id, view_type is not required # def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + """ + Get the detailed composition of the requested view like fields, model, view architecture + + :param cr: database cursor + :param user: current user id + :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 submenu: example (portal_project module) + :return: a 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 + :raise Invalid ArchitectureError: if there is view type other than form, tree, calendar, search etc defined on the structure + + """ if not context: context = {} @@ -1878,6 +1934,28 @@ class orm(orm_template): _protected = ['read','write','create','default_get','perm_read','unlink','fields_get','fields_view_get','search','name_get','distinct_field_get','name_search','copy','import_data','search_count', 'exists'] 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 + + :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 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: + + * 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' + :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 + + """ groupby_list = groupby groupby = groupby[0] context = context or {} @@ -1953,10 +2031,13 @@ class orm(orm_template): return data def _inherits_join_calc(self, field, tables, where_clause): - """ Adds missing table select and join clause(s) for reaching + """ + Adds missing table select and join clause(s) for reaching the field coming from an '_inherits' parent table. - @param tables: list of table._table names enclosed in double quotes as returned + + :param tables: a list of table._table names enclosed in double quotes as returned by _where_calc() + """ current_table = self while field in current_table._inherit_fields and not field in current_table._columns: @@ -2411,6 +2492,17 @@ class orm(orm_template): self._columns[f].restart() def default_get(self, cr, uid, fields_list, context=None): + """ + Get default field values of the given field 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', ...]) + :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) + + """ if not context: context = {} value = {} @@ -2502,12 +2594,38 @@ class orm(orm_template): self._inherits_reload_src() def fields_get(self, cr, user, fields=None, context=None): + """ + Get the description of list of fields + + :param cr: database cursor + :param user: current user id + :param fields: a 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 + :raise AccessError: * if user has no create/write rights on the requested object + + """ ira = self.pool.get('ir.model.access') read_access = ira.check(cr, user, self._name, 'write', raise_exception=False, context=context) or \ ira.check(cr, user, self._name, 'create', raise_exception=False, context=context) return super(orm, self).fields_get(cr, user, fields, context, read_access) def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): + """ + Read records with given ids with the given fields + + :param cr: database cursor + :param user: current user id + :param ids: id or a 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', ...]) + :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 + :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 + + """ if not context: context = {} self.pool.get('ir.model.access').check(cr, user, self._name, 'read', context=context) @@ -2693,6 +2811,24 @@ class orm(orm_template): return res def perm_read(self, cr, user, ids, context=None, details=True): + """ + Read the permission for record of the given ids + + :param cr: database cursor + :param user: current user id + :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: + + * id: object id + * create_uid: user who created the record + * create_date: date when the record was created + * write_uid: last user who changed the record + * write_date: date of the last change to the record + + """ if not context: context = {} if not ids: @@ -2753,6 +2889,20 @@ class orm(orm_template): % (operation, self._name)) def unlink(self, cr, uid, ids, context=None): + """ + Delete records with given ids + + :param cr: database cursor + :param uid: current user id + :param ids: id or a 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 + * if user tries to bypass access rules for unlink on the requested object + :raise UserError: if the record is default property for other records + + """ + if not ids: return True if isinstance(ids, (int, long)): @@ -2799,6 +2949,30 @@ class orm(orm_template): # TODO: Validate # def write(self, cr, user, ids, vals, context=None): + """ + Update records with given ids with the given field values + + :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 context(optional, highly recommended): context arguments, like lang, time zone + :return: True + :raise AccessError: * if user has no write rights on the requested object + * if user tries to bypass access rules for write on the requested object + :raise ValidateError: if user tries to enter invalid value for a field that is not in selection + :raise UserError: if recurssion is found + + vals format for relational field type. + + + many2many field : [(6, 0, list of ids)] (example: [(6, 0, [8, 5, 6, 4])]) + + one2many field : [(0, 0, dictionary of values)] (example: [(0, 0, {'field_name':field_value, ...})]) + + many2one field : ID of related record + + reference field : model name, id (example: 'product.product, 5') + + """ readonly = None for field in vals.copy(): fobj = None @@ -2985,10 +3159,28 @@ class orm(orm_template): # TODO: Should set perm to user.xxx # def create(self, cr, user, vals, context=None): - """ create(cr, user, vals, context) -> int - cr = database cursor - user = user id - vals = dictionary of the form {'field_name':field_value, ...} + """ + Create new record with specified value + + :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 context(optional, highly recommended): context arguements, like lang, time zone + :type context: a 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 + :raise ValidateError: if user tries to enter invalid value for a field that is not in selection + + vals format for relational field type. + + + many2many field : [(6, 0, list of ids)] (example: [(6, 0, [8, 5, 6, 4])]) + + one2many field : [(0, 0, dictionary of values)] (example: [(0, 0, {'field_name':field_value, ...})]) + + many2one field : ID of related record + + reference field : model name, id (example: 'product.product, 5') + """ if not context: context = {} @@ -3333,6 +3525,27 @@ class orm(orm_template): def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): + """ + Search for record/s with or without domain + + :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 limit: optional max number of records to return + :param order: optional columns to sort by (default: self._order ) + :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 + :raise AccessError: * if user tries to bypass access rules for read on the requested object. + + Operators: + * =, !=, >, >=, <, <=, like, ilike, in, not in, child_of, parent_left, parent_right + Prefix operators: + * '&' (default), '|', '!' + + """ if not context: context = {} # compute the where, order by, limit and offset clauses @@ -3382,6 +3595,16 @@ class orm(orm_template): return self._columns[field].search(cr, self, args, field, value, offset, limit, uid) def name_get(self, cr, user, ids, context=None): + """ + + :param cr: database cursor + :param user: current user id + :type user: integer (example 1) + :param ids: a list of ids + :param context: context arguments, like lang, time zone + :return: tuples with the text representation of requested objects for to-many relationships + + """ if not context: context = {} if not ids: @@ -3392,6 +3615,20 @@ class orm(orm_template): [self._rec_name], context, load='_classic_write')] def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): + """ + + :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 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 + + This method is equivalent of search() on name + name_get() + + """ if not args: args = [] if not context: @@ -3404,6 +3641,17 @@ class orm(orm_template): return res def copy_data(self, cr, uid, id, default=None, context=None): + """ + Copy given record's data with all its fields values + + :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 context: context arguments, like lang, time zone + :return: a dictionary containing all the field values + """ + if not context: context = {} if not default: @@ -3475,6 +3723,18 @@ class orm(orm_template): return data, trans_data def copy(self, cr, uid, id, default=None, context=None): + """ + Duplicate record with given id updating it with default values + + :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 context: context arguments, like lang, time zone + :return: True + + """ trans_obj = self.pool.get('ir.translation') data, trans_data = self.copy_data(cr, uid, id, default, context) new_id = self.create(cr, uid, data, context) @@ -3489,6 +3749,16 @@ class orm(orm_template): return bool(cr.fetchone()[0]) def check_recursion(self, cr, uid, ids, parent=None): + """ + Check recursion in records + + :param cr: database cursor + :param uid: current user id + :param ids: a list of ids of records + :param parent: parent field name + :return: True or False based on recursion detection + """ + if not parent: parent = self._parent_name ids_parent = ids[:] @@ -3507,3 +3777,4 @@ class orm(orm_template): return True # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + From 1982e4bf3c559de1da266618e9b5de75eca9f14e Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Tue, 6 Apr 2010 12:32:31 +0530 Subject: [PATCH 07/11] [REVIEW]: code review bzr revid: mga@tinyerp.com-20100406070231-zurxtsmvqk0szjv7 --- addons/survey/survey.py | 101 +++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index f7bb9329436..a1db5bdcc86 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -97,7 +97,6 @@ class survey(osv.osv): survey() - class survey_history(osv.osv): _name = 'survey.history' _description = 'Survey History' @@ -110,7 +109,6 @@ class survey_history(osv.osv): _defaults = { 'date': lambda * a: datetime.datetime.now() } - survey_history() class survey_page(osv.osv): @@ -144,14 +142,14 @@ class survey_page(osv.osv): surv_name_wiz = self.pool.get('survey.name.wiz') surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'transfer':True, 'page_no' : context.get('page_number',0) }) return { - 'view_type': 'form', - "view_mode": 'form', - 'res_model': 'survey.question.wiz', - 'type': 'ir.actions.act_window', - 'target': 'new', - 'search_view_id': search_id[0], - 'context': context - } + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'survey.question.wiz', + 'type': 'ir.actions.act_window', + 'target': 'new', + 'search_view_id': search_id[0], + 'context': context + } def copy(self, cr, uid, id, default=None, context={}): raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!')) @@ -196,28 +194,28 @@ class survey_question(osv.osv): 'descriptive_text': fields.text('Descriptive Text', size=255), 'column_heading_ids': fields.one2many('survey.question.column.heading', 'question_id',' Column heading'), 'type': fields.selection([('multiple_choice_only_one_ans','Multiple Choice (Only One Answer)'), - ('multiple_choice_multiple_ans','Multiple Choice (Multiple Answer)'), - ('matrix_of_choices_only_one_ans','Matrix of Choices (Only One Answers Per Row)'), - ('matrix_of_choices_only_multi_ans','Matrix of Choices (Multiple Answers Per Row)'), - ('matrix_of_drop_down_menus','Matrix of Drop-down Menus'), - ('rating_scale','Rating Scale'),('single_textbox','Single Textbox'), - ('multiple_textboxes','Multiple Textboxes'), - ('multiple_textboxes_diff_type','Multiple Textboxes With Different Type'), - ('comment','Comment/Essay Box'), - ('numerical_textboxes','Numerical Textboxes'),('date','Date'), - ('date_and_time','Date and Time'),('descriptive_text','Descriptive Text'), - ('table','Table'), - ], 'Question Type', required=1,), + ('multiple_choice_multiple_ans','Multiple Choice (Multiple Answer)'), + ('matrix_of_choices_only_one_ans','Matrix of Choices (Only One Answers Per Row)'), + ('matrix_of_choices_only_multi_ans','Matrix of Choices (Multiple Answers Per Row)'), + ('matrix_of_drop_down_menus','Matrix of Drop-down Menus'), + ('rating_scale','Rating Scale'),('single_textbox','Single Textbox'), + ('multiple_textboxes','Multiple Textboxes'), + ('multiple_textboxes_diff_type','Multiple Textboxes With Different Type'), + ('comment','Comment/Essay Box'), + ('numerical_textboxes','Numerical Textboxes'),('date','Date'), + ('date_and_time','Date and Time'),('descriptive_text','Descriptive Text'), + ('table','Table'), + ], 'Question Type', required=1,), 'is_comment_require': fields.boolean('Add Comment Field (optional)'), 'comment_label': fields.char('Field Label', size = 255), 'comment_field_type': fields.selection([('char', 'Single Line Of Text'), ('text', 'Paragraph of Text')], 'Comment Field Type'), 'comment_valid_type': fields.selection([('do_not_validate', '''Don't Validate Comment Text.'''), - ('must_be_specific_length', 'Must Be Specific Length'), - ('must_be_whole_number', 'Must Be A Whole Number'), - ('must_be_decimal_number', 'Must Be A Decimal Number'), - ('must_be_date', 'Must Be A Date'), - ('must_be_email_address', 'Must Be An Email Address'), - ], 'Text Validation'), + ('must_be_specific_length', 'Must Be Specific Length'), + ('must_be_whole_number', 'Must Be A Whole Number'), + ('must_be_decimal_number', 'Must Be A Decimal Number'), + ('must_be_date', 'Must Be A Date'), + ('must_be_email_address', 'Must Be An Email Address'), + ], 'Text Validation'), 'comment_minimum_no': fields.integer('Minimum number'), 'comment_maximum_no': fields.integer('Maximum number'), 'comment_minimum_float': fields.float('Minimum decimal number'), @@ -229,12 +227,12 @@ class survey_question(osv.osv): 'make_comment_field_err_msg': fields.text('Error message'), 'is_validation_require': fields.boolean('Validate Text (optional)'), 'validation_type': fields.selection([('do_not_validate', '''Don't Validate Comment Text.'''),\ - ('must_be_specific_length', 'Must Be Specific Length'),\ - ('must_be_whole_number', 'Must Be A Whole Number'),\ - ('must_be_decimal_number', 'Must Be A Decimal Number'),\ - ('must_be_date', 'Must Be A Date'),\ - ('must_be_email_address', 'Must Be An Email Address')\ - ], 'Text Validation'), + ('must_be_specific_length', 'Must Be Specific Length'),\ + ('must_be_whole_number', 'Must Be A Whole Number'),\ + ('must_be_decimal_number', 'Must Be A Decimal Number'),\ + ('must_be_date', 'Must Be A Date'),\ + ('must_be_email_address', 'Must Be An Email Address')\ + ], 'Text Validation'), 'validation_minimum_no': fields.integer('Minimum number'), 'validation_maximum_no': fields.integer('Maximum number'), 'validation_minimum_float': fields.float('Minimum decimal number'), @@ -437,14 +435,14 @@ class survey_question(osv.osv): surv_name_wiz = self.pool.get('survey.name.wiz') surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'transfer':True, 'page_no' : context.get('page_number',False) }) return { - 'view_type': 'form', - "view_mode": 'form', - 'res_model': 'survey.question.wiz', - 'type': 'ir.actions.act_window', - 'target': 'new', - 'search_view_id': search_id[0], - 'context': context - } + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'survey.question.wiz', + 'type': 'ir.actions.act_window', + 'target': 'new', + 'search_view_id': search_id[0], + 'context': context + } def default_get(self, cr, uid, fields, context={}): data = super(survey_question, self).default_get(cr, uid, fields, context) @@ -453,7 +451,7 @@ class survey_question(osv.osv): data['sequence'] = context['line_order'][-1][2]['sequence'] + 1 if context.has_key('page_id'): - data['page_id']= context.get('page_id',False) + data['page_id']= context.get('page_id', False) return data survey_question() @@ -465,11 +463,11 @@ class survey_question_column_heading(osv.osv): _rec_name = 'title' def _get_in_visible_rating_weight(self,cr, uid, context={}): - if context.get('in_visible_rating_weight',False): + if context.get('in_visible_rating_weight', False): return context['in_visible_rating_weight'] return False def _get_in_visible_menu_choice(self,cr, uid, context={}): - if context.get('in_visible_menu_choice',False): + if context.get('in_visible_menu_choice', False): return context['in_visible_menu_choice'] return False @@ -485,7 +483,6 @@ class survey_question_column_heading(osv.osv): 'in_visible_rating_weight': _get_in_visible_rating_weight, 'in_visible_menu_choice': _get_in_visible_menu_choice, } - survey_question_column_heading() class survey_answer(osv.osv): @@ -496,7 +493,7 @@ class survey_answer(osv.osv): def _calc_response_avg(self, cr, uid, ids, field_name, arg, context): val = {} - for rec in self.browse(cr, uid, ids): + for rec in self.browse(cr, uid, ids, context): cr.execute("select count(question_id) ,(select count(answer_id) \ from survey_response_answer sra, survey_response_line sa \ where sra.response_id = sa.id and sra.answer_id = %d \ @@ -515,9 +512,7 @@ class survey_answer(osv.osv): return val def _get_in_visible_answer_type(self,cr, uid, context={}): - if context.get('in_visible_answer_type',False): - return context.get('in_visible_answer_type',False) - return False + return context.get('in_visible_answer_type', False) _columns = { 'question_id': fields.many2one('survey.question', 'Question', ondelete='cascade'), @@ -526,8 +521,8 @@ class survey_answer(osv.osv): 'response': fields.function(_calc_response_avg, method=True, string="#Answer", multi='sums'), 'average': fields.function(_calc_response_avg, method=True, string="#Avg", multi='sums'), 'type': fields.selection([('char','Character'),('date','Date'),('datetime','Date & Time'),\ - ('integer','Integer'),('float','Float'),('selection','Selection'),\ - ('email','Email')], "Type of Answer",required=1), + ('integer','Integer'),('float','Float'),('selection','Selection'),\ + ('email','Email')], "Type of Answer",required=1), 'menu_choice': fields.text('Menu Choices'), 'in_visible_answer_type': fields.boolean('Is Answer Type Invisible??') } @@ -539,7 +534,7 @@ class survey_answer(osv.osv): def default_get(self, cr, uid, fields, context={}): data = super(survey_answer, self).default_get(cr, uid, fields, context) - if context.get('line_order',False): + if context.get('line_order', False): if len(context['line_order'][-1]) > 2 and type(context['line_order'][-1][2]) == type({}) and context['line_order'][-1][2].has_key('sequence'): data['sequence'] = context['line_order'][-1][2]['sequence'] + 1 return data From 59e15ebce0e9c5f70378adef965a046c48703189 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Tue, 6 Apr 2010 14:31:56 +0530 Subject: [PATCH 08/11] [REVIEW]: code review bzr revid: mga@tinyerp.com-20100406090156-3wesrbw3ue8g739f --- addons/base_calendar/base_calendar.py | 339 +++++++++++++------------- 1 file changed, 169 insertions(+), 170 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index f7608219b9d..6a29b023301 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -31,9 +31,10 @@ import time import tools months = { - 1: "January", 2: "February", 3: "March", 4: "April", \ - 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", \ - 10: "October", 11: "November", 12: "December"} + 1: "January", 2: "February", 3: "March", 4: "April", \ + 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", \ + 10: "October", 11: "November", 12: "December" +} def get_recurrent_dates(rrulestring, exdate, startdate=None): """ @@ -94,7 +95,6 @@ def real_id2base_calendar_id(real_id, recurrent_date): return '%d-%s' % (real_id, recurrent_date) return real_id - def _links_get(self, cr, uid, context={}): """ Get request link. @@ -385,9 +385,11 @@ request was delegated to"), response_re = re.compile("Are you coming\?.*\n*.*(YES|NO|MAYBE).*", re.UNICODE) def msg_new(self, cr, uid, msg): - """ @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, """ + """ + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + """ return False def msg_act_get(self, msg): @@ -446,25 +448,25 @@ request was delegated to"), (att2.partner_id and att2.partner_id.name) or \ att2.email) + ' - Status: ' + att2.state.title()) body_vals = {'name': res_obj.name, - 'start_date': res_obj.date, - 'end_date': res_obj.date_deadline or False, - 'description': res_obj.description or '-', - 'location': res_obj.location or '-', - 'attendees': '
'.join(att_infos), - 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', - 'sign': sign, - 'company': company + 'start_date': res_obj.date, + 'end_date': res_obj.date_deadline or False, + 'description': res_obj.description or '-', + 'location': res_obj.location or '-', + 'attendees': '
'.join(att_infos), + 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', + 'sign': sign, + 'company': company } body = html_invitation % body_vals if mail_to and email_from: tools.email_send( - email_from, - mail_to, - sub, - body, - subtype='html', - reply_to=email_from - ) + email_from, + mail_to, + sub, + body, + subtype='html', + reply_to=email_from + ) return True def onchange_user_id(self, cr, uid, ids, user_id, *args, **argv): """ @@ -507,7 +509,6 @@ request was delegated to"), for vals in self.browse(cr, uid, ids, context=context): user = vals.user_id if user: - mod_obj = self.pool.get(vals.ref._name) if vals.ref: if vals.ref.user_id.id != user.id: @@ -562,9 +563,7 @@ class res_alarm(osv.osv): are both optional, but if one occurs, so MUST the other"""), 'repeat': fields.integer('Repeat'), 'active': fields.boolean('Active', help="If the active field is set to \ - true, it will allow you to hide the event alarm information without removing it."), - - + true, it will allow you to hide the event alarm information without removing it.") } _defaults = { 'trigger_interval': lambda *x: 'minutes', @@ -590,10 +589,10 @@ are both optional, but if one occurs, so MUST the other"""), model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0] model_obj = self.pool.get(model) - for data in model_obj.browse(cr, uid, ids): + for data in model_obj.browse(cr, uid, ids, context): basic_alarm = data.alarm_id - if not context.get('alarm_id'): + if not context.get('alarm_id', False): self.do_alarm_unlink(cr, uid, [data.id], model) return True self.do_alarm_unlink(cr, uid, [data.id], model) @@ -636,7 +635,7 @@ are both optional, but if one occurs, so MUST the other"""), ir_obj = self.pool.get('ir.model') model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0] model_obj = self.pool.get(model) - for datas in model_obj.browse(cr, uid, ids): + for datas in model_obj.browse(cr, uid, ids, context): alarm_ids = alarm_obj.search(cr, uid, [('model_id', '=', model_id), ('res_id', '=', datas.id)]) if alarm_ids: alarm_obj.unlink(cr, uid, alarm_ids) @@ -654,35 +653,35 @@ class calendar_alarm(osv.osv): __attribute__ = {} _columns = { - 'alarm_id': fields.many2one('res.alarm', 'Basic Alarm', ondelete='cascade'), - 'name': fields.char('Summary', size=124, help="""Contains the text to be \ - used as the message subject for email \ - or contains the text to be used for display"""), - 'action': fields.selection([('audio', 'Audio'), ('display', 'Display'), \ - ('procedure', 'Procedure'), ('email', 'Email') ], 'Action', \ - required=True, help="Defines the action to be invoked when an alarm is triggered"), - 'description': fields.text('Description', help='Provides a more complete \ - description of the calendar component, than that \ - provided by the "SUMMARY" property'), - 'attendee_ids': fields.many2many('calendar.attendee', 'alarm_attendee_rel', \ - 'alarm_id', 'attendee_id', 'Attendees', readonly=True), - 'attach': fields.binary('Attachment', help="""* Points to a sound resource,\ - which is rendered when the alarm is triggered for audio, - * File which is intended to be sent as message attachments for email, - * Points to a procedure resource, which is invoked when\ - the alarm is triggered for procedure."""), - 'res_id': fields.integer('Resource ID'), - 'model_id': fields.many2one('ir.model', 'Model'), - 'user_id': fields.many2one('res.users', 'Owner'), - 'event_date': fields.datetime('Event Date'), - 'event_end_date': fields.datetime('Event End Date'), - 'trigger_date': fields.datetime('Trigger Date', readonly="True"), - 'state':fields.selection([ - ('draft', 'Draft'), - ('run', 'Run'), - ('stop', 'Stop'), - ('done', 'Done'), - ], 'State', select=True, readonly=True), + 'alarm_id': fields.many2one('res.alarm', 'Basic Alarm', ondelete='cascade'), + 'name': fields.char('Summary', size=124, help="""Contains the text to be \ + used as the message subject for email \ + or contains the text to be used for display"""), + 'action': fields.selection([('audio', 'Audio'), ('display', 'Display'), \ + ('procedure', 'Procedure'), ('email', 'Email') ], 'Action', \ + required=True, help="Defines the action to be invoked when an alarm is triggered"), + 'description': fields.text('Description', help='Provides a more complete \ + description of the calendar component, than that \ + provided by the "SUMMARY" property'), + 'attendee_ids': fields.many2many('calendar.attendee', 'alarm_attendee_rel', \ + 'alarm_id', 'attendee_id', 'Attendees', readonly=True), + 'attach': fields.binary('Attachment', help="""* Points to a sound resource,\ + which is rendered when the alarm is triggered for audio, + * File which is intended to be sent as message attachments for email, + * Points to a procedure resource, which is invoked when\ + the alarm is triggered for procedure."""), + 'res_id': fields.integer('Resource ID'), + 'model_id': fields.many2one('ir.model', 'Model'), + 'user_id': fields.many2one('res.users', 'Owner'), + 'event_date': fields.datetime('Event Date'), + 'event_end_date': fields.datetime('Event End Date'), + 'trigger_date': fields.datetime('Trigger Date', readonly="True"), + 'state':fields.selection([ + ('draft', 'Draft'), + ('run', 'Run'), + ('stop', 'Stop'), + ('done', 'Done'), + ], 'State', select=True, readonly=True), } _defaults = { @@ -717,15 +716,14 @@ class calendar_alarm(osv.osv): def do_run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, \ context=None): """ - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of calendar alarm’s IDs. - @param use_new_cursor: False or the dbname - @param context: A standard dictionary for contextual values + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of calendar alarm’s IDs. + @param use_new_cursor: False or the dbname + @param context: A standard dictionary for contextual values """ - if not context: context = {} current_datetime = datetime.now().strftime('%Y-%m-%d %H:%M:%S') @@ -793,7 +791,6 @@ class calendar_event(osv.osv): def _tz_get(self, cr, uid, context={}): return [(x.lower(), x) for x in pytz.all_timezones] - def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, context={}): """ @param self: The object pointer @@ -892,10 +889,10 @@ class calendar_event(osv.osv): whr = " where id=%(id)s" qry = qry + whr val.update({ - 'table': self._table, - 'rule_type': rrule_type, - 'id': id, - }) + 'table': self._table, + 'rule_type': rrule_type, + 'id': id, + }) cr.execute(qry % val) return True @@ -909,9 +906,7 @@ class calendar_event(osv.osv): @return: dictionary of rrule value. """ result = {} - for event in ids: - - datas = self.read(cr, uid, event) + for datas in self.read(cr, uid, ids): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False @@ -935,11 +930,10 @@ class calendar_event(osv.osv): 'duration': fields.float('Duration'), 'description': fields.text('Your action'), 'class': fields.selection([('public', 'Public'), ('private', 'Private'), \ - ('confidential', 'Confidential')], 'Mark as'), + ('confidential', 'Confidential')], 'Mark as'), 'location': fields.char('Location', size=264, help="Location of Event"), 'show_as': fields.selection([('free', 'Free'), \ - ('busy', 'Busy')], - 'Show as'), + ('busy', 'Busy')], 'Show as'), 'base_calendar_url': fields.char('Caldav URL', size=264), 'exdate': fields.text('Exception Date/Times', help="This property \ defines the list of date/time exceptions for arecurring calendar component."), @@ -948,8 +942,8 @@ class calendar_event(osv.osv): 'rrule': fields.function(_get_rulestring, type='char', size=124, method=True,\ string='Recurrent Rule', store=True, fnct_inv=_set_rrulestring), 'rrule_type': fields.selection([('none', ''), ('daily', 'Daily'), \ - ('weekly', 'Weekly'), ('monthly', 'Monthly'), \ - ('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'), + ('weekly', 'Weekly'), ('monthly', 'Monthly'), \ + ('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'), 'alarm_id': fields.many2one('res.alarm', 'Alarm'), 'base_calendar_alarm_id': fields.many2one('calendar.alarm', 'Alarm'), 'recurrent_uid': fields.integer('Recurrent ID'), @@ -958,13 +952,13 @@ class calendar_event(osv.osv): string='Timezone', store=True), 'user_id': fields.many2one('res.users', 'Responsible'), 'freq': fields.selection([('None', 'No Repeat'), \ - ('secondly', 'Secondly'), \ - ('minutely', 'Minutely'), \ - ('hourly', 'Hourly'), \ - ('daily', 'Daily'), \ - ('weekly', 'Weekly'), \ - ('monthly', 'Monthly'), \ - ('yearly', 'Yearly')], 'Frequency'), + ('secondly', 'Secondly'), \ + ('minutely', 'Minutely'), \ + ('hourly', 'Hourly'), \ + ('daily', 'Daily'), \ + ('weekly', 'Weekly'), \ + ('monthly', 'Monthly'), \ + ('yearly', 'Yearly')], 'Frequency'), 'interval': fields.integer('Interval'), 'count': fields.integer('Count'), 'mo': fields.boolean('Mon'), @@ -975,19 +969,18 @@ class calendar_event(osv.osv): 'sa': fields.boolean('Sat'), 'su': fields.boolean('Sun'), 'select1': fields.selection([('date', 'Date of month'), \ - ('day', 'Day of month')], 'Option'), + ('day', 'Day of month')], 'Option'), 'day': fields.integer('Date of month'), 'week_list': fields.selection([('MO', 'Monday'), ('TU', 'Tuesday'), \ - ('WE', 'Wednesday'), ('TH', 'Thursday'), \ - ('FR', 'Friday'), ('SA', 'Saturday'), \ - ('SU', 'Sunday')], 'Weekday'), + ('WE', 'Wednesday'), ('TH', 'Thursday'), \ + ('FR', 'Friday'), ('SA', 'Saturday'), \ + ('SU', 'Sunday')], 'Weekday'), 'byday': fields.selection([('1', 'First'), ('2', 'Second'), \ - ('3', 'Third'), ('4', 'Fourth'), \ - ('5', 'Fifth'), ('-1', 'Last')], 'By day'), + ('3', 'Third'), ('4', 'Fourth'), \ + ('5', 'Fifth'), ('-1', 'Last')], 'By day'), 'month_list': fields.selection(months.items(), 'Month'), 'end_date': fields.date('Repeat Until') } - _defaults = { 'class': lambda *a: 'public', 'show_as': lambda *a: 'busy', @@ -1011,11 +1004,11 @@ class calendar_event(osv.osv): event_id = base_calendar_id2real_id(event_id) datas = self.read(cr, uid, event_id, context=context) defaults.update({ - 'recurrent_uid': base_calendar_id2real_id(datas['id']), - 'recurrent_id': defaults.get('date') or real_date, - 'rrule_type': 'none', - 'rrule': '' - }) + 'recurrent_uid': base_calendar_id2real_id(datas['id']), + 'recurrent_id': defaults.get('date') or real_date, + 'rrule_type': 'none', + 'rrule': '' + }) exdate = datas['exdate'] and datas['exdate'].split(',') or [] if real_date and defaults.get('date'): exdate.append(real_date) @@ -1031,7 +1024,7 @@ class calendar_event(osv.osv): @param event_ids: List of crm meeting’s IDs. @return: True """ - #start Loop + for event_id in event_ids: event_id = base_calendar_id2real_id(event_id) @@ -1046,7 +1039,7 @@ class calendar_event(osv.osv): qry += ", location = '%(location)s'" qry += "WHERE id = %s" % (event_id) cr.execute(qry %(defaults)) - #End Loop + return True def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): @@ -1143,7 +1136,7 @@ class calendar_event(osv.osv): weekstring = '' monthstring = '' yearstring = '' -# logic for computing rrule string + freq = datas.get('freq') if freq == 'None': return '' @@ -1183,7 +1176,6 @@ class calendar_event(osv.osv): rrule_string = 'FREQ=' + freq.upper() + weekstring + ';INTERVAL=' + \ str(datas.get('interval')) + enddate + monthstring + yearstring -# End logic return rrule_string @@ -1376,13 +1368,14 @@ class calendar_todo(osv.osv): _description = "Calendar Task" def _get_date(self, cr, uid, ids, name, arg, context): - """ Get Date - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of calendar todo's IDs. - @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. - @param context: A standard dictionary for contextual values + """ + Get Date + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of calendar todo's IDs. + @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. + @param context: A standard dictionary for contextual values """ res = {} @@ -1391,14 +1384,15 @@ class calendar_todo(osv.osv): return res def _set_date(self, cr, uid, id, name, value, arg, context): - """ Set Date - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param id: calendar's ID. - @param value: Get Value - @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. - @param context: A standard dictionary for contextual values + """ + Set Date + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param id: calendar's ID. + @param value: Get Value + @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. + @param context: A standard dictionary for contextual values """ event = self.browse(cr, uid, id, context=context) @@ -1422,11 +1416,12 @@ class ir_attachment(osv.osv): _inherit = 'ir.attachment' def search_count(self, cr, user, args, context=None): - """ @param self: The object pointer - @param cr: the current row, from the database cursor, - @param user: the current user’s ID for security checks, - @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. - @param context: A standard dictionary for contextual values + """ + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param user: the current user’s ID for security checks, + @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. + @param context: A standard dictionary for contextual values """ args1 = [] @@ -1436,14 +1431,14 @@ class ir_attachment(osv.osv): def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): - - """ @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. - @param offset: The Number of Results to pass, - @param limit: The Number of Results to Return, - @param context: A standard dictionary for contextual values + """ + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. + @param offset: The Number of Results to pass, + @param limit: The Number of Results to Return, + @param context: A standard dictionary for contextual values """ new_args = args @@ -1460,12 +1455,13 @@ class ir_values(osv.osv): def set(self, cr, uid, key, key2, name, models, value, replace=True, \ isobject=False, meta=False, preserve_user=False, company=False): - - """ set IR Values - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param model: Get The Model """ + """ + Set IR Values + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param model: Get The Model + """ new_model = [] for data in models: @@ -1478,12 +1474,13 @@ class ir_values(osv.osv): def get(self, cr, uid, key, key2, models, meta=False, context={}, \ res_id_req=False, without_user=True, key2_req=True): - - """ Get IR Values - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param model: Get The Model """ + """ + Get IR Values + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param model: Get The Model + """ new_model = [] for data in models: @@ -1502,14 +1499,14 @@ class ir_model(osv.osv): def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'): - - """ Read IR Model - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of IR Model’s IDs. - @param context: A standard dictionary for contextual values """ - + """ + Read IR Model + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of IR Model’s IDs. + @param context: A standard dictionary for contextual values + """ data = super(ir_model, self).read(cr, uid, ids, fields=fields, \ context=context, load=load) @@ -1523,13 +1520,13 @@ ir_model() class virtual_report_spool(web_services.report_spool): def exp_report(self, db, uid, object, ids, datas=None, context=None): - - """ Export Report - @param self: The object pointer - @param db: get the current database, - @param uid: the current user’s ID for security checks, - @param context: A standard dictionary for contextual values """ - + """ + Export Report + @param self: The object pointer + @param db: get the current database, + @param uid: the current user’s ID for security checks, + @param context: A standard dictionary for contextual values + """ if object == 'printscreen.list': return super(virtual_report_spool, self).exp_report(db, uid, \ @@ -1547,13 +1544,14 @@ class res_users(osv.osv): _inherit = 'res.users' def _get_user_avail(self, cr, uid, ids, context=None): - - """ Get USer Availability - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of res user’s IDs. - @param context: A standard dictionary for contextual values """ + """ + Get USer Availability + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of res user’s IDs. + @param context: A standard dictionary for contextual values + """ current_datetime = datetime.now().strftime('%Y-%m-%d %H:%M:%S') res = {} @@ -1577,13 +1575,14 @@ class res_users(osv.osv): return res def _get_user_avail_fun(self, cr, uid, ids, name, args, context=None): - - """ Get USer Availability Function - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of res user’s IDs. - @param context: A standard dictionary for contextual values """ + """ + Get USer Availability Function + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of res user’s IDs. + @param context: A standard dictionary for contextual values + """ return self._get_user_avail(cr, uid, ids, context=context) From 4fcdc4055eff4420943e91476c0874f7381ff0c4 Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Tue, 6 Apr 2010 17:20:04 +0200 Subject: [PATCH 09/11] [FIX] l10n_be: periodical vat declaration, compliancy with version 5.1.0 of Intervat bzr revid: qdp-launchpad@tinyerp.com-20100406152004-pad9ocx398bpiowa --- addons/l10n_be/company.py | 8 +++-- .../wizard/l10n_be_account_vat_declaration.py | 30 +++++++++---------- .../l10n_be_account_vat_declaration_view.xml | 5 +++- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/addons/l10n_be/company.py b/addons/l10n_be/company.py index 4395f13380e..1a29940ada6 100644 --- a/addons/l10n_be/company.py +++ b/addons/l10n_be/company.py @@ -25,7 +25,7 @@ class res_company(osv.osv): _description = 'res.company' def _get_default_ad(self, addresses): - city = post_code = address = "" + city = post_code = address = country_code = "" for ads in addresses: if ads.type == 'default': city = ads.city or "" @@ -34,7 +34,9 @@ class res_company(osv.osv): address = ads.street or "" if ads.street2: address += " " + ads.street2 - return city, post_code, address + if ads.country_id: + country_code = ads.country_id and ads.country_id.code or "" + return city, post_code, address, country_code res_company() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py index 9dd5ea5b269..b1674293291 100644 --- a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py +++ b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py @@ -32,6 +32,9 @@ class l10n_be_vat_declaration(osv.osv_memory): 'period_id': fields.many2one('account.period','Period', required=True), 'msg': fields.text('File created', size=64, readonly=True), 'file_save': fields.binary('Save File'), + 'ask_resitution': {'type': 'boolean', 'string': 'Ask Restitution',}, + 'ask_payment': {'type': 'boolean', 'string': 'Ask Payment',}, + 'client_nihil': {'type': 'boolean', 'string': 'Last Declaration of Entreprise', 'help': 'Thick this case only if it concerns only the last statement on the civil or cessation of activity'}, } _defaults = { @@ -46,7 +49,7 @@ class l10n_be_vat_declaration(osv.osv_memory): obj_comp = self.pool.get('res.company') obj_data = self.pool.get('ir.model.data') - list_of_tags=['00','01','02','03','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','91'] + list_of_tags=['00','01','02','03','44','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','88','91'] obj_company = obj_user.browse(cr, uid, uid, context=context).company_id user_cmpny = obj_company.name vat_no=obj_company.partner_id.vat @@ -59,26 +62,19 @@ class l10n_be_vat_declaration(osv.osv_memory): ctx['period_id'] = data['period_id'] #added context here tax_info = obj_tax_code.read(cr, uid, tax_code_ids, ['code','sum_period'], context=ctx) - address = post_code = city = '' - if not obj_company.partner_id.address: - address = post_code = city = '' - - city, post_code, address = obj_comp._get_default_ad(obj_company.partner_id.address) + address = post_code = city = country_code = '' + city, post_code, address, country_code = obj_comp._get_default_ad(obj_company.partner_id.address) year_id = obj_fyear.find(cr, uid) account_period = obj_acc_period.browse(cr, uid, data['period_id'], context=context) - current_year = account_period.fiscalyear_id.name period_code = account_period.code - send_ref = user_cmpny - if period_code: - send_ref = send_ref + period_code - + send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4]) data_of_file='\n' data_of_file +='\n\t\n\t\t'+str(vat_no)+'\n\t\t'+str(obj_company.name)+'\n\t\t
'+address+'
' - data_of_file +='\n\t\t'+post_code+'\n\t\t'+city+'\n\t\t'+send_ref+'\n\t
' - data_of_file +='\n\t\n\t\t1\n\t\t'+str(vat_no)+'\n\t\t\n\t\t\t' - + data_of_file +='\n\t\t'+post_code+'\n\t\t'+city+'\n\t\t'+country_code+'\n\t\t'+send_ref+'\n\t' + data_of_file +='\n\t\n\t\t1\n\t\t'+str(vat_no[2:])+'\n\t\t\n\t\t\t' + starting_month = account_period.date_start[5:7] ending_month = account_period.date_stop[5:7] if starting_month != ending_month: @@ -89,14 +85,16 @@ class l10n_be_vat_declaration(osv.osv_memory): else: data_of_file += '' + starting_month + '\n\t\t\t' data_of_file += '' + str(account_period.date_stop[:4]) + '\n\t\t\n\t\t' + data_of_file += '\n\t\t'+ (data['form']['client_nihil'] and 'YES' or 'NO') +'' data_of_file +='\n\t\t\n\t\t\t' for item in tax_info: if item['code']: + if item['code'] == '71-72': item['code'] = '71' if item['code'] in list_of_tags: - data_of_file +='\n\t\t\t\t' + str(int(item['sum_period']*100)) + '' + data_of_file +='\n\t\t\t\t' + str(abs(int(item['sum_period']*100))) + '' data_of_file +='\n\t\t\t\n\t\t\n\t\n
' data['file_save'] = base64.encodestring(data_of_file) @@ -105,4 +103,4 @@ class l10n_be_vat_declaration(osv.osv_memory): l10n_be_vat_declaration() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml b/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml index 56f8b6477f9..3f33448f8d3 100644 --- a/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml +++ b/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml @@ -15,6 +15,9 @@
+ + +