Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2852 Lượt xem

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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 1 24
2420
5
thg 7 25
7695
1
thg 2 24
3668
1
thg 4 24
2081
0
thg 1 24
1249