Skip to Content
Menú
This question has been flagged
2 Respostes
2577 Vistes

Hello.

I am trying to create an automated action that will prevent the creation of the Sales order if there is no contact selected as Customer.

Example:

Company Ltd. --> Not allowed

Company Ltd., Name Username --> Allowed

I tried with an Automated action on creation and a Python code:

x = env['sale.order'].partner_id.parent_id
 if x == false:
    raise Warning("CONTACT IS MISSING")

But it doesn't work, x is always "false". Any suggestions?


Thank you so much!

Nejc

Avatar
Descartar
Best Answer
if not record.partner_id.parent_id:
  Warning('CONTACT IS MISSING')


Avatar
Descartar
Best Answer

Hi,

Try this code and see,

x = rec.partner_id.parent_id
if not x:
    raise Warning("CONTACT IS MISSING")


Thanks

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de nov. 22
6293
0
de gen. 21
2247
1
de nov. 22
3442
3
de febr. 25
1623
1
de des. 24
1826