Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet

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.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Okt. 24
49
2
Dez. 22
7423
0
Juni 20
3463
1
Juni 19
4213
1
März 25
880