Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
9026 Представления

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
7326
0
июн. 20
3420
1
июн. 19
4184
1
мар. 25
850