From 7eb95e5765d76bdf087f18fb9ea18cfb7c36a01c Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Wed, 18 Apr 2012 14:52:46 +0530 Subject: [PATCH 1/6] [IMP] project : Synchronization between states and stages. bzr revid: mdi@tinyerp.com-20120418092246-dswbz05h6jbzn21k --- addons/project/project.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/addons/project/project.py b/addons/project/project.py index c9cd49e54b9..5fe723e9b5b 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -660,6 +660,32 @@ class task(osv.osv): for work in self.pool.get('project.task.work').browse(cr, uid, ids, context=context): if work.task_id: result[work.task_id.id] = True return result.keys() + + def _get_state(self, cr, uid, ids, name, arg, context=None): + res = {} + for task in self.browse(cr, uid, ids, context=context): + if task.type_id: + res[task.id] = task.type_id.state + return res + + def _get_stage(self, cr, uid, ids, context=None): + task_obj = self.pool.get('project.task') + result = {} + for stage in self.browse(cr, uid, ids, context=context): + if stage.state: + task_ids = task_obj.search(cr, uid, [('state', '=', stage.state)], context=context) + for task in task_obj.browse(cr, uid, task_ids, context=context): + result[task.id] = True + return result.keys() + + def _save_state(self, cr, uid, task_id, field_name, field_value, arg, context=None): + stage_obj = self.pool.get('project.task.type') + stage_ids = stage_obj.search(cr, uid, [('state', '=', field_value)], context=context) + if stage_ids: + self.write(cr, uid, task_id, {'type_id': stage_ids[0]}, context=context) + else: + cr.execute("""update project_task set state=%s where id=%s""", (field_value, task_id, )) + return True _columns = { 'active': fields.function(_is_template, store=True, string='Not a Template Task', type='boolean', help="This field is computed automatically and have the same behavior than the boolean 'active' field: if the task is linked to a template or unactivated project, it will be hidden unless specifically asked."), @@ -668,7 +694,11 @@ class task(osv.osv): 'priority': fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Important'), ('0','Very important')], 'Priority', select=True), 'sequence': fields.integer('Sequence', select=True, help="Gives the sequence order when displaying a list of tasks."), 'type_id': fields.many2one('project.task.type', 'Stage'), - 'state': fields.related('type_id','state', type='selection', selection=_TASK_STATE, string="State", readonly=True, store=True), + 'state': fields.function(_get_state, fnct_inv=_save_state, type='selection', selection=_TASK_STATE, string="State", readonly=True, + store = { + 'project.task': (lambda self, cr, uid, ids, c={}: ids, ['type_id'], 10), + 'project.task.type': (_get_stage, ['state'], 10) + }), 'kanban_state': fields.selection([('normal', 'Normal'),('blocked', 'Blocked'),('done', 'Ready To Pull')], 'Kanban State', help="A task's kanban state indicates special situations affecting it:\n" " * Normal is the default situation\n" From 244c29f642aa2d0a777a7cceb9eb1ecf38513496 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Wed, 18 Apr 2012 16:00:22 +0530 Subject: [PATCH 2/6] [IMP] project_issue : Synchronization between states and stages. bzr revid: mdi@tinyerp.com-20120418103022-imtmaivgjfobsy60 --- addons/project_issue/project_issue.py | 32 ++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index e7c2194d304..484900b7613 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -165,6 +165,32 @@ class project_issue(crm.crm_case, osv.osv): if work.task_id: issues += issue_pool.search(cr, uid, [('task_id','=',work.task_id.id)]) return issues + + def _get_state(self, cr, uid, ids, name, arg, context=None): + res = {} + for issue in self.browse(cr, uid, ids, context=context): + if issue.type_id: + res[issue.id] = issue.type_id.state + return res + + def _get_stage(self, cr, uid, ids, context=None): + issue_obj = self.pool.get('project.issue') + result = {} + for stage in self.browse(cr, uid, ids, context=context): + if stage.state: + issue_ids = issue_obj.search(cr, uid, [('state', '=', stage.state)], context=context) + for issue in issue_obj.browse(cr, uid, issue_ids, context=context): + result[issue.id] = True + return result.keys() + + def _save_state(self, cr, uid, issue_id, field_name, field_value, arg, context=None): + stage_obj = self.pool.get('project.task.type') + stage_ids = stage_obj.search(cr, uid, [('state', '=', field_value)], context=context) + if stage_ids: + self.write(cr, uid, [issue_id], {'type_id': stage_ids[0]}, context=context) + else: + cr.execute("""update project_issue set state=%s where id=%s""", (field_value, issue_id, )) + return True _columns = { 'id': fields.integer('ID', readonly=True), @@ -181,7 +207,11 @@ class project_issue(crm.crm_case, osv.osv): 'partner_id': fields.many2one('res.partner', 'Partner', select=1), 'company_id': fields.many2one('res.company', 'Company'), 'description': fields.text('Description'), - 'state': fields.related('type_id','state', type='selection', selection=_ISSUE_STATE, string="State", readonly=True, store=True), + 'state': fields.function(_get_state, fnct_inv=_save_state, type='selection', selection=_ISSUE_STATE, string="State", readonly=True, + store = { + 'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['type_id'], 10), + 'project.task.type': (_get_stage, ['state'], 10) + }), 'email_from': fields.char('Email', size=128, help="These people will receive email.", select=1), 'email_cc': fields.char('Watchers Emails', size=256, help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"), 'date_open': fields.datetime('Opened', readonly=True,select=True), From 669a977f17d357055e48bfe333d2fade5373b372 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Wed, 18 Apr 2012 17:08:44 +0530 Subject: [PATCH 3/6] [IMP] project : Remove technical features group from stage object. bzr revid: mdi@tinyerp.com-20120418113844-cawv8o13qgvhcbsj --- addons/project/project_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 535c08c75b4..15705a4f6a8 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -632,7 +632,7 @@ - + From da5509dc23688c21660c5698188d0ece52746c2a Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Wed, 18 Apr 2012 18:03:22 +0530 Subject: [PATCH 4/6] [IMP] project : Added technical features group on buttons and state field. bzr revid: mdi@tinyerp.com-20120418123322-s8c5zb3vmmhtsm9f --- addons/project/project_view.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 15705a4f6a8..568e47d204f 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -224,15 +224,15 @@
-
@@ -280,7 +280,7 @@ - + @@ -382,7 +382,7 @@ type="object" class="oe_kanban_button"> - ! + !
@@ -392,7 +392,7 @@ - +
@@ -301,12 +301,12 @@ -