Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
3684 มุมมอง

In a demo instance previous to production release, I created an automated action to avoid VAT duplication and got a message where Warning is not recognized in the execution phase!!! There is no message of a syntaxis error. Next the code:


if record.vat:
   contact = env ['res.partner'].search([['vat','=',record.vat]])
   if contact:
     for c in contact:
         if c.id != record.id:
            raise Warning ('VAT is duplicated, change it pls')


Any idea to solve this problem? This was working properly before the last version update

อวตาร
ละทิ้ง
ผู้เขียน

It worked!!! Thank you very very very very much!!!

what would be the code to avoid creating contact with same email?

คำตอบที่ดีที่สุด

Hi,

Instead of Warning, use UserError and  see.


# - UserError: exception class for raising user-facing warning messages


Thanks 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

UserError blocks the execution. Is there a function to just show a warning, but not stop execution?

อวตาร
ละทิ้ง

Hi Trond, I have the same issue, got a solution please ?

Same question here.
All xxxError block the execution.
I need a warning only and the execution of the current process to be finished.
Looking forward to see any feedback

Hi Höppner and Mohammed.
Sorry, no, never found an alternative to UserError.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.พ. 24
949
1
ม.ค. 23
2000
1
พ.ย. 23
2160
3
ต.ค. 23
2882
2
ธ.ค. 23
5779