信息库

The information repository is a semantics tree in which the datas that are not the ressources are stocked. We find in this structure:

  1. 预设的值

  2. 有条件的值;

    • 州(省)取决于邮编,

    • 付款方法取决于伙伴,

  1. 事件客户端的反应动作;

    • 滑鼠在请款单菜单上单击,

    • 打印一份请款单,

    • 对一个伙伴的动作, …

信息库(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, 和其他一些可选的属性。

范例:

  1. <ir_set>
  2. <field name="keys" eval="[('action','client_print_multi'),('res_model','account.invoice')]"/>
  3. <field name="args" eval="[]"/>
  4. <field name="name">Print Invoices</field>
  5. <field name="value" eval="'ir.actions.report.xml,'+str(l0)"/>
  6. <field name="isobject" eval="True"/>
  7. <field name="replace" eval="False"/>
  8. </ir_set>

信息库物件方法

  1. def ir_set(cr, uid, key, key2, name, models, value, replace=True, isobject=False, meta=None)
  1. def ir_get(cr, uid, key, key2, models, meta=False, context={}, res_id_req=False)
  1. def ir_del(cr, uid, id):
Description of the fields:
 
  1. key:

  2. key2:

  3. name:

  4. models):

  5. value:

  6. isobject:

  7. replace: 所描述的动作是否应该覆盖现有的动作, 或是应该被加到现在的动作清单里。

  8. meta:

Using ir_set and ir_get:
 
  1. ...
  2. res = ir.ir_set(cr, uid, key, key2, name, models, value, replace, isobject, meta)
  3. ...
  4. ...
  5. if not report.menu_id:
  6. ir.ir_set(cr, uid, 'action', 'client_print_multi', name, [(model, False)], action, False, True)
  7. else:
  8. ir.ir_set(cr, uid, 'action', 'tree_but_open', 'Menuitem', [('ir.ui.menu', int(m_id))], action, False, True)
  9. ...
  10. ...
  11. res = ir.ir_get(cr, uid, [('default', self._name), ('field', False)], [('user_id',str(uid))])
  12. ...
  13. account_payable = ir.ir_get(cr, uid, [('meta','res.partner'), ('name','account.payable')], opt)[0][2]
  14. ...