Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
2423 Näkymät

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
Hylkää
Tekijä Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
3
heinäk. 25
2089
5
toukok. 25
9587
1
huhtik. 25
1570
0
lokak. 24
1278
2
toukok. 24
4111