多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
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> ~~~