Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
5013 Представления

class checked_criteria(models.Model):

_name="checked.criteria" 

soft=fields.Many2many('softandgrid','rel1','a','b',string="Soft Duplicates Fields")

When I run select * from rel1; in terminal, there are datas in a and b columns.

How can I get these data?Thank you.

Аватар
Отменить
Лучший ответ

self.env.cr.execute( " Your Request here")

 result = self._cr.fetchall()

 if result:

      # Result is your datas you get from your sql request. then you define  what you want to do with it within a loop

Аватар
Отменить
Лучший ответ

When you write a many2many field a new table is created in the database which stores the id of the two tables. In your example, the new table created is rel1 and a will be the id of the record from table checked_criteria and b will be the id of the record from softandgrid.

For understanding the concept, the naming can be done as follows:

soft_grid_ids = fields.Many2many('softandgrid', 'criteria_softgrid_rel', 'criteria_id', 'softgrid_id', string='Soft Duplicates Fields')


Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
июл. 24
2734
1
июн. 24
5189
1
окт. 23
10922
1
окт. 23
98
1
авг. 23
2194