Skip to Content
Menu
This question has been flagged
2 Replies
10016 Views

I want to have a tree view within my form that is editable="bottom" because this option enables a really quick way to add and edit the corresponding models but that also has a clickable link to the model. I have demonstrated it in this image :

As you can see I added the arrows on the right with photoshop to show you what I need. Clicking on the arrow should open the form view of that model, just like it does normally.

How can I add such an arrow to the tree view or achieve something similar?


This is what the tree view currently looks like

```

<page string="Stände">
<field name="staende">
<tree editable="bottom">
<field name="draw"/>
<
field name="name" />
<
field name="aussteller"/>
<
field name="start_number" />
<
field name="end_number" />
<
field name="type" />
<
field name="depth" />
<
field name="walls" />
<
field name="carpet"/>
tree>
field>page>

```

Avatar
Discard
Best Answer

Hello Josef Schmid,

Please find Code in Comment. 

hope may this helpful for you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard

Add the attribute in tree tag like below:
<tree editable="top" create="1" edit="1">

Author

Thank you for your answer. I edited the tree tag to look like this:

<tree editable="bottom" create="1" edit="1">
<field name="draw"/>
<field name="name" />
<field name="aussteller"/>
<field name="start_number" />
<field name="end_number" />
<field name="type" />
<field name="depth" />
<field name="walls" />
<field name="carpet"/>
</tree>

(I also tried editable="top")

Unfortunately, the tree still looks like this and I have no way of opening the model in the form view.

https://i.imgur.com/3WQFUkf.png

Best Answer

Hi, you can add a (object) button after your last field in tree tags.

<button class="oe_stat_button"
icon="fa-pencil-square-o"
name="open_budget_form_view"
type="object"/>


name attribute is should be name of the action function at behind.



Avatar
Discard
Author

Hey, I dont quite understand, where to put to button and what the function has to look like. Can you help by explaining it a bit further?

From what I understand, it looks like you want me to put the button here

<tree editable="bottom" create="1" edit="1">
<field name="draw"/>
<field name="name" />
<field name="aussteller"/>
<field name="start_number" />
<field name="end_number" />
<field name="type" />
<field name="depth" />
<field name="walls" />
<field name="carpet"/>
<button class="oe_stat_button"
icon="fa-pencil-square-o"
name="open_form_view_from_that_model"
type="object"/>
</tree>

Hover I do not know how to write a method or action that opens that form. Would you mind helping?

Thank you very much.

With pleasure,

Here is complete sample:

My tree view's model is "project.budget.item" and i should write my button's action function in this model but firstly let's add our button to view:

<record id="project_budget_tree" model="ir.ui.view">
<field name="name">project.budget.tree</field>
<field name="model">project.budget.item</field>
<field name="arch" type="xml">
<tree editable="bottom" create="1" edit="1">
<field name="sequence"/>
<field name="name" />
<field name="date"/>
<button class="oe_stat_button"
icon="fa-pencil-square-o"
name="open_budget_form_view"
type="object" />
</tree>
</field>
</record>

Now it's time to write a action function to call it from button:

class ProjectBudgetItem(models.Model):
_name = "project.budget.item"

#I should write this function name to my button's name attribute in tree view
def open_budget_form_view(self):
return {
'name': 'Budget Edit',
'domain': [],
'res_model': 'project.budget.item',
'type': 'ir.actions.act_window',
'view_mode': 'form',
'view_type': 'form',
'res_id': self.id,
'target': 'new',
}

or you should write something like this:

def action_account_bank_statement(self):
self.ensure_one()
action = self.env.ref('account_cheque.action_account_bank_statement').read()[0]
action['context'] = {'default_account_cheque_transaction_id': self.id}
return action

if i understood your question correctly the above example will give you what you want.

Thanks.

Related Posts Replies Views Activity
1
May 24
764
1
Sep 22
2360
1
Aug 22
1465
2
Aug 22
3949
1
Jul 22
2854