带odoo12的JavaScript

问题描述

我目前正在使用odoo12ce,并且试图在JS中通过and action触发创建一个简单的自定义仪表板,但是由于含糊的官方文档,我遇到了一些问题。

我已经继承并扩展了res.model并添加了两个字段

cats = fields.Integer(string =“猫数”) dogs = fields.Integer(string =“狗的数量”)

我想开始使用JS显示res.model中的记录列表以及javascript(类似于树形视图)中的猫和狗的数量

我从网站上下载了此模块,我认为这将是一个很好的起点,但是我不知道如何从JS访问res.partner。

odoo.define('hello_world.main',function (require) {
  // The require will import the AbstractAction from the web module.
  // The AbstractAction is the base class for all actions in odoo
  const AbstractAction = require('web.AbstractAction');
  const core = require('web.core');

  const OurAction = AbstractAction.extend({
    // Loads the template from static/src/xml/hello_world.xml
    template: "hello_world.ClientAction",info: "this message comes from the JS"
  });

  // Adds it to the registry so that the action is loaded by odoo
  core.action_registry.add('hello_world.action',OurAction);
});

<?xml version="1.0" encoding="UTF-8"?>
<!--
    This template will be loaded from /static/src/js/hello_world.js
-->
<templates xml:space="preserve">
    <div t-name="hello_world.ClientAction" class="hello-world">
      <h1 class="text-center">Hello odoo</h1>
      <div class="text-center">
          <!--
            widget.info is filled through the JavaScript code. See static/src/js/hello_world.js
          -->
          <t t-esc="widget.info"/>
      </div>
    </div>
</templates>

和操作按钮

    <data>
        <record id="action_hello_world" model="ir.actions.client">
            <field name="name">Tutorial Demo</field>
            <field name="tag">hello_world.action</field>
        </record>

        <menuitem name="Hello World"
                  id="hello_world_menu_root"
                  action="action_hello_world"/>
    </data>

当我单击并想要扩展对res.partner记录的访问权限时,代码可以正常工作并显示Hello odoo和信息小部件。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)