Skip to Content
Menu
This question has been flagged

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)


Avatar
Discard
Related Posts Replies Views Activity
0
Dec 18
13
1
May 16
3428
0
Dec 24
32
1
Sep 23
5005
1
Aug 22
6317