From bfd96de42bc942fa24158a8c87b9e905c2460b72 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Mon, 7 May 2012 12:50:49 +0530 Subject: [PATCH] [IMP]rename all fields which r required in project and another module and improve code and bzr revid: sgo@tinyerp.com-20120507072049-u00lsqra9x34nf73 --- addons/project/project.py | 18 +++++------------- addons/project/project_view.xml | 12 ++++++------ addons/project/static/src/js/project.js | 4 ++-- addons/project_issue/project_issue.py | 8 ++++---- addons/project_issue/project_issue_view.xml | 17 +++++++---------- .../static/src/js/project_issue.js | 4 ++-- addons/project_long_term/project_long_term.py | 8 ++++---- .../project_long_term_view.xml | 14 +++++++------- addons/project_timesheet/project_timesheet.py | 8 ++++---- .../project_timesheet_view.xml | 14 +++++++------- .../static/src/js/project_timesheet.js | 4 ++-- 11 files changed, 50 insertions(+), 61 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 27370363140..29816f5f922 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -155,7 +155,7 @@ class project(osv.osv): raise osv.except_osv(_('Operation Not Permitted !'), _('You cannot delete a project containing tasks. I suggest you to desactivate it.')) return super(project, self).unlink(cr, uid, ids, *args, **kwargs) - def _open_task(self, cr, uid, ids, field_name, arg, context=None): + def _task_count(self, cr, uid, ids, field_name, arg, context=None): open_task={} task_pool=self.pool.get('project.task') for id in ids: @@ -163,14 +163,6 @@ class project(osv.osv): open_task[id] = len(task_ids) return open_task - def company_uom_id(self, cr, uid, ids, field_name, arg, context=None): - uom_company = {} - for project in self.browse(cr,uid,ids): - user_browse = self.pool.get('res.users').browse(cr,uid,project.user_id.id) - uom_company[project.id] = project.company_id.project_time_mode_id.name or user_browse.company_id.project_time_mode_id.name - return uom_company - - _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."), @@ -207,10 +199,10 @@ class project(osv.osv): 'warn_header': fields.text('Mail Header', help="Header added at the beginning of the email for the warning message sent to the customer when a task is closed.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'warn_footer': fields.text('Mail Footer', help="Footer added at the beginning of the email for the warning message sent to the customer when a task is closed.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), - 'task': fields.boolean('Task',help = "If you check this field tasks appears in kanban view"), - 'open_task': fields.function(_open_task , type='integer',string="Open Tasks"), + 'use_tasks': fields.boolean('Task',help = "If you check this field tasks appears in kanban view"), + 'task_count': fields.function(_task_count , type='integer',string="Open Tasks"), 'color': fields.integer('Color Index'), - 'company_uom_id': fields.function(company_uom_id,type="char"), + 'company_uom_id': fields.related('company_id', 'project_time_mode_id', type='many2one', relation='product.uom'), } def dummy(self, cr, uid, ids, context=None): return False @@ -247,7 +239,7 @@ class project(osv.osv): 'priority': 1, 'sequence': 10, 'type_ids': _get_type_common, - 'task' : True, + 'use_tasks' : True, } # TODO: Why not using a SQL contraints ? diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 1b317d671ca..a9886e3b1c7 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -45,7 +45,7 @@ - + @@ -172,11 +172,11 @@ - + - +
@@ -198,8 +198,8 @@

...


@@ -216,7 +216,7 @@ Progress - / s + / diff --git a/addons/project/static/src/js/project.js b/addons/project/static/src/js/project.js index 5365e0b0942..001777103d6 100644 --- a/addons/project/static/src/js/project.js +++ b/addons/project/static/src/js/project.js @@ -17,8 +17,8 @@ openerp.project = function(openerp) { }); //if task is true , then open the task when click on the anywhere in the box. - if(this.record.task.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks'); - if(!this.record.task.raw_value)$(this.$element).find('.click_button').attr('data-name','dummy'); + if(this.record.use_tasks.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks'); + if(!this.record.use_tasks.raw_value)$(this.$element).find('.click_button').attr('data-name','dummy'); // set sequence like Tasks,Issues,Timesheets and Phases my_list = $("#list a") diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 575d51e7b1c..db2ad97b414 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -517,7 +517,7 @@ project_issue() class project(osv.osv): _inherit = "project.project" - def _compute_issue(self, cr, uid, ids, field_name, arg, context=None): + def _issue_count(self, cr, uid, ids, field_name, arg, context=None): res={} issue_pool=self.pool.get('project.issue') for project in self.browse(cr, uid, ids, context=context): @@ -528,12 +528,12 @@ class project(osv.osv): _columns = { 'project_escalation_id' : fields.many2one('project.project','Project Escalation', help='If any issue is escalated from the current Project, it will be listed under the project selected here.', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'reply_to' : fields.char('Reply-To Email Address', size=256), - 'issues' : fields.boolean('Issues',help = "If you check this field issues are appears in kanban view"), - 'total_issues': fields.function(_compute_issue , type='integer',string="Issue"), + 'use_issues' : fields.boolean('Issues',help = "If you check this field issues are appears in kanban view"), + 'issue_count': fields.function(_issue_count , type='integer'), } _defaults = { - 'issues' : True, + 'use_issues' : True, } def open_issues(self, cr, uid, ids, context=None): diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index f9290e5c7e1..66ad9c04e30 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -345,8 +345,8 @@ form - - + + @@ -361,19 +361,16 @@ kanban - - - + + + - - IssueIssues() + + IssueIssues() - - - diff --git a/addons/project_issue/static/src/js/project_issue.js b/addons/project_issue/static/src/js/project_issue.js index 61ee078bd0d..b0433055160 100644 --- a/addons/project_issue/static/src/js/project_issue.js +++ b/addons/project_issue/static/src/js/project_issue.js @@ -4,8 +4,8 @@ openerp.project_issue = function(openerp) { self = this; self._super(); if(this.view.dataset.model == 'project.project') { - if(this.record.task.raw_value && this.record.issues.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks'); - if(!this.record.task.raw_value && this.record.issues.raw_value)$(this.$element).find('.click_button').attr('data-name','open_issues'); + if(this.record.use_tasks.raw_value && this.record.use_issues.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks'); + if(!this.record.use_tasks.raw_value && this.record.use_issues.raw_value)$(this.$element).find('.click_button').attr('data-name','open_issues'); }; } diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py index 7806bc0abb9..582a5ed8ef0 100644 --- a/addons/project_long_term/project_long_term.py +++ b/addons/project_long_term/project_long_term.py @@ -217,7 +217,7 @@ project_user_allocation() class project(osv.osv): _inherit = "project.project" - def _open_phase(self, cr, uid, ids, field_name, arg, context=None): + def _phase_count(self, cr, uid, ids, field_name, arg, context=None): open_phase={} phase_pool=self.pool.get('project.phase') for id in ids: @@ -227,12 +227,12 @@ class project(osv.osv): _columns = { 'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases"), - 'phases' : fields.boolean('Phase',help = "If you check this field Phases are appears in kanban view"), - 'open_phases' : fields.function(_open_phase , type='integer',string="Open Phases"), + 'use_phases' : fields.boolean('Phase',help = "If you check this field Phases are appears in kanban view"), + 'phase_count' : fields.function(_phase_count , type='integer',string="Open Phases"), } _defaults = { - 'phases' : True, + 'use_phases' : True, } def open_phase(self, cr, uid, ids, context=None): #Open the View for the Tasks for the project diff --git a/addons/project_long_term/project_long_term_view.xml b/addons/project_long_term/project_long_term_view.xml index 1f258ff2ead..f5dcb48576d 100644 --- a/addons/project_long_term/project_long_term_view.xml +++ b/addons/project_long_term/project_long_term_view.xml @@ -104,8 +104,8 @@ form - - + + @@ -116,13 +116,13 @@ kanban - - - + + + - - PhasePhases() + + PhasePhases() diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index 59cb4be9321..9a718e08acc 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -48,7 +48,7 @@ class project_project(osv.osv): return res - def _compute_timesheet(self, cr, uid, ids, field_name, arg, context=None): + def _timesheet_count(self, cr, uid, ids, field_name, arg, context=None): res={} aal_pool=self.pool.get('account.analytic.line') for project in self.browse(cr, uid, ids, context=context): @@ -57,13 +57,13 @@ class project_project(osv.osv): return res _columns = { - 'timesheets' : fields.boolean('Timesheets',help = "If you check this field timesheets appears in kanban view"), + 'use_timesheets' : fields.boolean('Timesheets',help = "If you check this field timesheets appears in kanban view"), 'amt_to_invoice': fields.function(_to_invoice,string="Amount to Invoice",multi="sums"), 'hrs_to_invoice': fields.function(_to_invoice,string="Hours to Invoice",multi="sums"), - 'total_timesheet': fields.function(_compute_timesheet , type='integer',string="Issue"), + 'timesheet_count': fields.function(_timesheet_count , type='integer',string="Issue"), } _defaults = { - 'timesheets' : True, + 'use_timesheets' : True, } def onchange_partner_id(self, cr, uid, ids, part=False, context=None): diff --git a/addons/project_timesheet/project_timesheet_view.xml b/addons/project_timesheet/project_timesheet_view.xml index 0efc228136d..6ac8afcfaf8 100644 --- a/addons/project_timesheet/project_timesheet_view.xml +++ b/addons/project_timesheet/project_timesheet_view.xml @@ -7,8 +7,8 @@ form - - + + @@ -31,14 +31,14 @@ kanban - - - + + + - - TimesheetTimesheets() + + TimesheetTimesheets() diff --git a/addons/project_timesheet/static/src/js/project_timesheet.js b/addons/project_timesheet/static/src/js/project_timesheet.js index ef8bbc02f2e..3eff53a8651 100644 --- a/addons/project_timesheet/static/src/js/project_timesheet.js +++ b/addons/project_timesheet/static/src/js/project_timesheet.js @@ -11,9 +11,9 @@ openerp.project_timesheet = function(openerp) { } if(include(this.view.fields_keys,"issues")) { - if(!this.record.task.raw_value && !this.record.issues.raw_value && this.record.timesheets.raw_value)$(this.$element).find('.click_button').attr('data-name','open_timesheets'); + if(!this.record.use_tasks.raw_value && !this.record.use_issues.raw_value && this.record.use_timesheets.raw_value)$(this.$element).find('.click_button').attr('data-name','open_timesheets'); }; - if(this.record.task.raw_value && this.record.timesheets.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks'); + if(this.record.use_tasks.raw_value && this.record.use_timesheets.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks'); }; } });