Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
1669 Lượt xem

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




Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Tác giả

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 .

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ