diff options
| author | Antonin Bourguignon <abo@openerp.com> | 2012-10-02 14:06:34 +0200 |
|---|---|---|
| committer | Antonin Bourguignon <abo@openerp.com> | 2012-10-02 14:06:34 +0200 |
| commit | c28dfb19e19ea9dde6de2ae5fb20cfec3860744e (patch) | |
| tree | 4fdff0732f33426af59c7792b8e727458afe913c /addons/project | |
| parent | 79b2a0f6c6017d984b15160b8be806ecf7131b3e (diff) | |
| parent | 2b2288a3bd29c096cc5eb70c4d966cfd32bffc45 (diff) | |
[MERGE] trunk-unmutable-defaults-abo: fix the last few methods that still have mutable defaults
also improve code style (methods signatures and whitespaces)
contribution of Lionel Sausin from Numerigraphe
bzr revid: abo@openerp.com-20121002120634-ms2ins653tktqfnt
Diffstat (limited to 'addons/project')
| -rw-r--r-- | addons/project/project.py | 31 | ||||
| -rw-r--r-- | addons/project/wizard/project_task_reevaluate.py | 2 |
2 files changed, 16 insertions, 17 deletions
diff --git a/addons/project/project.py b/addons/project/project.py index 0d92d71a45f..dd4bbdcab21 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -55,7 +55,6 @@ class project_task_type(osv.osv): } _order = 'sequence' - def short_name(name): """Keep first word(s) of name to make it small enough but distinctive""" @@ -191,7 +190,6 @@ class project(osv.osv): # Lambda indirection method to avoid passing a copy of the overridable method when declaring the field _alias_models = lambda self, *args, **kwargs: self._get_alias_models(*args, **kwargs) - _columns = { 'complete_name': fields.function(_complete_name, string="Project Name", type='char', size=250), 'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the project without removing it."), @@ -311,11 +309,12 @@ class project(osv.osv): task_obj.duplicate_task(cr, uid, map_task_id, context=context) return True - def copy(self, cr, uid, id, default={}, context=None): + def copy(self, cr, uid, id, default=None, context=None): if context is None: context = {} + if default is None: + default = {} - default = default or {} context['active_test'] = False default['state'] = 'open' default['tasks'] = [] @@ -650,12 +649,12 @@ class task(base_stage, osv.osv): res[task.id]['progress'] = 100.0 return res - def onchange_remaining(self, cr, uid, ids, remaining=0.0, planned = 0.0): + def onchange_remaining(self, cr, uid, ids, remaining=0.0, planned=0.0): if remaining and not planned: return {'value':{'planned_hours': remaining}} return {} - def onchange_planned(self, cr, uid, ids, planned = 0.0, effective = 0.0): + def onchange_planned(self, cr, uid, ids, planned=0.0, effective=0.0): return {'value':{'remaining_hours': planned - effective}} def onchange_project(self, cr, uid, id, project_id): @@ -686,7 +685,9 @@ class task(base_stage, osv.osv): #FIXME why there is already the copy and the old one self.write(cr, uid, new, {'parent_ids':[(6,0,set(parent_ids))], 'child_ids':[(6,0, set(child_ids))]}) - def copy_data(self, cr, uid, id, default={}, context=None): + def copy_data(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} default = default or {} default.update({'work_ids':[], 'date_start': False, 'date_end': False, 'date_deadline': False}) if not default.get('remaining_hours', False): @@ -699,7 +700,6 @@ class task(base_stage, osv.osv): default.update({'name':new_name}) return super(task, self).copy_data(cr, uid, id, default, context) - def _is_template(self, cr, uid, ids, field_name, arg, context=None): res = {} for task in self.browse(cr, uid, ids, context=context): @@ -777,7 +777,6 @@ class task(base_stage, osv.osv): 'color': fields.integer('Color Index'), 'user_email': fields.related('user_id', 'email', type='char', string='User Email', readonly=True), } - _defaults = { 'stage_id': _get_default_stage_id, 'project_id': _get_default_project_id, @@ -790,7 +789,6 @@ class task(base_stage, osv.osv): 'user_id': lambda obj, cr, uid, context: uid, 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c), } - _order = "priority, sequence, date_start, name, id" def set_priority(self, cr, uid, ids, priority, *args): @@ -853,9 +851,8 @@ class task(base_stage, osv.osv): (_check_recursion, 'Error ! You cannot create recursive tasks.', ['parent_ids']), (_check_dates, 'Error ! Task end-date must be greater then task start-date', ['date_start','date_end']) ] - # + # Override view according to the company definition - # def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): users_obj = self.pool.get('res.users') if context is None: context = {} @@ -887,9 +884,9 @@ class task(base_stage, osv.osv): res['fields'][f]['string'] = res['fields'][f]['string'].replace('Hours',tm) return res - # **************************************** + # ---------------------------------------- # Case management - # **************************************** + # ---------------------------------------- def stage_find(self, cr, uid, cases, section_id, domain=[], order='sequence', context=None): """ Override of the base.stage method @@ -1021,10 +1018,12 @@ class task(base_stage, osv.osv): new_attachment_ids.append(attachment.copy(cr, uid, attachment_id, default={'res_id': delegated_task_id}, context=context)) return new_attachment_ids - def do_delegate(self, cr, uid, ids, delegate_data={}, context=None): + def do_delegate(self, cr, uid, ids, delegate_data=None, context=None): """ Delegate Task to another users. """ + if delegate_data is None: + delegate_data = {} assert delegate_data['user_id'], _("Delegated User should be specified") delegated_tasks = {} for task in self.browse(cr, uid, ids, context=context): @@ -1170,7 +1169,7 @@ class task(base_stage, osv.osv): return result # --------------------------------------------------- - # mail gateway + # Mail gateway # --------------------------------------------------- def message_new(self, cr, uid, msg, custom_values=None, context=None): diff --git a/addons/project/wizard/project_task_reevaluate.py b/addons/project/wizard/project_task_reevaluate.py index 382c9d64361..b00c531717f 100644 --- a/addons/project/wizard/project_task_reevaluate.py +++ b/addons/project/wizard/project_task_reevaluate.py @@ -26,7 +26,7 @@ from tools.translate import _ class project_task_reevaluate(osv.osv_memory): _name = 'project.task.reevaluate' - def _get_remaining(self,cr, uid, context=None): + def _get_remaining(self, cr, uid, context=None): if context is None: context = {} active_id = context.get('active_id', False) |
