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

Hi,

I have a field "X" for which i have written a def to make it to all caps and then save it to db, but the problem is that it doesn't work when i import a file. The function is as below

@api.onchange('name')
def set_account_group_caps(self):
if self.name:
self.name = str(self.name).upper()

Does anyone know how to achieve this even for when importing a file?

Avatar
Verwerfen
Autor Beste Antwort

Hi,

I achieved this by overriding the do method in base_import.py and a simple update statement inside the method does the magic.

@api.multi
def do(self, fields, columns, options, dryrun=False):
res = super(<class-name-here>, self).do(fields=fields, columns=columns, options=options, dryrun=dryrun)
self.env.cr.execute("UPDATE account_group SET name = UPPER(name)")
return res

Thank you

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
3
Juli 25
2091
5
Mai 25
9587
1
Apr. 25
1570
0
Okt. 24
1279
2
Mai 24
4111