<form string="Report xml">
<field name="name" select="1"/>
<field name="type" select="1"/>
+ <field name="model" select="1" />
<field name="report_name" select="1"/>
<field name="report_xsl"/>
<field name="report_xml"/>
<field name="model_id" select="1"/>
<field name="sequence" select="2"/>
<notebook colspan="4">
- <!--<page string="Python Code" attrs="{'invisible':[('state','!=','python')]}">
- <separator colspan="4" string="Python code"/>
- <field name="code" colspan="4" nolabel="1" />
- <button string="Create Action" name="%(wizard_server_action_create)d" type="action"/>
- </page>
-
- --><page string="Trigger" attrs="{'invisible':[('state','!=','trigger')]}">
+ <page string="Trigger" attrs="{'invisible':[('state','!=','trigger')]}">
<separator colspan="4" string="Trigger Configuration"/>
<field name="wkf_model_id"/>
<field name="trigger_obj_id" select="2" domain="[('model_id','=',model_id)]" on_change="on_trigger_obj_id(trigger_obj_id)"/>
<page string="Multi Actions" attrs="{'invisible':[('state','!=','other')]}">
<separator colspan="4" string="Other Actions Configuration"/>
<field name="child_ids" nolabel="1" colspan="4"/>
- <label colspan="4" string="Only one client action will be execute, last clinent action will be consider in case of multipls clinets actions" align="0.0"/>
+ <label colspan="4" string="Only one client action will be execute, last
+ clinent action will be consider in case of multiples clients actions" align="0.0"/>
</page>
</notebook>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ir.actions.server</field>
<field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
<field name="view_id" ref="view_server_action_tree"/>
<field name="context">{'key':'server_action'}</field>
</record>
('html', 'html'),
('raw', 'raw'),
('sxw', 'sxw'),
+ ('txt', 'txt'),
], string='Type', required=True),
'groups_id': fields.many2many('res.groups', 'res_groups_report_rel', 'uid', 'gid', 'Groups'),
'attachment': fields.char('Save As Attachment Prefix', size=32, help='This is the prefix of the file name the print will be saved as attachement. Keep empty to not save the printed reports')
#
class actions_server(osv.osv):
+ def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
+ res = super(actions_server, self).fields_view_get(cr, user, view_id, view_type, context, toolbar)
+ #print 'RES : ',res
+ return res
+
def _select_signals(self, cr, uid, context={}):
cr.execute("select distinct t.signal as key, t.signal || ' - [ ' || w.osv || ' ] ' as val from wkf w, wkf_activity a, wkf_transition t "\
" where w.id = a.wkf_id " \
" and t.act_from = a.wkf_id " \
- " or t.act_to = a.wkf_id ")
- return cr.fetchall()
-
- def on_trigger_obj_id(self, cr, uid, ids, context={}):
- cr.execute("select distinct t.signal as key, t.signal as val from wkf w, wkf_activity a, wkf_transition t "\
- " where w.id = a.wkf_id " \
- " and t.act_from = a.wkf_id " \
- " or t.act_to = a.wkf_id " \
- " and w.osv = %s ", ('account.invoice'))
- data = cr.fetchall()
- return {"values":{'trigger_name':data}}
+ " or t.act_to = a.wkf_id and t.signal not in (null, NULL)")
+ result = cr.fetchall() or []
+ res = []
+ for rs in result:
+ if not rs[0] == None and not rs[1] == None:
+ res.append(rs)
+ return res
_name = 'ir.actions.server'
_table = 'ir_act_server'
('object_write','Write Object'),
('other','Multi Actions'),
], 'Action State', required=True, size=32),
- 'code': fields.text('Python Code'),
'sequence': fields.integer('Sequence'),
'model_id': fields.many2one('ir.model', 'Object', required=True),
'action_id': fields.many2one('ir.actions.actions', 'Client Action'),
_defaults = {
'state': lambda *a: 'dummy',
'type': lambda *a: 'ir.actions.server',
- 'sequence': lambda *a: 0,
- 'code': lambda *a: """# You can use the following variables
- # - object
- # - object2
- # - time
- # - cr
- # - uid
- # - ids
- # If you plan to return an action, assign: action = {...}
- """,
+ 'sequence': lambda *a: 5,
}
if exp.type == 'equation':
obj_pool = self.pool.get(action.model_id.model)
obj = obj_pool.browse(cr, uid, context['active_id'], context=context)
- expr = eval(euq, {'context':context, 'object': obj})
+ expr = eval(euq, {'context':context, 'object': obj, 'time':time})
else:
expr = exp.value
res[exp.col1.name] = expr
if exp.type == 'equation':
obj_pool = self.pool.get(action.model_id.model)
obj = obj_pool.browse(cr, uid, context['active_id'], context=context)
- expr = eval(euq, {'context':context, 'object': obj})
+ expr = eval(euq, {'context':context, 'object': obj, 'time':time})
else:
expr = exp.value
res[exp.col1.name] = expr
logging.getLogger().addHandler(handler)
logging.getLogger().setLevel(config['log_level'])
- if isinstance(handler, logging.StreamHandler) and os.name != 'nt':
+ if (not isinstance(handler, logging.FileHandler)) and os.name != 'nt':
# change color of level names
# uses of ANSI color codes
# see http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html
class GenericXMLRPCRequestHandler:
def _dispatch(self, method, params):
- #print 'TERP-CALL : ',method, params
+ # print 'TERP-CALL : ',method, params
import traceback
try:
n = self.path.split("/")[-1]
ts.mysend(r)
except Exception, e:
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
- print e
- print tb_s
import tools
if tools.config['debug_mode']:
import pdb
col = self._table._columns[name]
elif name in self._table._inherit_fields:
col = self._table._inherit_fields[name][2]
- elif hasattr(self._table, name):
+ elif hasattr(self._table, str(name)):
if isinstance(getattr(self._table, name), (types.MethodType, types.LambdaType, types.FunctionType)):
return lambda *args, **argv: getattr(self._table, name)(self._cr, self._uid, [self._id], *args, **argv)
else:
elif f._type in ('one2many', 'many2many') and len(data[n]):
data[n] = self._list_class([browse_record(self._cr, self._uid, id, self._table.pool.get(f._obj), self._cache, context=self._context, list_class=self._list_class, fields_process=self._fields_process) for id in data[n]], self._context)
self._data[data['id']].update(data)
+ if not name in self._data[self._id]:
+ #how did this happen?
+ raise AttributeError(_('Unknown attribute % in % ') % (name,self._id))
return self._data[self._id][name]
def __getattr__(self, name):
module, xml_id = current_module, line[i]
ir_model_data_obj = self.pool.get('ir.model.data')
id = ir_model_data_obj._get_id(cr, uid, module, xml_id)
- res_id = ir_model_data_obj.read(cr, uid, [id],
- ['res_id'])[0]['res_id']
+ res_res_id = ir_model_data_obj.read(cr, uid, [id],
+ ['res_id'])
+ if res_res_id:
+ res_id = res_res_id[0]['res_id']
row[field[0][:-3]] = res_id or False
continue
if (len(field) == len(prefix)+1) and \
translation_obj = self.pool.get('ir.translation')
model_access_obj = self.pool.get('ir.model.access')
for parent in self._inherits:
- res.update(self.pool.get(parent).fields_get(cr, user, fields,
- context))
+ res.update(self.pool.get(parent).fields_get(cr, user, fields, context))
for f in self._columns.keys():
- if fields and f not in fields:
- continue
+ if fields and f not in fields:
+ continue
res[f] = {'type': self._columns[f]._type}
for arg in ('string', 'readonly', 'states', 'size', 'required',
'change_default', 'translate', 'help', 'select'):
and getattr(self._columns[f], arg):
res[f][arg] = getattr(self._columns[f], arg)
- res_trans = translation_obj._get_source(cr, user,
- self._name + ',' + f, 'field', context.get('lang', False) or 'en_US')
+ res_trans = translation_obj._get_source(cr, user, self._name + ',' + f, 'field', context.get('lang', False) or 'en_US')
if res_trans:
res[f]['string'] = res_trans
- help_trans = translation_obj._get_source(cr, user,
- self._name + ',' + f, 'help', context.get('lang', False) or 'en_US')
+ help_trans = translation_obj._get_source(cr, user, self._name + ',' + f, 'help', context.get('lang', False) or 'en_US')
if help_trans:
res[f]['help'] = help_trans
for (key, val) in sel:
val2 = None
if val:
- val2 = translation_obj._get_source(cr, user,
- self._name + ',' + f, 'selection',
- context.get('lang', False) or 'en_US', val)
+ val2 = translation_obj._get_source(cr, user, self._name + ',' + f, 'selection', context.get('lang', False) or 'en_US', val)
sel2.append((key, val2 or val))
sel = sel2
res[f]['selection'] = sel
arch = node.toxml(encoding="utf-8").replace('\t', '')
fields = self.fields_get(cr, user, fields_def.keys(), context)
- for field in fields_def:
+ for field in fields:
fields[field].update(fields_def[field])
return arch, fields
if attr != 'position'
])
tag = "<%s%s>" % (node2.localName, attrs)
- raise AttributeError(_("Couldn't find tag '%s' in parent view !") % tag)
+ raise AttributeError(_("Couldn't find tag '%s' in parent view !\n%s") % (tag,src))
return doc_src.toxml(encoding="utf-8").replace('\t', '')
result = {'type': view_type, 'model': self._name}
all_timezones=[]
pytz=pytzclass()
idref2['pytz'] = pytz
- return eval(a_eval, idref2)
+ try:
+ return eval(a_eval, idref2)
+ except:
+ logger = netsvc.Logger()
+ logger.notifyChannel("init", netsvc.LOG_WARNING, 'could eval(%s) for %s in %s, please get back and fix it!' % (a_eval,node.getAttribute('name'),context))
+ return ""
if t == 'xml':
def _process(s, idref):
m = re.findall('[^%]%\((.*?)\)[ds]', s)
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
self.idref[xml_id] = int(id)
+
+
if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')):
keyword = str(rec.getAttribute('keyword') or 'client_print_multi')
keys = [('action',keyword),('res_model',res['model'])]
value = 'ir.actions.report.xml,'+str(id)
- replace = rec.hasAttribute('replace') and rec.getAttribute("replace")
+ replace = rec.hasAttribute('replace') and rec.getAttribute("replace") or True
self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, res['name'], [res['model']], value, replace=replace, isobject=True, xml_id=xml_id)
return False
keyword = 'client_action_relate'
keys = [('action', keyword), ('res_model', res_model)]
value = 'ir.actions.act_window,'+str(id)
- replace = rec.hasAttribute('replace') and rec.getAttribute('replace')
+ replace = rec.hasAttribute('replace') and rec.getAttribute('replace') or True
self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, xml_id, [src_model], value, replace=replace, isobject=True, xml_id=xml_id)
# TODO add remove ir.model.data
return False