OpenERP建模/视图:相关对象内联 [英] OpenERP modeling / views: related object inline

查看:181
本文介绍了OpenERP建模/视图:相关对象内联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了内置的OpenERP 6.1模块crm。

因此,我现在已经在销售 - >机会中显示res.lead活动并可见。



我想编辑此对象/视图以显示合作伙伴的帐单地址。



因为我想在Opporunities窗体上执行此操作,已经有了一个partner_id。

复制另一个模块,我定义了我的新模块,如下所示:

  class crm_lead(osv.osv):
_name = _inherit ='crm.lead'
_columns = {
'billing_address_id' :fields.many2one('res.partner.address','Partner Billing Address',domain =[('partner_id','=',partner_id),('type','in',''invoice','默认'])]),
}

我将update_xml更改为:

 < record model =ir.ui.viewid =crm_case_form_view_oppor> 
< field name =name>商机表单(继承)< / field>
< field name =model> crm.lead< / field>
< field name =inherit_idref =crm.crm_case_form_view_oppor/>
< field name =archtype =xml>
< data>
< separator string =Detailsposition =replace/>
< field name =descriptionposition =replace>
< group colspan =2col =4>
< separator colspan =4string =Billing/>
< field widget =one2many_listmode =form,treename =billing_address_idcolspan =4nolabel =1/>
< / group>
< group colspan =2col =4>
< separator colspan =4string =Details/>
< field name =descriptionnolabel =1colspan =4/>
< / group>
< / field>
< / data>
< / field>
< / record>

问题在于相关对象显示所有相关字段(正如我猜想的那样) )。特别是,它显示了partner_id和company字段,我想隐藏它们,因为它们应该默认/从这个机会继承(或链接的合作伙伴)。



我怎样才能隐藏这些字段?我不能简单地添加一堆相关字段,因为可能有多个帐单地址。



感谢您的帮助!






编辑:为了更清楚一点,一个机会应该只有一个选择的帐单地址,从合作伙伴的发票/默认地址中选择。它应该以内联方式显示,以便于编辑。

为此类相关字段指定视图。您可以像这样使用上下文:

 < field 
name =order_line
colspan = 4
nolabel =1
context ={'form_view_ref':'module.view_id','tree_view_ref':'model.view_id'}/>

您也可以将子记录的整个视图指定为子视图,如下所示:

 <! - < === order_line是one2many字段 - > 
< field name =order_linecolspan =4nolabel =1>
< form>
< field name =qty/>
...
< / form>
< tree>
< field name =qty/>
...
< / tree>
< / field>


I have installed the built in OpenERP 6.1 module crm.

As a result, I now have res.lead active and visible at "Sales->Opportunities".

I'd like to edit this object / view to show the partner's billing address.

Since I want to do this on the Opporunities form, there is already a partner_id.

Copying another module, I defined my new module like this:

class crm_lead(osv.osv):
    _name = _inherit = 'crm.lead'
    _columns = {
    'billing_address_id': fields.many2one('res.partner.address', 'Partner Billing Address', domain="[('partner_id','=',partner_id),('type','in',['invoice', 'default'])]"),
    }

And I changed my update_xml to:

    <record model="ir.ui.view" id="crm_case_form_view_oppor">
        <field name="name">Opportunity form (inherit)</field>
        <field name="model">crm.lead</field>
        <field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
        <field name="arch" type="xml">
            <data>
                <separator string="Details" position="replace" />
                <field name="description" position="replace">
                    <group colspan="2" col="4">
                        <separator colspan="4" string="Billing" />
                        <field widget="one2many_list" mode="form,tree" name="billing_address_id" colspan="4" nolabel="1" />
                    </group>
                    <group colspan="2" col="4">
                        <separator colspan="4" string="Details" />
                        <field name="description" nolabel="1" colspan="4" />
                    </group>
                </field>
            </data>
        </field>
    </record>

The problem is that the related object shows all the related fields (as I'd guess would be expected). In particular, it shows the partner_id and company fields, which I'd like to hide since they should default to / inherit from this opportunity (or the linked partner).

How can I hide these fields? I can't simply add a bunch of 'related' fields, as there is potentially more than one billing address.

Thanks for the help!


Edit: To be clearer, an opportunity should only have a single chosen billing address, chosen from the partner's invoice / default addresses. It should be displayed inline to allow easy editing.

解决方案

There are a couple of ways to specify the view for related fields like this. You can use the context like this:

<field 
    name="order_line" 
    colspan="4" 
    nolabel="1"
    context="{'form_view_ref': 'module.view_id', 'tree_view_ref': 'model.view_id'}"/>

You can also specify the whole view for the child record as a subview within the parent view like this:

    <!-- <=== order_line is a one2many field -->
    <field name="order_line" colspan="4" nolabel="1">
        <form>
            <field name="qty"/>
            ...
        </form>
        <tree>
            <field name="qty"/>
            ...
        </tree>
    </field>

这篇关于OpenERP建模/视图:相关对象内联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆