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

Hello everybody !

I've got a one2many field displayed as a tree in a form view. I'm entering a lot of line in this field and I have to scroll a lot to reach the bottom to click on "Add a new line".

I tried editable=top but it didn't do what I want.

Is there a way to create a button above the tree view that would open the regular o2m form view to add a new line ?

Thanks 

Avatar
Discard
Best Answer

Hello @Alexandre Violleau

I thing on click 'Add a new line' button open wizard.
In wizard take a fields you want and in wizard form view fotter add two buttons 'Create' and 'Cancel'.
On click 'Create' button add new line in 'One2many' field.

Please find code in comment. 

I Hope this will help you. 

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

Avatar
Discard

Example for 'Create' button method to add line:
def create_new_line(self):
sale_order_id = self.env['sale.order'].browse(self._context.get('active_id'))
sale_order_id.order_line = [(0, 0, {
'prouct_id': self.product_id.id,
'name': self.product_id.name
})]

Best Answer

Hi   Alexandre,

I Guess by default there is no option to move the position of 'Add a new line' ,

Limiting records in one2many may help if scrolling is the issue.





Avatar
Discard

<tree string="Rates" editable="bottom" limit="25">