Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odgovori
1686 Prikazi

I created a form view and added a button so that when i hit the button i can generate values in the tree view inside the form view.

The values generated must be according to the values entered in the fields of the form view is this possible to do or not.

Thanks in advance




Avatar
Opusti
Best Answer

Hi  houssem salem,


Refer below code for creating records in the One2many field on button click.

def create_terms(self):
self.terms = False
terms_lines = []
terms_ids = self.env['so.terms.config'].search([])
for rec in terms_ids:
values = {
'name': rec.name,
'description': rec.description,
}
terms_lines.append((0, 0, values))
self.terms = terms_lines

terms = fields.One2many('sale.order.terms.conditions', 'order_id', string='Terms and Conditions')


Avatar
Opusti
Avtor

I already have values in the one2many fields so what im asking is that after filling the form view fields i can hit a generate values button that i have created that gives me the ability to retrieve data from other modules and prints that data into the tree view inside the form view .

Best Answer

Hi,

Of course it is doable if you are good in odoo orm. I hope the tree inside form view, refers to a one2many field.


Odoo ORM: https://www.odoo.com/documentation/15.0/developer/reference/backend/orm.html


Thanks & Regards

Avatar
Opusti
Avtor Best Answer

Hi niyas,

yes my tree inside the form view refers to one2many fields but i can't figure out the function that can do the automated generation of the records. Please if you have an exemple to how it is done share it with me.


Thanks


Avatar
Opusti