Search code examples
odooodoo-13

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


I setup and installed Odoo. After installation I did scaffolding to create a test module. Within that module I added some code and the module appeared under my module list. However after installation I do not see the module on my app list. Below is my code:

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>

manifest.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

Can someone please guide me what am I missing on my code. I'm more than happy to share more code if required but I think I have provided most of the bits


Solution

  • If module is not visible in app list then check few things, listed below.

    • Restart your Server.
    • Update App list.
    • Place module in right addons PATH.

    If your security file is not working well or something wrong with your manifest file all these things will happen during installation or after installation.