0

When click "add a line" button on sale.order.line as example, i want to show a warning message, but then still lets a new line show up, how it that possible? enter image description here

In odoo 15 by default, this is not possible, i've try this but not working.

Please help, thanks.

@api.onchange('product_id')
    def onchange_product_id(self):
        // my code
        return {
                    'warning': {'title': ('Warning'), 'message': ('my message'), },
                }
fudu
  • 617
  • 1
  • 10
  • 19
  • Can you clarify your question? What is happening at the moment and what is it you want? To me it's not clear if at the moment if you have a warning AND a new line (but don't want the new line) or if you only get a warning but also want a new line. – Jasper Apr 18 '22 at 10:50
  • sorry for misunderstanding, i mean that by default, when i raise a warning, it won't show a new line, and i want it to raise a warning but also show the new line. – fudu Apr 18 '22 at 11:18
  • For me your code works: it shows a message AND adds the selected record. Are you sure you're looking at the right place? You code says 'product_id' but your screenshot seems to show something like 'job_ids'. Or maybe something is going wrong in the `// my code` part? – Jasper Apr 18 '22 at 11:20
  • @Jasper oh yes thanks you, this code is copy from my company project so i can't copy all of it, also i take a picture from odoo 15 default which is my training odoo site, so the picture and the code is not match. – fudu Apr 19 '22 at 01:55
  • @Jasper sir, do you have in mind any idea that can show a warning message but can still lets "add a line" function work as normal? except the code above. – fudu Apr 19 '22 at 02:22
  • The easiest way to get help is always to create a 'minimal reproducible example' (see https://stackoverflow.com/help/minimal-reproducible-example), which other users can use to test your approach. – Jasper Apr 19 '22 at 10:52

0 Answers0