Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
1679 Widoki

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




Awatar
Odrzuć
Najlepsza odpowiedź

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')


Awatar
Odrzuć
Autor

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 .

Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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


Awatar
Odrzuć