Qweb是一个client和server的东东,类似jsp
实现:
通过点击upgrade,弹出一个upgrade的对话框
![](https://box.kancloud.cn/b7741f983c59cbc02adfdf702c4c3252_961x137.png)
![](https://box.kancloud.cn/3f30de5a904a0819850e9caaaeca4a8f_1008x156.png)
* 编写python
~~~
# 公司看板
class CompanyInDeviceUpgrade(models.Model):
_inherit = 'res.company'
# 发布
@api.multi
def open_device_upgrade_wizard(self):
return {
'name': 'Upgrade', # 对话框标题
'target': 'new',
'tag': 'tmp_device_upgrade_wizard_tag', # 对应action
'type': 'ir.actions.client', # 使用client action
}
~~~
* 编写action
~~~
<!-- action for device upgrade wizard -->
<record id="tmp_device_upgrade_wizard_client" model="ir.actions.client">
<field name="name">Upgrade</field>
<field name="target">new</field>
<field name="tag">tmp_device_upgrade_wizard_tag</field>
</record>
~~~
* 编写template(对应html)
device_upgrade_wizard_template.xml
~~~
<?xml version='1.0' encoding='utf-8' ?>
<template xml:space="preserve">
<t t-name="device_upgrade_wizard_client">
<p>Upgrade</p>
</t>
</template>
~~~
* 编写js(对应html)
device_upgrade_wizard.js
~~~
odoo.define('tmp_device_upgrade.wizard', function (require) {
var core = require('web.core');
var Widget = require('web.Widget');
var QWeb = core.qweb;
var monitor_control = Widget.extend({
template: 'device_upgrade_wizard_client',
init: function (parent, context) {
this._super(parent, context);
//this.layer = layer.msg("加载中...",{time:0, shade: 0.3});
},
start: function () {
this.load_fn();
},
load_fn: function () {
var self = this;
/* setTimeout(function () {
new dispatch_desktop(self, self.layer).appendTo(self.$el);
},1000);*/
self.$el.find('#mytable thead').removeAttr("style");
}
});
core.action_registry.add('tmp_device_upgrade_wizard_tag', monitor_control);
})
;
~~~
* 引入js
~~~
<template id="assets_backend" name="tree view menu" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/tmp_device/static/src/js/device_upgrade_wizard.js"></script>
</xpath>
</template>
~~~
- 开发教程
- Odoo10开发教程一(构建模块)
- Odoo10开发教程二(基本视图)
- Odoo10开发教程三(模型关联)
- Odoo10开发教程四(继承)
- Odoo10开发教程五(计算字段和默认值)
- Odoo10开发教程六(高级视图)
- Odoo10开发教程七(工作流和安全)
- 参考手册
- odoo V10中文参考手册(一:ORM API)
- odoo V10中文参考手册(指导规范)
- 技巧
- odoo 常用widget
- Odoo(OpenERP)开发实践:菜单隐藏(1)
- Odoo(OpenERP)开发实践:菜单隐藏(2)
- Odoo(OpenERP)开发实践:数据模型学习
- Odoo中自动备份数据库
- Odoo(OpenERP)应用实践: 使用db-filter参数实现通过域名指定访问哪个数据库
- Odoo(OpenERP)配置文件openerp-server.conf详解
- Odoo(OpenERP v8)数据模型(Data Model)
- odoo10学习笔记十七:controller
- Qweb定义