在 Odoo 中创建新模块 - 安装后无法在应用列表中看到该模块

Creating a new module in Odoo - Cannot see the module on app list after installation

我设置并安装了 Odoo。安装后我做了脚手架来创建一个测试模块。在该模块中,我添加了一些代码,该模块出现在我的模块列表下。但是安装后我没有在我的应用程序列表中看到该模块。下面是我的代码:

button_action_demo.py

from odoo import models, fields, api

#Non-odoo library
import random
from random import randint
import string

class button_action_demo(models.Model):
    _name = 'button.demo'
    name = fields.Char(required=True,default='Click on generate name!')
    password = fields.Char()

    def generate_record_name(self):
        self.ensure_one()
    #Generates a random name between 9 and 15 characters long and writes it to the record.
        self.write({'name': ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(randint(9,15)))})

    def generate_record_password(self):
        self.ensure_one()
    #Generates a random password between 12 and 15 characters long and writes it to the record.
        self.write({
            'password': ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(randint(12,15)))
        })

    def clear_record_data(self):
        self.ensure_one()
        self.write({
            'name': '',
            'password': ''
        })

views.xml

<record model="ir.ui.view" id="view_buttons_form">
      <field name="name">Buttons</field>
      <field name="model">button.demo</field>
      <field name="type">form</field>
      <field name="arch" type="xml">
          <form string="Button record">
        <!--The header tag is built to add buttons within. This puts them at the top -->
        <header>
      <!--The oe_highlight class gives the button a red color when it is saved.
      It is usually used to indicate the expected behaviour. -->
            <button string="Generate name" type="object" name="generate_record_name" class="oe_highlight"/>
      <button string="Generate password" type="object" name="generate_record_password"/>
      <button string="Clear data" type="object" name="clear_record_data"/>
        </header>
        <group>
      <field name="name"/>
      <field name="password"/>
        </group>
    </form>
      </field>
  </record>

  <!--The action -->
        <record model="ir.actions.act_window" id="buttons_example_action">
            <field name="name">Create new record</field>
            <field name="res_model">button.demo</field>
            <field name="view_mode">form,tree</field>
            <field name='view_id' ref='view_buttons_form'/>
        </record>

        <!-- top level menu: no parent -->
        <menuitem id="main_button_menu" name="Buttons demo"/>
        <menuitem id="button_menu" name="Buttons demo"
                  parent="main_button_menu"/>
        <menuitem id="menu_detail_logging"
                action="buttons_example_action" parent="button_menu"
                sequence="20"/>
    </data>
</odoo>

清单.py

{
    'name': "button_action_demo",

    'summary': """
        Short (1 phrase/line) summary of the module's purpose, used as
        subtitle on modules listing or apps.openerp.com""",

    'description': """
        Long description of module's purpose
    """,

    'author': "My Company",
    'website': "http://www.yourcompany.com",

    # Categories can be used to filter modules in modules listing
    # Check https://github.com/odoo/odoo/blob/13.0/odoo/addons/base/data/ir_module_category_data.xml
    # for the full list
    'category': 'Uncategorized',
    'version': '0.1',

    # any module necessary for this one to work correctly
    'depends': ['base'],

    # always loaded
    'data': [
        # 'security/ir.model.access.csv',
        'views/views.xml',
        'views/templates.xml',
    ],
    # only loaded in demonstration mode
    'demo': [
        'demo/demo.xml',
    ],
}

security.py

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_button_action_demo_button_action_demo,button_action_demo.button_action_demo,model_button_action_demo_button_action_demo,base.group_user,1,1,1,1

有人可以指导我我的代码中缺少什么吗?如果需要,我非常乐意分享更多代码,但我想我已经提供了大部分代码

添加安全性或打开调试模式,然后单击成为 odoo 中的超级用户 13 admin 不是超级用户,但您可以通过上面的操作使他成为超级用户

如果模块在应用列表中不可见,请检查下面列出的几项内容。

  • 重新启动您的服务器。
  • 更新应用列表。
  • 将模块放在右侧插件中 PATH.

如果您的 security 文件运行不正常或者您的 manifest 文件 所有这些事情都会在安装期间或安装后发生。