コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
2427 ビュー

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?

アバター
破棄
著作者 最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
3
7月 25
2093
5
5月 25
9590
1
4月 25
1570
0
10月 24
1279
2
5月 24
4112