当我从 java 脚本代码调用 do_action 方法时,我没有获得操作 ID。因此,当我刷新或重新加载页面时,我的表单是空白的。我正在使用 Odoo 11。
action_timesheet_user: function(event) {
var self = this;
event.stopPropagation();
event.preventDefault();
alert(self.employee_data.timesheet_action);
if (self.employee_data.uid == 1){
this.do_action({
name: _t("Timesheets"),
type: 'ir.actions.act_window',
res_model: 'account.analytic.line',
view_mode: 'tree,form',
view_type: 'form',
views: [[false, 'list'],[false, 'form']],
context: {
//'search_default_employee_id': [self.employee_data.id],
'search_default_month': true,
},
target: 'current'
})}
else {
this.do_action({
name: _t("Timesheets"),
type: 'ir.actions.act_window',
res_model: 'account.analytic.line',
view_mode: 'tree,form',
view_type: 'form',
views: [[false, 'list'],[false, 'form']],
context: {
//'search_default_employee_id': [self.employee_data.uid],
'search_default_month': true,
},
domain: ['|','|',['user_id', '=', self.employee_data.uid],
['employee_id.department_id.manager_id.user_id', '=', self.employee_data.uid],
['project_id.user_id','in',[self.employee_data.uid]]],
target: 'current'
},{on_reverse_breadcrumb: function(){ return self.reload();}})}
},
events: _.extend({}, Widget.prototype.events, {'click .custom_helpdesk_tickets': 'action_custom_helpdesk_tickets'}),
Xml 模板:
<div><a class="btn btn-primary btn-block custom_helpdesk_tickets" role="button"><strong>Helpdesk</strong></a></div>
在模板按钮上调用此函数后,我得到:
http://localhost:8069/web?#view_type=list&model=account.analytic.line
要求:
http://localhost:8069/web?debug#view_type=list&model=account.analytic.line&menu_id=458&action=487
提前致谢。
最佳答案
如果上面的代码不起作用,那么您将尝试下面的第二种方法,这是您将使用此代码的示例代码
XML 代码:
<record id="hr_timesheets_attendance_action_kanban" model="ir.actions.act_window">
<field name="name">Timesheets</field>
<field name="res_model">account.analytic.line</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p>
To create employees timesheet.
</p>
</field>
</record>
JS代码
this.do_action('module_name.hr_timesheets_attendance_action_kanban');
谢谢
关于javascript - 如何在 Odoo 11 中通过 do_action() java 脚本方法显示 action_id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54129440/