Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3366 Lượt xem

Hello,

I'm using Odoo10. I'm trying to make a new tree view and add a button. When I click on this button I'd like to open a view.
But I have an error and I can't find any answer in the manual or on line.

Here is the piece of code that generate the error :

<record model="ir.ui.view" id="mrp_prod_tree_view">
<field name="name">mrp.prod.tree</field>
<field name="model">mrp.bom.line</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Bill of Materials" editable="bottom" version="7.0">
<field name="sequence" invisible="1"/>
<field name="product_id"/>
<field name="product_qty"/>
<button name="open_form" string="Open Form" type="object" icon="fa-pencil" class="oe_highlight"/>
</tree>
</field>
</record>

The python code :

@api.multi
def open_form(self):
print(self.id)
if self.id:
return {
'view_mode': 'form',
'view_type': 'form',
'res_model': 'mrp.production',
'res_id': self.id,
'type': 'ir.actions.act_window',
'target': 'current',
'context': self.env.context
}
else:
return False

The error is :

TypeError: dict.field.attrs.modifiers is undefined
Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I have already look on this topic but this is Qweb, and the solution isn't applicable for me...

Ảnh đại diện
Huỷ bỏ

Your code seems to be fine, there is no issue I can find on it, just remove the line 'target': 'current' and see, whether it can bring solution or not.

Câu trả lời hay nhất

Hi,

You can refer this https://www.odoo.com/forum/help-1/question/treeview-button-error-dict-field-attrs-modifiers-is-undefined-55593

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
7
thg 11 18
23696
2
thg 7 25
4526
2
thg 12 24
7695
2
thg 11 24
28443
2
thg 5 24
7423