我正在使用odoo 8,我想知道如何在视图中添加一个包含产品列表和其数量的页面,以在干预请求中提及我们将要修改的产品。这样,我们可以估算每次干预的费用
view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_intervention_form" model="ir.ui.view">
<field name="name">cmms.intervention.form</field>
<field name="model">cmms.intervention</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Intervention request" version="7.0">
<header>
<button name="action_broadcast" type="object" string="Déffuser mail" icon="STOCK_REDO"/>
<button name="action_done" states="draft" string="Valider" type="object" icon="gtk-apply"/>
<button name="action_cancel" states="done," string="Annuler" type="object" icon="gtk-cancel"/>
<button name="action_draft" states="cancel" string="Remettre en brouillon" type="object" icon="terp-stock_effects-object-colorize"/>
<field name="state" widget="statusbar" />
</header>
<sheet>
<group>
<group>
<field name="name" select="1" />
<field name="user_id" select="1" colspan="1" />
<field name="user2_id" />
<field name="priority" />
<field name="state_machine" />
<field name="product_id"/>
</group>
<group>
<field name="type" select="1" colspan="1" />
<field name="equipment_id" select="1" colspan="1" />
<field name="date_inter" />
<field name="date_end" />
</group>
</group>
<newline />
<notebook colspan="1">
<page string="Motif d'intervention">
<field name="motif" />
</page>
<page string="Observation">
<field name="observation" />
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
</data>
</openerp>
答案 0 :(得分:1)
您应该在页面上添加一个字段One2many,然后定义树状视图,类似于:
<field name="fieldOne2many">
<tree editable="bottom">
<field name="product_id"/>
<field name="quantity"/>
</tree>
</field>
但是首先,您必须在models.py中定义它,并创建与one2many相关的类,其中包含 quantity 和 product_id 。
致谢。