Laoris
Laoris

Reputation: 23

Automated Actions in odoo 12. Set values with python code

I tried to take text from one field and set it modificated to another throught Execute Python Code.

recs = record.smt
for rec in recs:
    details = pythonwhois.get_whois(rec)
    if 'No match for' in str(details):
        record.smt2='ok'
    else:
        record.smt2='denied'

Error: forbidden opcode

Please, help!

Upvotes: 2

Views: 2131

Answers (1)

arryph
arryph

Reputation: 2825

For the line:

details = pythonwhois.get_whois(rec)

You are using a external library pythonwhois which is not imported, how do you suppose to use that in your execution. As import statement is also not allowed, you can't just import any library.

instead of using dot operator, try to use write function.

    if 'No match for' in str(details):
        smt2='ok'
    else:
        smt2='denied'
record.write({'smt2': smt})

Also keep in mind that record is the record on which the action is triggered; may be void

Upvotes: 2

Related Questions