0

我设置并安装了 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': ''
        })

视图.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',
    ],
}

安全.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

有人可以指导我在我的代码中缺少什么。如果需要,我很乐意分享更多代码,但我认为我已经提供了大部分代码

4

2 回答 2

1

添加安全性或打开调试情绪,然后在 odoo 13 管理员中单击成为超级用户不是超级用户,但您可以通过上述操作使他成为超级用户

于 2019-12-17T02:35:26.967 回答
1

如果模块在应用列表中不可见,请检查以下几项。

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

如果您的安全文件运行不正常或清单文件有问题,所有这些事情都会在安装期间或安装后发生。

于 2019-12-19T08:13:37.350 回答