콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2979 화면

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


아바타
취소
베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
0
1월 24
2527
5
7월 25
7865
1
2월 24
3831
1
4월 24
2201
0
1월 24
1320