Skip to Content
Menu
This question has been flagged

Hi

I want to show a button at the top of tasks that direct to a view of all tasks that have the same value in their field 'lead_id'.


this is my lead field: 

class project_Task(models.Model):
_inherit = 'project.task'

lead_id = fields.Many2one(comodel_name='crm.lead',
string='Opportunity',
tracking=True,
compute='_compute_lead_id',
readonly=False,
store=True
)


this is my xml:


I see the the button on the tasks (top right) but if i click it I get an error.


I think the issue most likely is in lines 8 and 9 of the xml, can you help me out?


Thanks in advance!

Friedrich


Avatar
Discard
Best Answer

Hi 

Update the XML code as follows update the button of type = object and render the action in the project task model 

   

<xpath expr="//div[@name='button_box']" position="inside">

    <button name="act_lead_action"

            class="oe_stat_button"

            icon="fa-credit-card"

            type="object"

            >

        </button>

    </xpath>


Python code as follows

def act_lead_action(self):
action = {
'type': 'ir.actions.act_window',
'domain': [('id', 'in', self.lead_id.id)],
'view_type': 'form',
'view_mode': 'list,form',
'name': _('Lead'),
'res_model': 'crm.lead',
}
return action


Regards

Avatar
Discard
Related Posts Replies Views Activity
0
Jan 24
1785
5
May 25
6914
1
Feb 24
2787
1
Apr 24
1459
0
Jan 24
750