Jalena Blog

  • 首页
  • 程序开发
    • Java
    • Spring
    • SpringBoot
    • SpringMvc
    • Python
    • Odoo
    • C#
    • SQL
    • Web
    • Linux
  • 移动设备
    • Android
    • Router
  • 杂七杂八
    • 我的废话
    • 音频
    • 视频
    • 常用软件
  • 关于
  1. 首页
  2. 软件开发
  3. Python
  4. Odoo
  5. 正文

Odoo Javascript & Widget

2018-12-01

定义一个OdooClass

odoo.define('addon_name.service', function (require) {
    "use strict";
    var utils = require('web.utils');
    var Model = require('web.Model');

    // do things with utils and Model
    var something_useful = 15;
    return  {
        something_useful: something_useful,
    };
});

重写记录打开方式

odoo.define('combined_statements.working_papers', function(require) {
    "use strict";
	var core = require('web.core');
	var ListView = require('web.ListView');
	var utils = require('web.utils');
	var web_client = require('web.web_client');
	var Model = require('web.Model');

	var QWeb = core.qweb;
	var _t = core._t;

	/**
	 * 打开工作底稿创建向导页面
	 */
	function open_wording_papers_wizard_action() {
		web_client.action_manager.do_action({
			name: "底稿定义",
			type: "ir.actions.act_window",
			res_model: "working.papers.define.wizard",
			target: 'new',
			xml_id: 'combined_statements.working_papers_define_wizard_form',
			views: [
                [
                    false, 'form'
                ]
            ]
        });
    }

	ListView.include({
        // 为增加按钮绑定点击事件
		render_buttons: function($node) {
			let add_button = false;
			if (!this.$buttons) {
				add_button = true;
            }

			this._super.apply(this, arguments);

			if (add_button) {
				this.$buttons.on('click', '.o_button_open', open_wording_papers_wizard_action.bind(this));
            }
        },
        // 重写Tree视图点击行打开记录的方式
		do_activate_record: function(index, id, dataset, view) {
			if (this.model === 'combined.statements.working.paper') {
				let record = this.records.get(id);
				this.do_action({
					type: "ir.actions.client",
					tag: 'working.papers',
					params: record,
                });
            }else {
				this._super.apply(this, arguments);
            }
        }
    });
});
标签: javascript odoo
最后更新:2019-01-01

Jalena

原创内容,转载请注明出处! 部分内容来自网络,请遵守法律适用!

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

【腾讯云】云服务器特惠热卖中
文章目录
  • 定义一个OdooClass
  • 重写记录打开方式
标签聚合
java Centos odoo 其他 生活 wordpress docker MySql
分类
  • Android / 4篇
  • C# / 10篇
  • Codec / 9篇
  • Conversion / 14篇
  • Editing / 16篇
  • Java / 47篇
  • Javascript / 3篇
  • Linux / 30篇
  • Odoo / 25篇
  • Python / 6篇
  • SQL / 30篇
  • Web / 3篇
  • Windows / 4篇
  • 我的日记 / 10篇
  • 杂七杂八 / 93篇
  • 软件开发 / 72篇
  • 非线性编辑 / 1篇

COPYRIGHT © 2026 Jalena Blog. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

蜀ICP备17025376号