[IMP+FIX] crm: Make new generic wizard for Meeting case, put necessary method

bzr revid: hmo@tinyerp.com-20091229110222-k161yopj90abuhp0
This commit is contained in:
Harry (Open ERP) 2009-12-29 16:32:22 +05:30
parent 892e40f0c9
commit a0b3b3fe01
3 changed files with 104 additions and 3 deletions

View File

@ -493,7 +493,7 @@ class crm_case(osv.osv):
'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the case without removing it."),
'description': fields.text('Your action'),
'section_id': fields.many2one('crm.case.section', 'Section', required=True, select=True, help='Section to which Case belongs to. Define Responsible user and Email account for mail gateway.'),
'section_id': fields.many2one('crm.case.section', 'Section', select=True, help='Section to which Case belongs to. Define Responsible user and Email account for mail gateway.'),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id)]", help='Category related to the section.Subdivide the CRM cases independently or section-wise.'),
'planned_revenue': fields.float('Planned Revenue'),
'planned_cost': fields.float('Planned Costs'),

View File

@ -201,8 +201,12 @@ class crm_meeting(osv.osv):
return res
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
if isinstance(ids, (str, int, long)):
select = [ids]
else:
select = ids
new_ids = []
for id in ids:
for id in select:
id = common.caldevIDs2readIDs(id)
if not id in new_ids:
new_ids.append(id)
@ -300,7 +304,76 @@ class crm_meeting(osv.osv):
vals['case_id'] = common.caldevIDs2readIDs(vals['case_id'])
return super(crm_meeting, self).create(cr, uid, vals, context)
def _map_ids(self, method, cr, uid, ids, *args, **argv):
case_data = self.browse(cr, uid, ids)
new_ids = []
for case in case_data:
if case.inherit_case_id:
new_ids.append(case.inherit_case_id.id)
return getattr(self.pool.get('crm.case'),method)(cr, uid, new_ids, *args, **argv)
def onchange_case_id(self, cr, uid, ids, *args, **argv):
return self._map_ids('onchange_case_id',cr,uid,ids,*args,**argv)
def onchange_partner_id(self, cr, uid, ids, *args, **argv):
return self._map_ids('onchange_partner_id',cr,uid,ids,*args,**argv)
def onchange_partner_address_id(self, cr, uid, ids, *args, **argv):
return self._map_ids('onchange_partner_address_id',cr,uid,ids,*args,**argv)
def onchange_categ_id(self, cr, uid, ids, *args, **argv):
return self._map_ids('onchange_categ_id',cr,uid,ids,*args,**argv)
def case_close(self,cr, uid, ids, *args, **argv):
return self._map_ids('case_close',cr,uid,ids,*args,**argv)
def case_open(self,cr, uid, ids, *args, **argv):
return self._map_ids('case_open',cr,uid,ids,*args,**argv)
def case_cancel(self,cr, uid, ids, *args, **argv):
return self._map_ids('case_cancel',cr,uid,ids,*args,**argv)
def case_reset(self,cr, uid, ids, *args, **argv):
return self._map_ids('case_reset',cr,uid,ids,*args,**argv)
crm_meeting()
class crm_meeting_generic_wizard(osv.osv_memory):
_name = 'crm.meeting.generic_wizard'
_columns = {
'section_id': fields.many2one('crm.case.section', 'Section', required=True),
'user_id': fields.many2one('res.users', 'Responsible'),
}
def _get_default_section(self, cr, uid, context):
case_id = context.get('active_id',False)
if not case_id:
return False
case_obj = self.pool.get('crm.meeting')
case = case_obj.read(cr, uid, case_id, ['state','section_id'])
if case['state'] in ('done'):
raise osv.except_osv(_('Error !'), _('You can not assign Closed Case.'))
return case['section_id']
_defaults = {
'section_id': _get_default_section
}
def action_create(self, cr, uid, ids, context=None):
case_obj = self.pool.get('crm.meeting')
case_id = context.get('active_id',[])
res = self.read(cr, uid, ids)[0]
case = case_obj.read(cr, uid, case_id, ['state'])
if case['state'] in ('done'):
raise osv.except_osv(_('Error !'), _('You can not assign Closed Case.'))
new_case_id = case_obj.copy(cr, uid, case_id, default=
{
'section_id':res.get('section_id',False),
'user_id':res.get('user_id',False)
}, context=context)
case_obj.write(cr, uid, case_id, {'case_id':new_case_id}, context=context)
case_obj.case_close(cr, uid, [case_id])
return {}
crm_meeting_generic_wizard()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -5,6 +5,34 @@
# Meetings
# ------------------------------------------------------
<record model="ir.ui.view" id="crm_meeting_generic_wizard">
<field name="name">crm.meeting.generic_wizard.form</field>
<field name="model">crm.meeting.generic_wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Generic Wizard">
<group col="2">
<field name="section_id" select="1" widget="selection"/>
<field name="user_id"/>
</group>
<newline/>
<separator colspan="4"/>
<group col="2" colspan="2">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" name="action_create" string="Assign" type="object"/>
</group>
</form>
</field>
</record>
<record id="crm_meeting_generic_wizard_act" model="ir.actions.act_window">
<field name="name">Meeting Generic Wizard</field>
<field name="res_model">crm.meeting.generic_wizard</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm_meeting_generic_wizard"/>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.ui.view" id="crm_case_form_view_meet">
<field name="name">CRM - Meetings Form</field>
<field name="model">crm.meeting</field>
@ -20,7 +48,7 @@
<field name="duration" colspan="1" widget="float_time" required="1"/>
<group colspan="2">
<field name="case_id" on_change="onchange_case_id(case_id, name, partner_id)"/>
<button string="Assign" name="%(crm_generic_wizard_act)d" type="action" />
<button string="Assign" name="%(crm_meeting_generic_wizard_act)d" type="action" />
</group>
</group>