Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2424 Переглядів

Hi, I have display problem, on Many2one on Line.

When i have select equipment, i have a condition_out. This one is display in line but if i select another equipment the condition_out doesn't display execpt I reload reccord or save. What's the good methode to display my condition when i pick my equipment ? ( maybe to reload cahce butI can not to succeed)

@api.onchange('equipment_id')
def onchange_condition_out(self):
    self.ensure_one()
    if self.equipment_id:
        print(self.equipment_id.id)
        datas = {}
        last_rental_line_id = self.search([
                                                             ('equipment_id', '=', self.equipment_id.id),
                                                             ('state', '=', 'done')],
                                                             order='id DESC', limit=1)
        if last_rental_line_id:
            datas = {
                            'name' : last_rental_line_id[0].name,
                            'rental_id' : self.rental_id.id,
                            'equipment_id' : last_rental_line_id[0].equipment_id.id,
                            'description' : last_rental_line_id[0].condition_in.description,
                            }
        else:
            datas = {
                            'name' : self.equipment_id.name + "-" + (self.rental_id.name and self.rental_id.name or ""),
                            'rental_id' : self.rental_id.id,
                            'equipment_id' : self.equipment_id.id,
                            'description' : "first location",
                            }

        if self.condition_out:
                self.condition_out.write(datas)
        else:
                self.condition_out = self.env['rental.condition.out'].create(datas)


Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
груд. 18
13
1
трав. 16
4466
1
січ. 25
1273
1
вер. 23
6503
1
серп. 22
7845