信息库
The information repository is a semantics tree in which the datas that are not the ressources are stocked. We find in this structure:
预设的值
有条件的值;
州(省)取决于邮编,
付款方法取决于伙伴,
事件客户端的反应动作;
滑鼠在请款单菜单上单击,
打印一份请款单,
对一个伙伴的动作, …
信息库(IR)有 3 个物件方法;
在语义树里增加值
在语义树里删除值
在一个选定表单里取得所有值
设定数值
The ir_set tag allows you to insert new values in the “Information Repository”. This tag must contain several field tags with name and eval attributes.
这些属性是依据存取信息库的方法定义的;我们必须在提供标签时设置以下属性:keys, args, name, value, isobject, replace, meta, 和其他一些可选的属性。
范例:
<ir_set>
<field name="keys" eval="[('action','client_print_multi'),('res_model','account.invoice')]"/>
<field name="args" eval="[]"/>
<field name="name">Print Invoices</field>
<field name="value" eval="'ir.actions.report.xml,'+str(l0)"/>
<field name="isobject" eval="True"/>
<field name="replace" eval="False"/>
</ir_set>
信息库物件方法
def ir_set(cr, uid, key, key2, name, models, value, replace=True, isobject=False, meta=None)
def ir_get(cr, uid, key, key2, models, meta=False, context={}, res_id_req=False)
def ir_del(cr, uid, id):
Description of the fields: | |
---|---|
| |
Using ir_set and ir_get: | |
...
res = ir.ir_set(cr, uid, key, key2, name, models, value, replace, isobject, meta)
...
...
if not report.menu_id:
ir.ir_set(cr, uid, 'action', 'client_print_multi', name, [(model, False)], action, False, True)
else:
ir.ir_set(cr, uid, 'action', 'tree_but_open', 'Menuitem', [('ir.ui.menu', int(m_id))], action, False, True)
...
...
res = ir.ir_get(cr, uid, [('default', self._name), ('field', False)], [('user_id',str(uid))])
...
account_payable = ir.ir_get(cr, uid, [('meta','res.partner'), ('name','account.payable')], opt)[0][2]
...