From 105412b5d55d4f22421140f8edbba9dfa104ceda Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Mon, 24 Jun 2013 12:05:31 +0530 Subject: [PATCH] [REM]: Remove python action field from stage -> Improve convert to opportunity button not work. -> Mark lost shold visible any time. bzr revid: aja@tinyerp.com-20130624063531-i7t0sec0u0aj7d6j --- addons/crm/crm_lead.py | 2 +- addons/crm/crm_lead_view.xml | 3 +-- addons/project/project.py | 24 ++---------------------- addons/project/project_data.xml | 8 -------- addons/project/project_view.xml | 2 -- addons/project_mrp/project_mrp.py | 18 +++++++++++++----- addons/project_mrp/project_mrp_view.xml | 1 + 7 files changed, 18 insertions(+), 40 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index ab948cc6035..1981757135c 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -685,7 +685,7 @@ class crm_lead(base_stage, format_address, osv.osv): customer = partner.browse(cr, uid, partner_id, context=context) for lead in self.browse(cr, uid, ids, context=context): # avoid done / cancelled leads - if lead.probability == 100 or (lead.probability == 0 and lead.stage_id and lead.stage_id.sequence == 1): + if lead.probability == 100 or (lead.probability == 0 and lead.stage_id and lead.stage_id.sequence != 1): continue vals = self._convert_opportunity_data(cr, uid, lead, customer, section_id, context=context) self.write(cr, uid, [lead.id], vals, context=context) diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index fba44af114c..5e6e9eb1b77 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -375,8 +375,7 @@
diff --git a/addons/project/project.py b/addons/project/project.py index 0de2b670044..aba3daa41c7 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -46,7 +46,6 @@ class project_task_type(osv.osv): 'project_ids': fields.many2many('project.project', 'project_task_type_rel', 'type_id', 'project_id', 'Projects'), 'fold': fields.boolean('Folded by Default', help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."), - 'action': fields.text('Python Action'), } def _get_default_project_id(self, cr, uid, ctx={}): proj = ctx.get('default_project_id', False) @@ -785,7 +784,6 @@ class task(base_stage, osv.osv): 'id': fields.integer('ID', readonly=True), 'color': fields.integer('Color Index'), 'user_email': fields.related('user_id', 'email', type='char', string='User Email', readonly=True), - 'is_close': fields.boolean('Task is Close ?'), } _defaults = { 'stage_id': _get_default_stage_id, @@ -925,13 +923,7 @@ class task(base_stage, osv.osv): if stage_ids: return stage_ids[0] return False - - def action_task_close(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'is_close': True}) - - def action_task_open(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'is_close': False}) - + # TODO : Need to Clean def _check_child_task(self, cr, uid, ids, context=None): if context == None: context = {} @@ -1036,15 +1028,6 @@ class task(base_stage, osv.osv): self._store_history(cr, uid, [task_id], context=context) return task_id - def _trigger_stage_action(self, cr, uid, ids, action, context): - for line in action['action'].split('\n'): - line = line.strip() - if line and hasattr(self,line): - getattr(self,line)(cr,uid,ids,context) - else: - raise osv.except_osv(_("Warning!"), _("Invalid Python Action.")) - return True - # Overridden to reset the kanban_state to normal whenever # the stage (stage_id) of the task changes. def write(self, cr, uid, ids, vals, context=None): @@ -1057,9 +1040,6 @@ class task(base_stage, osv.osv): vals['message_follower_ids'] += [(6, 0,[follower.id]) for follower in project_id.message_follower_ids] if vals and not 'kanban_state' in vals and 'stage_id' in vals: new_stage = vals.get('stage_id') - action=self.pool.get('project.task.type').read(cr, uid, new_stage, ['action'],context=context) - if action['action']: - self._trigger_stage_action(cr, uid, ids, action, context) vals['date_end'] = time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT) vals_reset_kstate = dict(vals, kanban_state='normal') for t in self.browse(cr, uid, ids, context=context): @@ -1079,7 +1059,7 @@ class task(base_stage, osv.osv): def unlink(self, cr, uid, ids, context=None): if context == None: context = {} - self._check_child_task(cr, uid, ids, context=context) +# self._check_child_task(cr, uid, ids, context=context) TODO : If child task is open then parent task should not be deleted. res = super(task, self).unlink(cr, uid, ids, context) return res diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 119a4dacfa6..778732d8ca5 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -30,51 +30,43 @@ 1 Analysis - action_task_open 2 Specification - action_task_open 2 Design - action_task_open 3 Development - action_task_open 4 Testing - action_task_open 5 Merge - action_task_open 100 Done - action_task_close 200 Cancelled - action_task_close diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index f2d03c64d4c..e1c4e4f53df 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -377,7 +377,6 @@ - - diff --git a/addons/project_mrp/project_mrp.py b/addons/project_mrp/project_mrp.py index 52a55b6ffaf..47175726c97 100644 --- a/addons/project_mrp/project_mrp.py +++ b/addons/project_mrp/project_mrp.py @@ -28,13 +28,9 @@ class project_task(osv.osv): _columns = { 'procurement_id': fields.many2one('procurement.order', 'Procurement', ondelete='set null'), 'sale_line_id': fields.related('procurement_id', 'sale_line_id', type='many2one', relation='sale.order.line', store=True, string='Sales Order Line'), + 'is_close': fields.boolean('Task is Close ?'), } - def action_task_close(self, cr, uid, ids, context=None): - res = super(project_task, self).action_task_close(cr, uid, ids,context) - self._validate_subflows(cr, uid, ids,context) - return res - def _validate_subflows(self, cr, uid, ids,context): wf_service = netsvc.LocalService("workflow") for task in self.browse(cr, uid, ids): @@ -51,6 +47,18 @@ class project_task(osv.osv): self._validate_subflows(cr, uid, ids) return res + def write(self, cr, uid, ids, vals, context=None): + if 'stage_id' in vals: + curr_stage = self.pool.get('project.task.type').browse(cr, uid, vals.get('stage_id'),context) + task = self.browse(cr, uid, ids[0],context) + sequence = [stage.sequence for stage in task.project_id.type_ids[-2:]] + if curr_stage.sequence in sequence: + self.write(cr, uid, ids, {'is_close': True}) + self._validate_subflows(cr, uid, ids,context) + else: + self.write(cr, uid, ids, {'is_close': False}) + return super(project_task, self).write(cr, uid, ids, vals, context=context) + class product_product(osv.osv): _inherit = "product.product" _columns = { diff --git a/addons/project_mrp/project_mrp_view.xml b/addons/project_mrp/project_mrp_view.xml index ac6f2513a40..abaa4d3c660 100644 --- a/addons/project_mrp/project_mrp_view.xml +++ b/addons/project_mrp/project_mrp_view.xml @@ -28,6 +28,7 @@ +