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

Hello,

I have 3 models.

Model_a.py:

fila = fields.one2many('model.c', 'keya')

kn_b = fields.many2one('model.b')


Model_b.py:

filb = fields.one2many('model.c', 'keyb')

reference = fields.Char('Reference')

date = fields.Date('Date')


Model_c.py:

filcb = fields.many2one('model.b')


I will create records in model b. In this model b, there is a button is there. On clicking on that button I need to copy all values (all records) of filb field to fila field of model a .

I'd tried with this code:

def accept(self):

for record in self:

            filb_values = [(0, 0, {'reference': line.reference, 'date': line.date}) for line in record.filb]

            vals = {'fila': filb_values}

self.env["model.a"].write(vals)

return True


After click a button 'Accept'. It still not show all records ( in tree view notebook of model b) in one2many tree view notebook of model a.


Please help!

Thank you!



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

Finally, I'd solved my issue. Just add the line like this:

.....

filab = self.env["model.a"].search([])

filab = filab.write(vals)

return True


And it works fine after clicking the button: 'accept'.

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
февр. 21
3533
1
апр. 25
3951
0
янв. 21
3009
3
мар. 21
5271
1
мар. 21
18896