跳至內容
選單
此問題已被標幟
1 回覆
2820 瀏覽次數

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
2409
5
7月 25
7679
1
2月 24
3660
1
4月 24
2056
0
1月 24
1226