تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
910 أدوات العرض

I have inheritted survey_user_input and added 

lead_id = fields.Many2one(comodel_name='crm.lead', string='Crm Lead') 

and i wanted to show this in the smart  button 

<button name="action_open_documents"
class="oe_right_oe_button_box"
icon="fa-star"
string="Lead"
type="object"
invisible="not lead_id" >

</button>

the method is :

def action_open_lead(self):
return {
'type': 'ir.actions.act_window',
'name': 'Lead',
'res_model': 'crm.lead',
'view_mode': 'form',
'res_id': self.lead_id.id,
'context': {'create': False}
}


the xpath is correct because the other  buttons which i have  creaqted in  this model  works but for this i get :

Field 'lead_id' used in modifier 'invisible' (not lead_id) is restricted to the group(s) base.group_no_one.


View error context:

{'file': '/home/guhan/odoo/opt/odoo-servicum-addons/servicum_fillout_integration/views/survey_user_input_inherit.xml',

'line': 1,

'name': 'survey.user.input.view.form.inherit',

'view': ir.ui.view(772,),

'view.model': 'survey.user_input',

'view.parent': ir.ui.view(560,),

'xmlid': 'survey_user_input_view_form_inherit'}


i  get  the error only when 

invisible="not lead_id" 

is present.i have no groups set up in the field definition. the lead_id many2one alone works , but  it throws an error in  the button . any help would  be appreciated. Thanks 

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

The error occurs because you're using invisible="not lead_id" on the button, but lead_id is not available in the form view's XML. Odoo needs the field to be present in the view to apply modifiers like invisible. To fix this, simply add <field name="lead_id" invisible="1"/> somewhere in the form view to make it available for evaluation.

Also, double-check your button’s name attribute—you're calling action_open_documents, but your method is named action_open_lead. Update it to match: <button name="action_open_lead" ... />. That should solve both the visibility and function issues.


Hope it helps

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
نوفمبر 19
3170
4
يونيو 22
6440
2
مايو 24
2121
0
أبريل 24
30
3
أبريل 23
11588