【问题标题】:How to avoid showing fields in a customized form in OpenERP7?如何避免在 OpenERP 7 中以自定义形式显示字段?
【发布时间】:2014-10-21 11:29:08
【问题描述】:

我正在使用 OpenERP7,并且我在表单中创建了一个字段。该字段是下一个:

'history': fields.function(_get_history, type='many2many',
                           obj="res.partner.link.category",
                           method=True, string='Categories'),

然后,我在表格中显示它。由于该字段是 many2many,因此它显示为树,我在下面指定。

<group string="Activity Summary">
    <field name="history" nolabel="1" attrs="{'readonly': 1}">
        <tree string="Categories">
            <field name="active_category" attrs="{'readonly': 1}"/>
            <field name="link_category_id" attrs="{'readonly': 1}"/>
            <field name="type" attrs="{'readonly': 1}"/>
            <field name="date" attrs="{'readonly': 1}"/>
            <field name="observations"/>
            <button name="open_history" type="object" string="View history" icon="terp-calendar"/>
        </tree>
    </field>
</group>

一切正常,但是,如果我单击其中一条记录,它会在弹出窗口中作为表单打开,并且显示一些我不想要的字段。例如,“res.partner.link.category”的对象具有属性 partner_id,我不想显示它。所以我没有把它写在树里面(这很好用),但我对表单做了同样的事情,这个显示了“res.partner.link.category”的每个属性。这里是我为显示我想要的表单所做的修改后的代码:

<group string="Activity Summary">
    <field name="history" nolabel="1" attrs="{'readonly': 1}">
        <tree string="Categories">
            <field name="active_category" attrs="{'readonly': 1}"/>
            <field name="link_category_id" attrs="{'readonly': 1}"/>
            <field name="type" attrs="{'readonly': 1}"/>
            <field name="date" attrs="{'readonly': 1}"/>
            <field name="observations"/>
            <button name="open_history" type="object" string="View history" icon="terp-calendar"/>
        </tree>
        <form string="Categories" version="7.0">
            <sheet>
                <group col="4">
                    <field name="active_category"/>
                    <field name="link_category_id" options="{'no_open': True}"/>
                    <field name="type"/>
                    <field name="partner_id" attrs="{'invisible': True}"/>
                </group>
                <group col="4">
                    <field name="date"/>
                    <field name="observations"/>
                </group>
            </sheet>
        </form>
    </field>
</group>

我做错了什么?有什么办法可以解决吗?

【问题讨论】:

  • 您想隐藏many2many 视图的一些字段/列?在many2many 默认显示在列表/树视图中定义的所有列。
  • 例如,我不能在树中显示 6 列,在表单中显示 3 列,可以吗?

标签: python xml view openerp openerp-7


【解决方案1】:

你必须继承它并用历史替换它

试试这个,

<record id="form_id" model="ir.ui.view">
            <field name="name">model.form</field>
            <field name="model">model</field>
            <field name="inherit_id" ref="module_to_inherit.view id"/>
            <field name="arch" type="xml">
                <field name="partner_id" position="replace">
                    <field name="history"/>
                </field>
            </field>
</record>

【讨论】:

    猜你喜欢
    • 2011-04-14
    • 2018-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-11
    • 2011-09-05
    • 2014-04-17
    • 1970-01-01
    相关资源
    最近更新 更多