Is there a way to select and delete particular rows from a many2many tree view, Any idea how to achieve it?
Thanks for the help in advance.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Is there a way to select and delete particular rows from a many2many tree view, Any idea how to achieve it?
Thanks for the help in advance.
Hi Abdul Azeez,
Below is a code for one2many field where I have created a checkbox in the models for the line items. The row should be editable so I have tree editable="top". I have added a button named "Select Lines" in the page which is used to perform action on the selected rows.
string="Lines" name="related_line_ids">
name="sample_line_ids">
editable="top">
name="checkbox"/>
name="name"/>
name="value"/>
On button click the below function is called.
def add_selected_lines(self):
for line in self.sample_line_ids:
if line.checkbox:
self.write({"sample_selected_line_ids":[(0,0,{"name":line.name, "value":line.value})]})
line.checkbox = False
return
You could modify the method to unlink line for your requirement.
Hope this reference helps your problem.
Regards
Joebert
Don't know why, the xml code either disappears or the tags are getting removed.
<page string="Lines" name="related_line_ids">
<button name="add_selected_lines" string="Select Lines" type="object"/>
<field name="sample_line_ids">
<tree editable="top">
<field name="checkbox"/>
<field name="name"/>
<field name="value"/>
</tree>
</field>
</page>
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
2
sie 20
|
10625 | ||
Sort widget="many2many_checkboxes" items
Rozwiązane
|
|
1
maj 19
|
9593 | |
|
2
wrz 17
|
9831 | ||
|
1
mar 15
|
11502 | ||
|
1
lut 24
|
1870 |
Can you give an example, what menu you want to delete its data?
models.py:
web_portal_ids = fields.Many2many('web.portals', string="Web Portals", tracking=True)
xml:
<group string="Web Portals">
<field name="web_portal_ids">
<tree>
<field name="name"/>
<field name="image" widget="image"/>
</tree>
</field>
</group>
I need a check box field along with the tree to select and delete the selected rows from it.
Thanks.
I have tried to create a boolean field inside the model to perform some action, but the check box in view is not editable. I don't know why.