我正在尝试修改现有视图,并向树中添加一列。
视图的模型是
stock.picking
,树视图的模型为
stock.move
.
我试图添加的字段只应在满足特定条件时显示。也就是说,如果
股票采摘
有吗
sale_id
设置,然后我想在树中显示我的字段(列)。
以下是为简洁而编辑的代码:
<form string="Transfer">
....
<field name="move_ids_without_package" mode="tree,kanban" attrs="{'readonly': ['&', ('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'default_company_id': company_id, 'picking_type_code': picking_type_code, 'default_picking_id': id, 'form_view_ref':'stock.view_move_form', 'address_in_id': partner_id, 'default_picking_type_id': picking_type_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
<tree decoration-danger="not parent.immediate_transfer and state != 'done' and quantity_done > reserved_availability and show_reserved_availability" decoration-muted="scrapped == True or state == 'cancel' or (state == 'done' and is_locked == True)" string="Stock Moves" editable="bottom">
....
**MY CONDITIONAL FIELD GOES HERE***
在我看来,我继承并修改了上述内容:
<field name="arch" type="xml">
<xpath expr="(//field[@name='product_id'])[1]" position="before">
<field name="sale_id"/>
<field name="co7_so_line_number" readonly="1" attrs="{'invisible': [('sale_id', '=', False)]}"/>
</xpath>
</field>
这不管用。我认为问题在于树视图的“上下文”是
股票移动
而且
销售标识
这是一个研究领域
股票采摘
.如何访问“外部”模型(
股票采摘
)在树状视图中(当然不编辑父视图)?