i用一个按钮打开我的树形视图,但是问题是它没有编辑选项或保存就打开了。我希望可以更改价格和数量并保存
@api.multi
def button_details(self):
context = self.env.context.copy()
context['view_buttons'] = True
view_id = self.env.ref('cfg.view_order_line_form_view').id
view = {
'name': _('Details'),
'view_type': 'form',
'view_mode': 'tree, form',
'res_model': 'sale.order.line',
'views' : [(view_id,'tree')],
'type': 'ir.actions.act_window',
'target': 'new',
'readonly': True,
'res_id': self.id,
'context': context
}
return view
<record id="view_order_line_form_view" model="ir.ui.view">
<field name="name">sale.order.line.forma</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<tree string="Form" editable="bottom">
<field name="product_id" />
<field name="product_uom_qty" string="Qty" placeholder="Qty"/>
<field name="price_unit" string="Price"/>
</tree>
</field>
</record>
用picutre更新了我的问题 。这是我的树状视图,但我想删除产品或更改数量
答案 0 :(得分:1)
在python代码中添加“标志”,并在xml代码中删除=“ true”。在顶部,您会看到一个名为“更多”的下拉菜单,单击它会显示删除选项。
@api.multi
def button_details(self):
context = self.env.context.copy()
context['view_buttons'] = True
view_id = self.env.ref('cfg.view_order_line_form_view').id
view = {
'name': _('Details'),
'view_type': 'form',
'view_mode': 'tree, form',
'res_model': 'sale.order.line',
'views' : [(view_id,'tree')],
'type': 'ir.actions.act_window',
'target': 'new',
'readonly': True,
'res_id': self.id,
'flags': {'sidebar': True},
'context': context
}
return view
<record id="view_order_line_form_view" model="ir.ui.view">
<field name="name">sale.order.line.forma</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<tree string="Form" editable="bottom" delete="true">
<field name="product_id" />
<field name="product_uom_qty" string="Qty" placeholder="Qty"/>
<field name="price_unit" string="Price"/>
</tree>
</field>
</record>