[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
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -375,8 +375,7 @@
|
||||
<header>
|
||||
<button name="case_mark_won" string="Mark Won" type="object" class="oe_highlight"
|
||||
attrs="{'invisible': [('probability', '=', 100)]}"/>
|
||||
<button name="case_mark_lost" string="Mark Lost" type="object" class="oe_highlight"
|
||||
attrs="{'invisible': [('probability', 'in', [0,100])]}"/>
|
||||
<button name="case_mark_lost" string="Mark Lost" type="object" class="oe_highlight"/>
|
||||
<field name="stage_id" widget="statusbar" clickable="True"
|
||||
domain="['&', ('section_ids', '=', section_id), '|', ('type', '=', type), ('type', '=', 'both')]"/>
|
||||
</header>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -30,51 +30,43 @@
|
||||
<record id="project_tt_analysis" model="project.task.type">
|
||||
<field name="sequence">1</field>
|
||||
<field name="name">Analysis</field>
|
||||
<field name="action">action_task_open</field>
|
||||
<field name="case_default" eval="False"/>
|
||||
</record>
|
||||
<record id="project_tt_specification" model="project.task.type">
|
||||
<field name="sequence">2</field>
|
||||
<field name="name">Specification</field>
|
||||
<field name="action">action_task_open</field>
|
||||
<field name="case_default" eval="True"/>
|
||||
</record>
|
||||
<record id="project_tt_design" model="project.task.type">
|
||||
<field name="sequence">2</field>
|
||||
<field name="name">Design</field>
|
||||
<field name="action">action_task_open</field>
|
||||
<field name="case_default" eval="True"/>
|
||||
</record>
|
||||
<record id="project_tt_development" model="project.task.type">
|
||||
<field name="sequence">3</field>
|
||||
<field name="name">Development</field>
|
||||
<field name="action">action_task_open</field>
|
||||
<field name="case_default" eval="True"/>
|
||||
</record>
|
||||
<record id="project_tt_testing" model="project.task.type">
|
||||
<field name="sequence">4</field>
|
||||
<field name="name">Testing</field>
|
||||
<field name="action">action_task_open</field>
|
||||
<field name="case_default" eval="True"/>
|
||||
</record>
|
||||
<record id="project_tt_merge" model="project.task.type">
|
||||
<field name="sequence">5</field>
|
||||
<field name="name">Merge</field>
|
||||
<field name="action">action_task_open</field>
|
||||
<field name="case_default" eval="False"/>
|
||||
<field name="fold" eval="True"/>
|
||||
</record>
|
||||
<record id="project_tt_deployment" model="project.task.type">
|
||||
<field name="sequence">100</field>
|
||||
<field name="name">Done</field>
|
||||
<field name="action">action_task_close</field>
|
||||
<field name="case_default" eval="True"/>
|
||||
<field name="fold" eval="True"/>
|
||||
</record>
|
||||
<record id="project_tt_cancel" model="project.task.type">
|
||||
<field name="sequence">200</field>
|
||||
<field name="name">Cancelled</field>
|
||||
<field name="action">action_task_close</field>
|
||||
<field name="case_default" eval="True"/>
|
||||
<field name="fold" eval="True"/>
|
||||
</record>
|
||||
|
||||
@@ -377,7 +377,6 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="project_id" on_change="onchange_project(project_id)" context="{'default_use_tasks':1}"/>
|
||||
<field name="is_close" invisible="1"/>
|
||||
<field name="user_id"
|
||||
on_change="onchange_user_assigned()"
|
||||
options='{"no_open": True}'
|
||||
@@ -681,7 +680,6 @@
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="case_default"/>
|
||||
<field name="action"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="sequence"/>
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<field name="sale_line_id" string="Order Line"/>
|
||||
<field name="is_close" invisible="1"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user