Templating the XML files

+1 to any effort that tries to simplify management of XML files.

About the proposal I wonder how hard it will be to guess the IDs that will be created by such methods. It seems that it could be somewhat harder to find the IDs that ones need to refer to in “inheriting” modules.

Although the proposal is about templating, I’ve also thought in the past about simplifying XMLs. Maybe I’m the only one but I find XMLs somewhat hard to read and write and I’ve lately been used to YAML syntax.

If that was considered there are many ways to establish the structure of such file. One of them could be as follows (a fragment of sale/sale.xml translated into sale/sale.yml):

---
- model: res.group
  group_sale:
    name: Sales
  group_sale_admin:
    name: Sales Administration

- model: res.user-res.group
  user_admin_group_sale:
    user: res.user_admin
    group: group_sale

  user_admin_group_sale_admin:
    user: res.user_admin
    group: group_sale_admin

- model: ir.ui.icon
  sale_icon:
    name: tryton-sale
    path: icons/tryton-sale.svg

- model: ir.ui.view
  sale_view_form:
    model: sale.sale
    type: form
    name: sale_form

  sale_view_tree:
    model: sale.sale
    type: tree
    name: sale_tree

- model: ir.action.act_window
  act_sale_form:
    name: Sales
    res_model: sale.sale
    search_value: ""

- model: ir.action.act_window.view
  act_sale_form_view1:
    sequence: 10
    view: sale_view_tree
    act_window: act_sale_form

  act_sale_form_view2:
    sequence: 20
    view: sale_view_form
    act_window: act_sale_form

- model: ir.action.act_window.domain
  act_sale_form_domain_draft:
    name: Draft
    sequence: 10
    domain:
      eval: [('state', '=', 'draft')]
      pyson: 1
    count:
      eval: True
    act_window: act_sale_form

  act_sale_form_domain_quotation:
    name: Quotation
    sequence: 20
    domain:
      eval: [('state', '=', 'quotation')]
      pyson: 1
    count:
      eval: True
    act_window: act_sale_form

  act_sale_form_domain_processing:
    name: Processing
    sequence: 40
    domain:
      eval: [('state', '=', 'processing')]
      pyson: 1
    count:
      eval: True
    act_window: act_sale_form

  act_sale_form_domain_all:
    name: All
    sequence: 9999
    domain: ""
    act_window: act_sale_form

This makes several assumptions such as:

  • It takes advantage of the fact that many consecutive records are from the same model
  • Assumes that most of the time m2o fields use a “ref=xxx” where xxx is the ID of the related record

Of course there could be other ways of structuring it, such as:

group_sale:
  model: res.group
  fields:
    name: Sales

group_sale_admin:
  model: res.group

I understand that because of the use of SAX, XML may consume less memory, and maybe others already feel comfortable with XML, but just wanted to put another option on the table.