Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
9054 Переглядів

Hello guys, does somebody know what this error means?

I'm trying to generate the value of a new field from the creation date of a crm.lead object.

My field's name is "x_codigo_oportunidad" and I just need to save a string of the current date in "YYYY-MM" format, because then I will generate an identifier for the lead.

So, this is the code that I typed on Compute field on odoo GUI when creating a new field:

from datetime import datetime
for record in self:
  date_aux= datetime.now()
  record[('x_codigo_oportunidad')] = str(date_aux.date().year) + '-' + str(date_aux.date().month).zfill(2)

But then, when I try to save the field, it gives me this:

File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\safe_eval.py", line 187, in assert_valid_codeobj
    raise ValueError("forbidden opcode(s) in %r: %s" % (expr, ', '.join(opname[x] for x in codes)))
ValueError: forbidden opcode(s) in "from datetime import datetime\nfor record in self:\n  date_aux= datetime.now()\n  record[('x_codigo_oportunidad')] = str(date_aux.date().year) + '-' + str(date_aux.date().month).zfill(2)": IMPORT_NAME, IMPORT_FROM

I don't really know what I am doing wrong. 

I hope you guys can help me because I've been two days stucked on it.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
жовт. 24
49
2
груд. 22
7363
0
черв. 20
3438
1
черв. 19
4200
1
бер. 25
868