1 # -*- encoding: utf-8 -*-
3 ##############################################################################
5 # Copyright (c) 2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
7 # WARNING: This program as such is intended to be used by professional
8 # programmers who take the whole responsability of assessing all potential
9 # consequences resulting from its eventual inadequacies and bugs
10 # End users who are looking for a ready-to-use solution with commercial
11 # garantees and support are strongly adviced to contract a Free Software
14 # This program is Free Software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 ##############################################################################
33 def _get_default(obj, cursor, uid, data, context=None):
34 '''Get default value'''
37 def _make_case(obj, cursor, uid, data, context=None):
39 pool = pooler.get_pool(cursor.dbname)
40 case_obj = pool.get('crm.case')
41 mod_obj = pool.get('ir.model.data')
42 act_obj = pool.get('ir.actions.act_window')
46 for partner_id in data['ids']:
47 new_id.append(case_obj.create(cursor, uid, {
48 'name': data['form']['name'],
49 'section_id': data['form']['section'],
50 'partner_id': partner_id,
51 'description': data['form']['description'],
54 result = mod_obj._get_id(cursor, uid, 'crm', 'crm_case_categ0-act')
55 res_id = mod_obj.read(cursor, uid, [result], ['res_id'])[0]['res_id']
56 result = act_obj.read(cursor, uid, [res_id])[0]
57 result['domain'] = str([('id', 'in', new_id)])
61 class MakeCase(wizard.interface):
62 '''Wizard that create case on partner'''
64 case_form = """<?xml version="1.0"?>
65 <form string="Make Case">
67 <field name="section"/>
69 <field name="description" colspan="4"/>
73 'name': {'string': 'Case Description', 'type': 'char', 'size': 64,
75 'section': {'string': 'Case Section', 'type': 'many2one',
76 'relation': 'crm.case.section', 'required': True},
77 'user': {'string': 'User Responsible', 'type': 'many2one',
78 'relation': 'res.users'},
79 'description': {'string': 'Your action', 'type': 'text'},
84 'actions': [_get_default],
85 'result': {'type': 'form', 'arch': case_form, 'fields': case_fields,
94 'result': {'type': 'action', 'action': _make_case, 'state': 'end'}
98 MakeCase('sale_crm.make_case')
99 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: