[IMP] Ir Action Server - Fix the domain for the field 'Link Using field'.
[odoo/odoo.git] / openerp / addons / base / ir / ir_actions.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2014 OpenERP S.A. <http://www.openerp.com>
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 from functools import partial
23 import logging
24 import operator
25 import os
26 import time
27 import datetime
28 import dateutil
29
30 import openerp
31 from openerp import SUPERUSER_ID
32 from openerp import tools
33 from openerp import workflow
34 from openerp.osv import fields, osv
35 from openerp.osv.orm import browse_record
36 import openerp.report.interface
37 from openerp.report.report_sxw import report_sxw, report_rml
38 from openerp.tools.safe_eval import safe_eval as eval
39 from openerp.tools.translate import _
40 import openerp.workflow
41
42 _logger = logging.getLogger(__name__)
43
44 class actions(osv.osv):
45     _name = 'ir.actions.actions'
46     _table = 'ir_actions'
47     _order = 'name'
48     _columns = {
49         'name': fields.char('Name', size=64, required=True),
50         'type': fields.char('Action Type', required=True, size=32),
51         'usage': fields.char('Action Usage', size=32),
52         'help': fields.text('Action description',
53             help='Optional help text for the users with a description of the target view, such as its usage and purpose.',
54             translate=True),
55     }
56     _defaults = {
57         'usage': lambda *a: False,
58     }
59
60
61 class ir_actions_report_xml(osv.osv):
62
63     def _report_content(self, cursor, user, ids, name, arg, context=None):
64         res = {}
65         for report in self.browse(cursor, user, ids, context=context):
66             data = report[name + '_data']
67             if not data and report[name[:-8]]:
68                 fp = None
69                 try:
70                     fp = tools.file_open(report[name[:-8]], mode='rb')
71                     data = fp.read()
72                 except:
73                     data = False
74                 finally:
75                     if fp:
76                         fp.close()
77             res[report.id] = data
78         return res
79
80     def _report_content_inv(self, cursor, user, id, name, value, arg, context=None):
81         self.write(cursor, user, id, {name+'_data': value}, context=context)
82
83     def _report_sxw(self, cursor, user, ids, name, arg, context=None):
84         res = {}
85         for report in self.browse(cursor, user, ids, context=context):
86             if report.report_rml:
87                 res[report.id] = report.report_rml.replace('.rml', '.sxw')
88             else:
89                 res[report.id] = False
90         return res
91
92     def _lookup_report(self, cr, name):
93         """
94         Look up a report definition.
95         """
96         opj = os.path.join
97
98         # First lookup in the deprecated place, because if the report definition
99         # has not been updated, it is more likely the correct definition is there.
100         # Only reports with custom parser sepcified in Python are still there.
101         if 'report.' + name in openerp.report.interface.report_int._reports:
102             new_report = openerp.report.interface.report_int._reports['report.' + name]
103         else:
104             cr.execute("SELECT * FROM ir_act_report_xml WHERE report_name=%s", (name,))
105             r = cr.dictfetchone()
106             if r:
107                 if r['report_rml'] or r['report_rml_content_data']:
108                     if r['parser']:
109                         kwargs = { 'parser': operator.attrgetter(r['parser'])(openerp.addons) }
110                     else:
111                         kwargs = {}
112                     new_report = report_sxw('report.'+r['report_name'], r['model'],
113                             opj('addons',r['report_rml'] or '/'), header=r['header'], register=False, **kwargs)
114                 elif r['report_xsl'] and r['report_xml']:
115                     new_report = report_rml('report.'+r['report_name'], r['model'],
116                             opj('addons',r['report_xml']),
117                             r['report_xsl'] and opj('addons',r['report_xsl']), register=False)
118                 else:
119                     raise Exception, "Unhandled report type: %s" % r
120             else:
121                 raise Exception, "Required report does not exist: %s" % r
122
123         return new_report
124
125     def render_report(self, cr, uid, res_ids, name, data, context=None):
126         """
127         Look up a report definition and render the report for the provided IDs.
128         """
129         new_report = self._lookup_report(cr, name)
130         return new_report.create(cr, uid, res_ids, data, context)
131
132     _name = 'ir.actions.report.xml'
133     _inherit = 'ir.actions.actions'
134     _table = 'ir_act_report_xml'
135     _sequence = 'ir_actions_id_seq'
136     _order = 'name'
137     _columns = {
138         'name': fields.char('Name', size=64, required=True, translate=True),
139         'model': fields.char('Object', size=64, required=True),
140         'type': fields.char('Action Type', size=32, required=True),
141         'report_name': fields.char('Service Name', size=64, required=True),
142         'usage': fields.char('Action Usage', size=32),
143         'report_type': fields.char('Report Type', size=32, required=True, help="Report Type, e.g. pdf, html, raw, sxw, odt, html2html, mako2html, ..."),
144         'groups_id': fields.many2many('res.groups', 'res_groups_report_rel', 'uid', 'gid', 'Groups'),
145         'multi': fields.boolean('On Multiple Doc.', help="If set to true, the action will not be displayed on the right toolbar of a form view."),
146         'attachment': fields.char('Save as Attachment Prefix', size=128, help='This is the filename of the attachment used to store the printing result. Keep empty to not save the printed reports. You can use a python expression with the object and time variables.'),
147         'attachment_use': fields.boolean('Reload from Attachment', help='If you check this, then the second time the user prints with same attachment name, it returns the previous report.'),
148         'auto': fields.boolean('Custom Python Parser'),
149
150         'header': fields.boolean('Add RML Header', help="Add or not the corporate RML header"),
151
152         'report_xsl': fields.char('XSL Path', size=256),
153         'report_xml': fields.char('XML Path', size=256, help=''),
154
155         # Pending deprecation... to be replaced by report_file as this object will become the default report object (not so specific to RML anymore)
156         'report_rml': fields.char('Main Report File Path', size=256, help="The path to the main report file (depending on Report Type) or NULL if the content is in another data field"),
157         # temporary related field as report_rml is pending deprecation - this field will replace report_rml after v6.0
158         'report_file': fields.related('report_rml', type="char", size=256, required=False, readonly=False, string='Report File', help="The path to the main report file (depending on Report Type) or NULL if the content is in another field", store=True),
159
160         'report_sxw': fields.function(_report_sxw, type='char', string='SXW Path'),
161         'report_sxw_content_data': fields.binary('SXW Content'),
162         'report_rml_content_data': fields.binary('RML Content'),
163         'report_sxw_content': fields.function(_report_content, fnct_inv=_report_content_inv, type='binary', string='SXW Content',),
164         'report_rml_content': fields.function(_report_content, fnct_inv=_report_content_inv, type='binary', string='RML Content'),
165
166         'parser': fields.char('Parser Class'),
167     }
168     _defaults = {
169         'type': 'ir.actions.report.xml',
170         'multi': False,
171         'auto': True,
172         'header': True,
173         'report_sxw_content': False,
174         'report_type': 'pdf',
175         'attachment': False,
176     }
177
178
179 class ir_actions_act_window(osv.osv):
180     _name = 'ir.actions.act_window'
181     _table = 'ir_act_window'
182     _inherit = 'ir.actions.actions'
183     _sequence = 'ir_actions_id_seq'
184     _order = 'name'
185
186     def _check_model(self, cr, uid, ids, context=None):
187         for action in self.browse(cr, uid, ids, context):
188             if action.res_model not in self.pool:
189                 return False
190             if action.src_model and action.src_model not in self.pool:
191                 return False
192         return True
193
194     def _invalid_model_msg(self, cr, uid, ids, context=None):
195         return _('Invalid model name in the action definition.')
196
197     _constraints = [
198         (_check_model, _invalid_model_msg, ['res_model','src_model'])
199     ]
200
201     def _views_get_fnc(self, cr, uid, ids, name, arg, context=None):
202         """Returns an ordered list of the specific view modes that should be
203            enabled when displaying the result of this action, along with the
204            ID of the specific view to use for each mode, if any were required.
205
206            This function hides the logic of determining the precedence between
207            the view_modes string, the view_ids o2m, and the view_id m2o that can
208            be set on the action.
209
210            :rtype: dict in the form { action_id: list of pairs (tuples) }
211            :return: { action_id: [(view_id, view_mode), ...], ... }, where view_mode
212                     is one of the possible values for ir.ui.view.type and view_id
213                     is the ID of a specific view to use for this mode, or False for
214                     the default one.
215         """
216         res = {}
217         for act in self.browse(cr, uid, ids):
218             res[act.id] = [(view.view_id.id, view.view_mode) for view in act.view_ids]
219             view_ids_modes = [view.view_mode for view in act.view_ids]
220             modes = act.view_mode.split(',')
221             missing_modes = [mode for mode in modes if mode not in view_ids_modes]
222             if missing_modes:
223                 if act.view_id and act.view_id.type in missing_modes:
224                     # reorder missing modes to put view_id first if present
225                     missing_modes.remove(act.view_id.type)
226                     res[act.id].append((act.view_id.id, act.view_id.type))
227                 res[act.id].extend([(False, mode) for mode in missing_modes])
228         return res
229
230     def _search_view(self, cr, uid, ids, name, arg, context=None):
231         res = {}
232         for act in self.browse(cr, uid, ids, context=context):
233             field_get = self.pool[act.res_model].fields_view_get(cr, uid,
234                 act.search_view_id and act.search_view_id.id or False,
235                 'search', context=context)
236             res[act.id] = str(field_get)
237         return res
238
239     _columns = {
240         'name': fields.char('Action Name', size=64, translate=True),
241         'type': fields.char('Action Type', size=32, required=True),
242         'view_id': fields.many2one('ir.ui.view', 'View Ref.', ondelete='cascade'),
243         'domain': fields.char('Domain Value',
244             help="Optional domain filtering of the destination data, as a Python expression"),
245         'context': fields.char('Context Value', required=True,
246             help="Context dictionary as Python expression, empty by default (Default: {})"),
247         'res_id': fields.integer('Record ID', help="Database ID of record to open in form view, when ``view_mode`` is set to 'form' only"),
248         'res_model': fields.char('Destination Model', size=64, required=True,
249             help="Model name of the object to open in the view window"),
250         'src_model': fields.char('Source Model', size=64,
251             help="Optional model name of the objects on which this action should be visible"),
252         'target': fields.selection([('current','Current Window'),('new','New Window'),('inline','Inline Edit'),('inlineview','Inline View')], 'Target Window'),
253         'view_mode': fields.char('View Mode', size=250, required=True,
254             help="Comma-separated list of allowed view modes, such as 'form', 'tree', 'calendar', etc. (Default: tree,form)"),
255         'view_type': fields.selection((('tree','Tree'),('form','Form')), string='View Type', required=True,
256             help="View type: Tree type to use for the tree view, set to 'tree' for a hierarchical tree view, or 'form' for a regular list view"),
257         'usage': fields.char('Action Usage', size=32,
258             help="Used to filter menu and home actions from the user form."),
259         'view_ids': fields.one2many('ir.actions.act_window.view', 'act_window_id', 'Views'),
260         'views': fields.function(_views_get_fnc, type='binary', string='Views',
261                help="This function field computes the ordered list of views that should be enabled " \
262                     "when displaying the result of an action, federating view mode, views and " \
263                     "reference view. The result is returned as an ordered list of pairs (view_id,view_mode)."),
264         'limit': fields.integer('Limit', help='Default limit for the list view'),
265         'auto_refresh': fields.integer('Auto-Refresh',
266             help='Add an auto-refresh on the view'),
267         'groups_id': fields.many2many('res.groups', 'ir_act_window_group_rel',
268             'act_id', 'gid', 'Groups'),
269         'search_view_id': fields.many2one('ir.ui.view', 'Search View Ref.'),
270         'filter': fields.boolean('Filter'),
271         'auto_search':fields.boolean('Auto Search'),
272         'search_view' : fields.function(_search_view, type='text', string='Search View'),
273         'multi': fields.boolean('Restrict to lists', help="If checked and the action is bound to a model, it will only appear in the More menu on list views"),
274     }
275
276     _defaults = {
277         'type': 'ir.actions.act_window',
278         'view_type': 'form',
279         'view_mode': 'tree,form',
280         'context': '{}',
281         'limit': 80,
282         'target': 'current',
283         'auto_refresh': 0,
284         'auto_search':True,
285         'multi': False,
286     }
287
288     def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
289         """ call the method get_empty_list_help of the model and set the window action help message
290         """
291         ids_int = isinstance(ids, (int, long))
292         if ids_int:
293             ids = [ids]
294         results = super(ir_actions_act_window, self).read(cr, uid, ids, fields=fields, context=context, load=load)
295
296         if not fields or 'help' in fields:
297             context = dict(context or {})
298             eval_dict = {
299                 'active_model': context.get('active_model'),
300                 'active_id': context.get('active_id'),
301                 'active_ids': context.get('active_ids'),
302                 'uid': uid,
303             }
304             for res in results:
305                 model = res.get('res_model')
306                 if model and self.pool.get(model):
307                     try:
308                         with tools.mute_logger("openerp.tools.safe_eval"):
309                             eval_context = eval(res['context'] or "{}", eval_dict) or {}
310                     except Exception:
311                         continue
312                     custom_context = dict(context, **eval_context)
313                     res['help'] = self.pool.get(model).get_empty_list_help(cr, uid, res.get('help', ""), context=custom_context)
314         if ids_int:
315             return results[0]
316         return results
317
318     def for_xml_id(self, cr, uid, module, xml_id, context=None):
319         """ Returns the act_window object created for the provided xml_id
320
321         :param module: the module the act_window originates in
322         :param xml_id: the namespace-less id of the action (the @id
323                        attribute from the XML file)
324         :return: A read() view of the ir.actions.act_window
325         """
326         dataobj = self.pool.get('ir.model.data')
327         data_id = dataobj._get_id (cr, SUPERUSER_ID, module, xml_id)
328         res_id = dataobj.browse(cr, uid, data_id, context).res_id
329         return self.read(cr, uid, res_id, [], context)
330
331 VIEW_TYPES = [
332     ('tree', 'Tree'),
333     ('form', 'Form'),
334     ('graph', 'Graph'),
335     ('calendar', 'Calendar'),
336     ('gantt', 'Gantt'),
337     ('kanban', 'Kanban')]
338 class ir_actions_act_window_view(osv.osv):
339     _name = 'ir.actions.act_window.view'
340     _table = 'ir_act_window_view'
341     _rec_name = 'view_id'
342     _order = 'sequence'
343     _columns = {
344         'sequence': fields.integer('Sequence'),
345         'view_id': fields.many2one('ir.ui.view', 'View'),
346         'view_mode': fields.selection(VIEW_TYPES, string='View Type', required=True),
347         'act_window_id': fields.many2one('ir.actions.act_window', 'Action', ondelete='cascade'),
348         'multi': fields.boolean('On Multiple Doc.',
349             help="If set to true, the action will not be displayed on the right toolbar of a form view."),
350     }
351     _defaults = {
352         'multi': False,
353     }
354     def _auto_init(self, cr, context=None):
355         super(ir_actions_act_window_view, self)._auto_init(cr, context)
356         cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'act_window_view_unique_mode_per_action\'')
357         if not cr.fetchone():
358             cr.execute('CREATE UNIQUE INDEX act_window_view_unique_mode_per_action ON ir_act_window_view (act_window_id, view_mode)')
359
360
361 class ir_actions_act_window_close(osv.osv):
362     _name = 'ir.actions.act_window_close'
363     _inherit = 'ir.actions.actions'
364     _table = 'ir_actions'
365     _defaults = {
366         'type': 'ir.actions.act_window_close',
367     }
368
369
370 class ir_actions_act_url(osv.osv):
371     _name = 'ir.actions.act_url'
372     _table = 'ir_act_url'
373     _inherit = 'ir.actions.actions'
374     _sequence = 'ir_actions_id_seq'
375     _order = 'name'
376     _columns = {
377         'name': fields.char('Action Name', size=64, translate=True),
378         'type': fields.char('Action Type', size=32, required=True),
379         'url': fields.text('Action URL',required=True),
380         'target': fields.selection((
381             ('new', 'New Window'),
382             ('self', 'This Window')),
383             'Action Target', required=True
384         )
385     }
386     _defaults = {
387         'type': 'ir.actions.act_url',
388         'target': 'new'
389     }
390
391
392 class ir_actions_server(osv.osv):
393     """ Server actions model. Server action work on a base model and offer various
394     type of actions that can be executed automatically, for example using base
395     action rules, of manually, by adding the action in the 'More' contextual
396     menu.
397
398     Since OpenERP 8.0 a button 'Create Menu Action' button is available on the
399     action form view. It creates an entry in the More menu of the base model.
400     This allows to create server actions and run them in mass mode easily through
401     the interface.
402
403     The available actions are :
404
405     - 'Execute Python Code': a block of python code that will be executed
406     - 'Trigger a Workflow Signal': send a signal to a workflow
407     - 'Run a Client Action': choose a client action to launch
408     - 'Create or Copy a new Record': create a new record with new values, or
409       copy an existing record in your database
410     - 'Write on a Record': update the values of a record
411     - 'Execute several actions': define an action that triggers several other
412       server actions
413     """
414     _name = 'ir.actions.server'
415     _table = 'ir_act_server'
416     _inherit = 'ir.actions.actions'
417     _sequence = 'ir_actions_id_seq'
418     _order = 'sequence,name'
419
420     def _select_objects(self, cr, uid, context=None):
421         model_pool = self.pool.get('ir.model')
422         ids = model_pool.search(cr, uid, [], limit=None)
423         res = model_pool.read(cr, uid, ids, ['model', 'name'])
424         return [(r['model'], r['name']) for r in res] + [('', '')]
425
426     def _get_states(self, cr, uid, context=None):
427         """ Override me in order to add new states in the server action. Please
428         note that the added key length should not be higher than already-existing
429         ones. """
430         return [('code', 'Execute Python Code'),
431                 ('trigger', 'Trigger a Workflow Signal'),
432                 ('client_action', 'Run a Client Action'),
433                 ('object_create', 'Create or Copy a new Record'),
434                 ('object_write', 'Write on a Record'),
435                 ('multi', 'Execute several actions')]
436
437     def _get_states_wrapper(self, cr, uid, context=None):
438         return self._get_states(cr, uid, context)
439
440     _columns = {
441         'name': fields.char('Action Name', required=True, size=64, translate=True),
442         'condition': fields.char('Condition',
443                                  help="Condition verified before executing the server action. If it "
444                                  "is not verified, the action will not be executed. The condition is "
445                                  "a Python expression, like 'object.list_price > 5000'. A void "
446                                  "condition is considered as always True. Help about python expression "
447                                  "is given in the help tab."),
448         'state': fields.selection(_get_states_wrapper, 'Action To Do', required=True,
449                                   help="Type of server action. The following values are available:\n"
450                                   "- 'Execute Python Code': a block of python code that will be executed\n"
451                                   "- 'Trigger a Workflow Signal': send a signal to a workflow\n"
452                                   "- 'Run a Client Action': choose a client action to launch\n"
453                                   "- 'Create or Copy a new Record': create a new record with new values, or copy an existing record in your database\n"
454                                   "- 'Write on a Record': update the values of a record\n"
455                                   "- 'Execute several actions': define an action that triggers several other server actions\n"
456                                   "- 'Send Email': automatically send an email (available in email_template)"),
457         'usage': fields.char('Action Usage', size=32),
458         'type': fields.char('Action Type', size=32, required=True),
459         # Generic
460         'sequence': fields.integer('Sequence',
461                                    help="When dealing with multiple actions, the execution order is "
462                                    "based on the sequence. Low number means high priority."),
463         'model_id': fields.many2one('ir.model', 'Base Model', required=True, ondelete='cascade',
464                                     help="Base model on which the server action runs."),
465         'model_name': fields.related('model_id', 'model', type='char',
466                                      string='Model Name', readonly=True),
467         'menu_ir_values_id': fields.many2one('ir.values', 'More Menu entry', readonly=True,
468                                              help='More menu entry.'),
469         # Client Action
470         'action_id': fields.many2one('ir.actions.actions', 'Client Action',
471                                      help="Select the client action that has to be executed."),
472         # Python code
473         'code': fields.text('Python Code',
474                             help="Write Python code that the action will execute. Some variables are "
475                             "available for use; help about pyhon expression is given in the help tab."),
476         # Workflow signal
477         'use_relational_model': fields.selection([('base', 'Use the base model of the action'),
478                                                   ('relational', 'Use a relation field on the base model')],
479                                                  string='Target Model', required=True),
480         'wkf_transition_id': fields.many2one('workflow.transition', string='Signal to Trigger',
481                                              help="Select the workflow signal to trigger."),
482         'wkf_model_id': fields.many2one('ir.model', 'Target Model',
483                                         help="The model that will receive the workflow signal. Note that it should have a workflow associated with it."),
484         'wkf_model_name': fields.related('wkf_model_id', 'model', type='char', string='Target Model Name', store=True, readonly=True),
485         'wkf_field_id': fields.many2one('ir.model.fields', string='Relation Field',
486                                         oldname='trigger_obj_id',
487                                         help="The field on the current object that links to the target object record (must be a many2one, or an integer field with the record ID)"),
488         # Multi
489         'child_ids': fields.many2many('ir.actions.server', 'rel_server_actions',
490                                       'server_id', 'action_id',
491                                       string='Child Actions',
492                                       help='Child server actions that will be executed. Note that the last return returned action value will be used as global return value.'),
493         # Create/Copy/Write
494         'use_create': fields.selection([('new', 'Create a new record in the Base Model'),
495                                         ('new_other', 'Create a new record in another model'),
496                                         ('copy_current', 'Copy the current record'),
497                                         ('copy_other', 'Choose and copy a record in the database')],
498                                        string="Creation Policy", required=True,
499                                        help=""),
500         'crud_model_id': fields.many2one('ir.model', 'Target Model',
501                                          oldname='srcmodel_id',
502                                          help="Model for record creation / update. Set this field only to specify a different model than the base model."),
503         'crud_model_name': fields.related('crud_model_id', 'model', type='char',
504                                           string='Create/Write Target Model Name',
505                                           store=True, readonly=True),
506         'ref_object': fields.reference('Reference record', selection=_select_objects, size=128,
507                                        oldname='copy_object'),
508         'link_new_record': fields.boolean('Attach the new record',
509                                           help="Check this if you want to link the newly-created record "
510                                           "to the current record on which the server action runs."),
511         'link_field_id': fields.many2one('ir.model.fields', 'Link using field',
512                                          oldname='record_id',
513                                          help="Provide the field where the record id is stored after the operations."),
514         'use_write': fields.selection([('current', 'Update the current record'),
515                                        ('expression', 'Update a record linked to the current record using python'),
516                                        ('other', 'Choose and Update a record in the database')],
517                                       string='Update Policy', required=True,
518                                       help=""),
519         'write_expression': fields.char('Expression',
520                                         oldname='write_id',
521                                         help="Provide an expression that, applied on the current record, gives the field to update."),
522         'fields_lines': fields.one2many('ir.server.object.lines', 'server_id',
523                                         string='Value Mapping',
524                                         help=""),
525
526         # Fake fields used to implement the placeholder assistant
527         'model_object_field': fields.many2one('ir.model.fields', string="Field",
528                                               help="Select target field from the related document model.\n"
529                                                    "If it is a relationship field you will be able to select "
530                                                    "a target field at the destination of the relationship."),
531         'sub_object': fields.many2one('ir.model', 'Sub-model', readonly=True,
532                                       help="When a relationship field is selected as first field, "
533                                            "this field shows the document model the relationship goes to."),
534         'sub_model_object_field': fields.many2one('ir.model.fields', 'Sub-field',
535                                                   help="When a relationship field is selected as first field, "
536                                                        "this field lets you select the target field within the "
537                                                        "destination document model (sub-model)."),
538         'copyvalue': fields.char('Placeholder Expression', help="Final placeholder expression, to be copy-pasted in the desired template field."),
539         # Fake fields used to implement the ID finding assistant
540         'id_object': fields.reference('Record', selection=_select_objects, size=128),
541         'id_value': fields.char('Record ID'),
542     }
543
544     _defaults = {
545         'state': 'code',
546         'condition': 'True',
547         'type': 'ir.actions.server',
548         'sequence': 5,
549         'code': """# You can use the following variables:
550 #  - self: ORM model of the record on which the action is triggered
551 #  - object: browse_record of the record on which the action is triggered if there is one, otherwise None
552 #  - pool: ORM model pool (i.e. self.pool)
553 #  - cr: database cursor
554 #  - uid: current user id
555 #  - context: current context
556 #  - time: Python time module
557 # If you plan to return an action, assign: action = {...}""",
558         'use_relational_model': 'base',
559         'use_create': 'new',
560         'use_write': 'current',
561     }
562
563     def _check_expression(self, cr, uid, expression, model_id, context):
564         """ Check python expression (condition, write_expression). Each step of
565         the path must be a valid many2one field, or an integer field for the last
566         step.
567
568         :param str expression: a python expression, beginning by 'obj' or 'object'
569         :param int model_id: the base model of the server action
570         :returns tuple: (is_valid, target_model_name, error_msg)
571         """
572         if not model_id:
573             return (False, None, 'Your expression cannot be validated because the Base Model is not set.')
574         # fetch current model
575         current_model_name = self.pool.get('ir.model').browse(cr, uid, model_id, context).model
576         # transform expression into a path that should look like 'object.many2onefield.many2onefield'
577         path = expression.split('.')
578         initial = path.pop(0)
579         if initial not in ['obj', 'object']:
580             return (False, None, 'Your expression should begin with obj or object.\nAn expression builder is available in the help tab.')
581         # analyze path
582         while path:
583             step = path.pop(0)
584             column_info = self.pool[current_model_name]._all_columns.get(step)
585             if not column_info:
586                 return (False, None, 'Part of the expression (%s) is not recognized as a column in the model %s.' % (step, current_model_name))
587             column_type = column_info.column._type
588             if column_type not in ['many2one', 'int']:
589                 return (False, None, 'Part of the expression (%s) is not a valid column type (is %s, should be a many2one or an int)' % (step, column_type))
590             if column_type == 'int' and path:
591                 return (False, None, 'Part of the expression (%s) is an integer field that is only allowed at the end of an expression' % (step))
592             if column_type == 'many2one':
593                 current_model_name = column_info.column._obj
594         return (True, current_model_name, None)
595
596     def _check_write_expression(self, cr, uid, ids, context=None):
597         for record in self.browse(cr, uid, ids, context=context):
598             if record.write_expression and record.model_id:
599                 correct, model_name, message = self._check_expression(cr, uid, record.write_expression, record.model_id.id, context=context)
600                 if not correct:
601                     _logger.warning('Invalid expression: %s' % message)
602                     return False
603         return True
604
605     _constraints = [
606         (_check_write_expression,
607             'Incorrect Write Record Expression',
608             ['write_expression']),
609         (partial(osv.Model._check_m2m_recursion, field_name='child_ids'),
610             'Recursion found in child server actions',
611             ['child_ids']),
612     ]
613
614     def on_change_model_id(self, cr, uid, ids, model_id, wkf_model_id, crud_model_id, context=None):
615         """ When changing the action base model, reset workflow and crud config
616         to ease value coherence. """
617         values = {
618             'use_create': 'new',
619             'use_write': 'current',
620             'use_relational_model': 'base',
621             'wkf_model_id': model_id,
622             'wkf_field_id': False,
623             'crud_model_id': model_id,
624         }
625
626         if model_id:
627             values['model_name'] = self.pool.get('ir.model').browse(cr, uid, model_id, context).model
628
629         return {'value': values}
630
631     def on_change_wkf_wonfig(self, cr, uid, ids, use_relational_model, wkf_field_id, wkf_model_id, model_id, context=None):
632         """ Update workflow type configuration
633
634          - update the workflow model (for base (model_id) /relational (field.relation))
635          - update wkf_transition_id to False if workflow model changes, to force
636            the user to choose a new one
637         """
638         values = {}
639         if use_relational_model == 'relational' and wkf_field_id:
640             field = self.pool['ir.model.fields'].browse(cr, uid, wkf_field_id, context=context)
641             new_wkf_model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', field.relation)], context=context)[0]
642             values['wkf_model_id'] = new_wkf_model_id
643         else:
644             values['wkf_model_id'] = model_id
645         return {'value': values}
646
647     def on_change_wkf_model_id(self, cr, uid, ids, wkf_model_id, context=None):
648         """ When changing the workflow model, update its stored name also """
649         wkf_model_name = False
650         if wkf_model_id:
651             wkf_model_name = self.pool.get('ir.model').browse(cr, uid, wkf_model_id, context).model
652         values = {'wkf_transition_id': False, 'wkf_model_name': wkf_model_name}
653         return {'value': values}
654
655     def on_change_crud_config(self, cr, uid, ids, state, use_create, use_write, ref_object, crud_model_id, model_id, context=None):
656         """ Wrapper on CRUD-type (create or write) on_change """
657         if state == 'object_create':
658             return self.on_change_create_config(cr, uid, ids, use_create, ref_object, crud_model_id, model_id, context=context)
659         elif state == 'object_write':
660             return self.on_change_write_config(cr, uid, ids, use_write, ref_object, crud_model_id, model_id, context=context)
661         else:
662             return {}
663
664     def on_change_create_config(self, cr, uid, ids, use_create, ref_object, crud_model_id, model_id, context=None):
665         """ When changing the object_create type configuration:
666
667          - `new` and `copy_current`: crud_model_id is the same as base model
668          - `new_other`: user choose crud_model_id
669          - `copy_other`: disassemble the reference object to have its model
670          - if the target model has changed, then reset the link field that is
671            probably not correct anymore
672         """
673         values = {}
674         if use_create == 'new':
675             values['crud_model_id'] = model_id
676         elif use_create == 'new_other':
677             pass
678         elif use_create == 'copy_current':
679             values['crud_model_id'] = model_id
680         elif use_create == 'copy_other' and ref_object:
681             ref_model, ref_id = ref_object.split(',')
682             ref_model_id = self.pool['ir.model'].search(cr, uid, [('model', '=', ref_model)], context=context)[0]
683             values['crud_model_id'] = ref_model_id
684
685         if values.get('crud_model_id') != crud_model_id:
686             values['link_field_id'] = False
687         return {'value': values}
688
689     def on_change_write_config(self, cr, uid, ids, use_write, ref_object, crud_model_id, model_id, context=None):
690         """ When changing the object_write type configuration:
691
692          - `current`: crud_model_id is the same as base model
693          - `other`: disassemble the reference object to have its model
694          - `expression`: has its own on_change, nothing special here
695         """
696         values = {}
697         if use_write == 'current':
698             values['crud_model_id'] = model_id
699         elif use_write == 'other' and ref_object:
700             ref_model, ref_id = ref_object.split(',')
701             ref_model_id = self.pool['ir.model'].search(cr, uid, [('model', '=', ref_model)], context=context)[0]
702             values['crud_model_id'] = ref_model_id
703         elif use_write == 'expression':
704             pass
705
706         if values.get('crud_model_id') != crud_model_id:
707             values['link_field_id'] = False
708         return {'value': values}
709
710     def on_change_write_expression(self, cr, uid, ids, write_expression, model_id, context=None):
711         """ Check the write_expression and update crud_model_id accordingly """
712         values = {}
713         valid, model_name, message = self._check_expression(cr, uid, write_expression, model_id, context=context)
714         if valid:
715             ref_model_id = self.pool['ir.model'].search(cr, uid, [('model', '=', model_name)], context=context)[0]
716             values['crud_model_id'] = ref_model_id
717             return {'value': values}
718         if not message:
719             message = 'Invalid expression'
720         return {
721             'warning': {
722                 'title': 'Incorrect expression',
723                 'message': message,
724             }
725         }
726
727     def on_change_crud_model_id(self, cr, uid, ids, crud_model_id, context=None):
728         """ When changing the CRUD model, update its stored name also """
729         crud_model_name = False
730         if crud_model_id:
731             crud_model_name = self.pool.get('ir.model').browse(cr, uid, crud_model_id, context).model
732         
733         values = {'link_field_id': False, 'crud_model_name': crud_model_name}
734         return {'value': values}
735
736     def _build_expression(self, field_name, sub_field_name):
737         """ Returns a placeholder expression for use in a template field,
738         based on the values provided in the placeholder assistant.
739
740         :param field_name: main field name
741         :param sub_field_name: sub field name (M2O)
742         :return: final placeholder expression
743         """
744         expression = ''
745         if field_name:
746             expression = "object." + field_name
747             if sub_field_name:
748                 expression += "." + sub_field_name
749         return expression
750
751     def onchange_sub_model_object_value_field(self, cr, uid, ids, model_object_field, sub_model_object_field=False, context=None):
752         result = {
753             'sub_object': False,
754             'copyvalue': False,
755             'sub_model_object_field': False,
756         }
757         if model_object_field:
758             fields_obj = self.pool.get('ir.model.fields')
759             field_value = fields_obj.browse(cr, uid, model_object_field, context)
760             if field_value.ttype in ['many2one', 'one2many', 'many2many']:
761                 res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_value.relation)], context=context)
762                 sub_field_value = False
763                 if sub_model_object_field:
764                     sub_field_value = fields_obj.browse(cr, uid, sub_model_object_field, context)
765                 if res_ids:
766                     result.update({
767                         'sub_object': res_ids[0],
768                         'copyvalue': self._build_expression(field_value.name, sub_field_value and sub_field_value.name or False),
769                         'sub_model_object_field': sub_model_object_field or False,
770                     })
771             else:
772                 result.update({
773                     'copyvalue': self._build_expression(field_value.name, False),
774                 })
775         return {'value': result}
776
777     def onchange_id_object(self, cr, uid, ids, id_object, context=None):
778         if id_object:
779             ref_model, ref_id = id_object.split(',')
780             return {'value': {'id_value': ref_id}}
781         return {'value': {'id_value': False}}
782
783     def create_action(self, cr, uid, ids, context=None):
784         """ Create a contextual action for each of the server actions. """
785         for action in self.browse(cr, uid, ids, context=context):
786             ir_values_id = self.pool.get('ir.values').create(cr, SUPERUSER_ID, {
787                 'name': _('Run %s') % action.name,
788                 'model': action.model_id.model,
789                 'key2': 'client_action_multi',
790                 'value': "ir.actions.server,%s" % action.id,
791             }, context)
792             action.write({
793                 'menu_ir_values_id': ir_values_id,
794             })
795
796         return True
797
798     def unlink_action(self, cr, uid, ids, context=None):
799         """ Remove the contextual actions created for the server actions. """
800         for action in self.browse(cr, uid, ids, context=context):
801             if action.menu_ir_values_id:
802                 try:
803                     self.pool.get('ir.values').unlink(cr, SUPERUSER_ID, action.menu_ir_values_id.id, context)
804                 except Exception:
805                     raise osv.except_osv(_('Warning'), _('Deletion of the action record failed.'))
806         return True
807
808     def run_action_client_action(self, cr, uid, action, eval_context=None, context=None):
809         if not action.action_id:
810             raise osv.except_osv(_('Error'), _("Please specify an action to launch!"))
811         return self.pool[action.action_id.type].read(cr, uid, action.action_id.id, context=context)
812
813     def run_action_code_multi(self, cr, uid, action, eval_context=None, context=None):
814         eval(action.code.strip(), eval_context, mode="exec", nocopy=True)  # nocopy allows to return 'action'
815         if 'action' in eval_context:
816             return eval_context['action']
817
818     def run_action_trigger(self, cr, uid, action, eval_context=None, context=None):
819         """ Trigger a workflow signal, depending on the use_relational_model:
820
821          - `base`: base_model_pool.signal_<TRIGGER_NAME>(cr, uid, context.get('active_id'))
822          - `relational`: find the related model and object, using the relational
823            field, then target_model_pool.signal_<TRIGGER_NAME>(cr, uid, target_id)
824         """
825         obj_pool = self.pool[action.model_id.model]
826         if action.use_relational_model == 'base':
827             target_id = context.get('active_id')
828             target_pool = obj_pool
829         else:
830             value = getattr(obj_pool.browse(cr, uid, context.get('active_id'), context=context), action.wkf_field_id.name)
831             if action.wkf_field_id.ttype == 'many2one':
832                 target_id = value.id
833             else:
834                 target_id = value
835             target_pool = self.pool[action.wkf_model_id.model]
836
837         trigger_name = action.wkf_transition_id.signal
838
839         workflow.trg_validate(uid, target_pool._name, target_id, trigger_name, cr)
840
841     def run_action_multi(self, cr, uid, action, eval_context=None, context=None):
842         res = []
843         for act in action.child_ids:
844             result = self.run(cr, uid, [act.id], context)
845             if result:
846                 res.append(result)
847         return res and res[0] or False
848
849     def run_action_object_write(self, cr, uid, action, eval_context=None, context=None):
850         """ Write server action.
851
852          - 1. evaluate the value mapping
853          - 2. depending on the write configuration:
854
855           - `current`: id = active_id
856           - `other`: id = from reference object
857           - `expression`: id = from expression evaluation
858         """
859         res = {}
860         for exp in action.fields_lines:
861             if exp.type == 'equation':
862                 expr = eval(exp.value, eval_context)
863             else:
864                 expr = exp.value
865             res[exp.col1.name] = expr
866
867         if action.use_write == 'current':
868             model = action.model_id.model
869             ref_id = context.get('active_id')
870         elif action.use_write == 'other':
871             model = action.crud_model_id.model
872             ref_id = action.ref_object.id
873         elif action.use_write == 'expression':
874             model = action.crud_model_id.model
875             ref = eval(action.write_expression, eval_context)
876             if isinstance(ref, browse_record):
877                 ref_id = getattr(ref, 'id')
878             else:
879                 ref_id = int(ref)
880
881         obj_pool = self.pool[model]
882         obj_pool.write(cr, uid, [ref_id], res, context=context)
883
884     def run_action_object_create(self, cr, uid, action, eval_context=None, context=None):
885         """ Create and Copy server action.
886
887          - 1. evaluate the value mapping
888          - 2. depending on the write configuration:
889
890           - `new`: new record in the base model
891           - `copy_current`: copy the current record (id = active_id) + gives custom values
892           - `new_other`: new record in target model
893           - `copy_other`: copy the current record (id from reference object)
894             + gives custom values
895         """
896         res = {}
897         for exp in action.fields_lines:
898             if exp.type == 'equation':
899                 expr = eval(exp.value, eval_context)
900             else:
901                 expr = exp.value
902             res[exp.col1.name] = expr
903
904         if action.use_create in ['new', 'copy_current']:
905             model = action.model_id.model
906         elif action.use_create in ['new_other', 'copy_other']:
907             model = action.crud_model_id.model
908
909         obj_pool = self.pool[model]
910         if action.use_create == 'copy_current':
911             ref_id = context.get('active_id')
912             res_id = obj_pool.copy(cr, uid, ref_id, res, context=context)
913         elif action.use_create == 'copy_other':
914             ref_id = action.ref_object.id
915             res_id = obj_pool.copy(cr, uid, ref_id, res, context=context)
916         else:
917             res_id = obj_pool.create(cr, uid, res, context=context)
918
919         if action.link_new_record and action.link_field_id:
920             self.pool[action.model_id.model].write(cr, uid, [context.get('active_id')], {action.link_field_id.name: res_id})
921
922     def _eval_context_for_action(self, cr, uid, action, context=None):
923         if context is None:
924             context = {}
925         model = self.pool[action.model_id.model]
926         active_id = context.get('active_id')
927         active_ids = context.get('active_ids', [active_id] if active_id else [])
928         target_record = None
929         if context.get('active_model') == action.model_id.model and active_id:
930             context = dict(context, active_ids=active_ids, active_id=active_id)
931             target_record = model.browse(cr, uid, active_id, context=context) if active_id else None
932         user = self.pool['res.users'].browse(cr, uid, uid)
933         eval_context = {
934             'self': model,
935             'object': target_record,
936             'obj': target_record,
937             'pool': self.pool,
938             'time': time,
939             'datetime': datetime,
940             'dateutil': dateutil,
941             'cr': cr,
942             'uid': uid,
943             'user': user,
944             'context': context,
945             'Warning': openerp.exceptions.Warning,
946         }
947         return eval_context
948
949
950     def run(self, cr, uid, ids, context=None):
951         """ Runs the server action. For each server action, the condition is
952         checked. Note that a void (``False``) condition is considered as always
953         valid. If it is verified, the run_action_<STATE> method is called. This
954         allows easy overriding of the server actions.
955
956         :param dict context: context should contain following keys
957
958                              - active_id: id of the current object (single mode)
959                              - active_model: current model that should equal the action's model
960
961                              The following keys are optional:
962
963                              - active_ids: ids of the current records (mass mode). If active_ids
964                                and active_id are present, active_ids is given precedence.
965
966         :return: an action_id to be executed, or False is finished correctly without
967                  return action
968         """
969         if context is None:
970             context = {}
971         res = False
972         for action in self.browse(cr, uid, ids, context):
973             eval_context = self._eval_context_for_action(cr, uid, action, context)
974             condition = action.condition
975             if condition is False:
976                 # Void (aka False) conditions are considered as True
977                 condition = True
978             if hasattr(self, 'run_action_%s_multi' % action.state):
979                 run_context = eval_context['context']
980                 expr = eval(str(condition), eval_context)
981                 if not expr:
982                     continue
983                 # call the multi method
984                 func = getattr(self, 'run_action_%s_multi' % action.state)
985                 res = func(cr, uid, action, eval_context=eval_context, context=run_context)
986
987             elif hasattr(self, 'run_action_%s' % action.state):
988                 func = getattr(self, 'run_action_%s' % action.state)
989                 active_id = context.get('active_id')
990                 active_ids = context.get('active_ids', [active_id] if active_id else [])
991                 for active_id in active_ids:
992                     # run context dedicated to a particular active_id
993                     run_context = dict(context, active_ids=[active_id], active_id=active_id)
994                     eval_context["context"] = run_context
995                     expr = eval(str(condition), eval_context)
996                     if not expr:
997                         continue
998                     # call the single method related to the action: run_action_<STATE>
999                     res = func(cr, uid, action, eval_context=eval_context, context=run_context)
1000         return res
1001
1002
1003 class ir_server_object_lines(osv.osv):
1004     _name = 'ir.server.object.lines'
1005     _sequence = 'ir_actions_id_seq'
1006     _columns = {
1007         'server_id': fields.many2one('ir.actions.server', 'Related Server Action'),
1008         'col1': fields.many2one('ir.model.fields', 'Field', required=True),
1009         'value': fields.text('Value', required=True, help="Expression containing a value specification. \n"
1010                                                           "When Formula type is selected, this field may be a Python expression "
1011                                                           " that can use the same values as for the condition field on the server action.\n"
1012                                                           "If Value type is selected, the value will be used directly without evaluation."),
1013         'type': fields.selection([
1014             ('value', 'Value'),
1015             ('equation', 'Python expression')
1016         ], 'Evaluation Type', required=True, change_default=True),
1017     }
1018     _defaults = {
1019         'type': 'value',
1020     }
1021
1022
1023 TODO_STATES = [('open', 'To Do'),
1024                ('done', 'Done')]
1025 TODO_TYPES = [('manual', 'Launch Manually'),('once', 'Launch Manually Once'),
1026               ('automatic', 'Launch Automatically')]
1027 class ir_actions_todo(osv.osv):
1028     """
1029     Configuration Wizards
1030     """
1031     _name = 'ir.actions.todo'
1032     _description = "Configuration Wizards"
1033     _columns={
1034         'action_id': fields.many2one(
1035             'ir.actions.actions', 'Action', select=True, required=True),
1036         'sequence': fields.integer('Sequence'),
1037         'state': fields.selection(TODO_STATES, string='Status', required=True),
1038         'name': fields.char('Name', size=64),
1039         'type': fields.selection(TODO_TYPES, 'Type', required=True,
1040             help="""Manual: Launched manually.
1041 Automatic: Runs whenever the system is reconfigured.
1042 Launch Manually Once: after having been launched manually, it sets automatically to Done."""),
1043         'groups_id': fields.many2many('res.groups', 'res_groups_action_rel', 'uid', 'gid', 'Groups'),
1044         'note': fields.text('Text', translate=True),
1045     }
1046     _defaults={
1047         'state': 'open',
1048         'sequence': 10,
1049         'type': 'manual',
1050     }
1051     _order="sequence,id"
1052
1053     def action_launch(self, cr, uid, ids, context=None):
1054         """ Launch Action of Wizard"""
1055         wizard_id = ids and ids[0] or False
1056         wizard = self.browse(cr, uid, wizard_id, context=context)
1057         if wizard.type in ('automatic', 'once'):
1058             wizard.write({'state': 'done'})
1059
1060         # Load action
1061         act_type = self.pool.get('ir.actions.actions').read(cr, uid, wizard.action_id.id, ['type'], context=context)
1062
1063         res = self.pool[act_type['type']].read(cr, uid, wizard.action_id.id, [], context=context)
1064         if act_type['type'] != 'ir.actions.act_window':
1065             return res
1066         res.setdefault('context','{}')
1067         res['nodestroy'] = True
1068
1069         # Open a specific record when res_id is provided in the context
1070         user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
1071         ctx = eval(res['context'], {'user': user})
1072         if ctx.get('res_id'):
1073             res.update({'res_id': ctx.pop('res_id')})
1074
1075         # disable log for automatic wizards
1076         if wizard.type == 'automatic':
1077             ctx.update({'disable_log': True})
1078         res.update({'context': ctx})
1079
1080         return res
1081
1082     def action_open(self, cr, uid, ids, context=None):
1083         """ Sets configuration wizard in TODO state"""
1084         return self.write(cr, uid, ids, {'state': 'open'}, context=context)
1085
1086     def progress(self, cr, uid, context=None):
1087         """ Returns a dict with 3 keys {todo, done, total}.
1088
1089         These keys all map to integers and provide the number of todos
1090         marked as open, the total number of todos and the number of
1091         todos not open (which is basically a shortcut to total-todo)
1092
1093         :rtype: dict
1094         """
1095         user_groups = set(map(
1096             lambda x: x.id,
1097             self.pool['res.users'].browse(cr, uid, [uid], context=context)[0].groups_id))
1098         def groups_match(todo):
1099             """ Checks if the todo's groups match those of the current user
1100             """
1101             return not todo.groups_id \
1102                    or bool(user_groups.intersection((
1103                         group.id for group in todo.groups_id)))
1104
1105         done = filter(
1106             groups_match,
1107             self.browse(cr, uid,
1108                 self.search(cr, uid, [('state', '!=', 'open')], context=context),
1109                         context=context))
1110
1111         total = filter(
1112             groups_match,
1113             self.browse(cr, uid,
1114                 self.search(cr, uid, [], context=context),
1115                         context=context))
1116
1117         return {
1118             'done': len(done),
1119             'total': len(total),
1120             'todo': len(total) - len(done)
1121         }
1122
1123
1124 class ir_actions_act_client(osv.osv):
1125     _name = 'ir.actions.client'
1126     _inherit = 'ir.actions.actions'
1127     _table = 'ir_act_client'
1128     _sequence = 'ir_actions_id_seq'
1129     _order = 'name'
1130
1131     def _get_params(self, cr, uid, ids, field_name, arg, context):
1132         result = {}
1133         for record in self.browse(cr, uid, ids, context=context):
1134             result[record.id] = record.params_store and eval(record.params_store, {'uid': uid}) or False
1135         return result
1136
1137     def _set_params(self, cr, uid, id, field_name, field_value, arg, context):
1138         if isinstance(field_value, dict):
1139             self.write(cr, uid, id, {'params_store': repr(field_value)}, context=context)
1140         else:
1141             self.write(cr, uid, id, {'params_store': field_value}, context=context)
1142
1143     _columns = {
1144         'name': fields.char('Action Name', required=True, size=64, translate=True),
1145         'tag': fields.char('Client action tag', size=64, required=True,
1146                            help="An arbitrary string, interpreted by the client"
1147                                 " according to its own needs and wishes. There "
1148                                 "is no central tag repository across clients."),
1149         'res_model': fields.char('Destination Model', size=64, 
1150             help="Optional model, mostly used for needactions."),
1151         'context': fields.char('Context Value', size=250, required=True,
1152             help="Context dictionary as Python expression, empty by default (Default: {})"),
1153         'params': fields.function(_get_params, fnct_inv=_set_params,
1154                                   type='binary', 
1155                                   string="Supplementary arguments",
1156                                   help="Arguments sent to the client along with"
1157                                        "the view tag"),
1158         'params_store': fields.binary("Params storage", readonly=True)
1159     }
1160     _defaults = {
1161         'type': 'ir.actions.client',
1162         'context': '{}',
1163
1164     }
1165
1166
1167
1168 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1169