Openerp 从日历视图中禁用“创建”选项
我可以在单击时禁用quick_加载项日历视图,但它会导致打开“表单视图”,用户可以创建任务 我的代码片段如下Openerp 从日历视图中禁用“创建”选项,openerp,odoo-8,odoo-9,Openerp,Odoo 8,Odoo 9,我可以在单击时禁用quick_加载项日历视图,但它会导致打开“表单视图”,用户可以创建任务 我的代码片段如下 <!-- Calendar View Begins--> <record id="pms_view_task_calendar" model="ir.ui.view"> <field name="name">project.task.calendar</field> <field name="mo
<!-- Calendar View Begins-->
<record id="pms_view_task_calendar" model="ir.ui.view">
<field name="name">project.task.calendar</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_calendar"/>
<field name="arch" type="xml">
<calendar position="attributes">
<attribute name="quick_add">false</attribute>
</calendar>
</field>
</record>
<!-- Calendar View Ends-->
project.task.calendar
项目任务
假的
如何在单击日历时禁用日历视图中的创建选项最后,我通过继承JS从单击操作中的日历视图中删除了创建选项
odoo.define('module_name.calender_view', function (require) {
"use strict";
var calenderView = require('web_calendar.CalendarView');
calenderView.include({
open_quick_create: function(){
if (this.model != 'model.name') {
this._super();
}
}
});
});
最后,我通过继承JS从click操作中的日历视图中删除了create选项
odoo.define('module_name.calender_view', function (require) {
"use strict";
var calenderView = require('web_calendar.CalendarView');
calenderView.include({
open_quick_create: function(){
if (this.model != 'model.name') {
this._super();
}
}
});
});
答案很好。
我已将他的答案修改为设置多个模型
var calenderView = require('web_calendar.CalendarView');
calenderView.include({
open_quick_create: function(){
var calendar_models = ['project.task', 'sale.order', 'crm.lead'];
if (!(calendar_models.includes(this.model))) {
this._super();
}
}
});
答案很好。
我已将他的答案修改为设置多个模型
var calenderView = require('web_calendar.CalendarView');
calenderView.include({
open_quick_create: function(){
var calendar_models = ['project.task', 'sale.order', 'crm.lead'];
if (!(calendar_models.includes(this.model))) {
this._super();
}
}
});
更新Odoo 11以及如何使特定型号的日历视图完全只读: JS文件:
odoo.define('your_module.CalendarView', function (require) {
"use strict";
var CalendarView = require('web.CalendarView');
CalendarView.include({
init: function (viewInfo, params) {
this._super.apply(this, arguments);
if (this.controllerParams.modelName == 'your.model.name') {
this.loadParams.editable = false;
this.loadParams.creatable = false;
}
},
});
return CalendarView;
});
不要忘记通过xml“包含”js:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="handling assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/your_module/static/src/js/your_javascript_file_name.js"/>
</xpath>
</template>
</odoo>
更新Odoo 11以及如何使特定型号的日历视图完全只读: JS文件:
odoo.define('your_module.CalendarView', function (require) {
"use strict";
var CalendarView = require('web.CalendarView');
CalendarView.include({
init: function (viewInfo, params) {
this._super.apply(this, arguments);
if (this.controllerParams.modelName == 'your.model.name') {
this.loadParams.editable = false;
this.loadParams.creatable = false;
}
},
});
return CalendarView;
});
不要忘记通过xml“包含”js:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="handling assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/your_module/static/src/js/your_javascript_file_name.js"/>
</xpath>
</template>
</odoo>
Vignesh我尝试了此解决方案,但出现了一个客户端错误:“Uncaught TypeError:viewclass不是构造函数”Hello@Vigneshwaran,我们可以打开直接表单视图而不是此摘要窗口吗?感谢advanceVignesh,我尝试了这个解决方案,但得到了一个客户端错误:“UncaughtTypeError:viewclass不是构造函数”Hello@Vigneshwaran,我们可以打开直接表单视图而不是这个摘要窗口吗?提前感谢您知道如何为基于公共假日的日期列指定特定颜色吗?您知道如何为基于公共假日的日期列指定特定颜色吗?