This question has been flagged
3 Replies
2419 Views

Hi !

In Odoo 13 I have added a button to each sales order line to "deliver" the service sold (it writes 1 to qty_delivered field).

The problem is that each time I press this button, the form reloads after the modification, so in sale orders that have a lot of lines, each time I press this button, I spend a lot of time scrolling down to find the next line to deliver.

Is there a way to prevent the refresh/reload of the form so I stay on the line where I press the button ?

Thank you !

Ernesto.




Avatar
Discard
Author

Hi Sudhir, did you had the chance to review the code I have posted ?

Thank you !

Author

Hi all !

I am blocked here, I have tried the following with no success, the form keeps reloading and going all the way up:

Removing "for line in self"

Changing

self.update({'qty_delivered' : self.product_uom_qty})

To

self.write({'qty_delivered' : self.product_uom_qty})

Changing

self.update({'qty_delivered' : self.product_uom_qty})

To

line['qty_delivered'] : self.product_uom_qty

Please help me !

Thank you !

Author Best Answer

Hello Sudhir, here's the code of the button ("realise" and "date_envoi_raport" are customs fields):


    def raport_envoye(self):
        for line in self:
            if line.realise:
                if line.qty_delivered != line.product_uom_qty:
                    self.update({'qty_delivered' : self.product_uom_qty})
                    if not self.date_envoi_raport:
                     self.update({'date_envoi_raport':fields.Date.today()})
            else:
                a = self.name
                d = a.encode('utf-8')
                raise exceptions.Warning(u'ATTENTION: La prestation ' + d.decode('utf-8') + u" n'est pas encore réalisée !")
Thank you !

Ernesto

Avatar
Discard