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

I wrote the following code to check if stage_id does not have a record, then stage_id.fold = True, where did I go wrong, please help, thanks

@api.onchange('stage_id')
def _onchange_stage_id(self):
res = super(CrmLead, self)._onchange_stage_id()
for r in self.env['crm.stage'].search([]).ids:
if not self.search('stage_id', '=', r.id):
self.r.fold = True
return res
アバター
破棄
著作者

Dương Đường . thank you, but for me it doesn't work, can you sp me me by email? tienentrust@gmail.com

最善の回答

You're looping through IDs list not objects by using:

self.env['crm.stage'].search([]).ids
So this line:
if not self.search([('stage_id', '=', r.id)])
Should be:
if not self.search([('stage_id', '=', r)])
アバター
破棄
著作者 最善の回答

thank you, my statement is probably wrong somewhere:

bug: File "d:\odoo-training\code\takara\takara_crm\models\crm_lead.py", line 22, in _onchange_stage_id

    if not self.search([('stage_id', '=', r.id)]):
AttributeError: 'int' object has no attribute 'id'

アバター
破棄
最善の回答

Hello vu van tien,

You write the wrong syntax of a search method when you check if condition.
Please Update this code.

@api.onchange('stage_id')
def _onchange_stage_id(self):
res = super(CrmLead, self)._onchange_stage_id()
for r in self.env['crm.stage'].search([]).ids:
if not self.search([('stage_id', '=', r.id)]):
self.r.fold = True
return res

Hope this could help ...

アバター
破棄

Thanks for the help, I had to use js to deal with it

関連投稿 返信 ビュー 活動
2
8月 25
1500
0
5月 25
768
0
8月 24
1091
2
3月 24
1354
1
7月 22
2681