Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
3130 Visualizzazioni

I want to install my custom module to show tree view, but the apps not showing in apps list
here's my codes

.py

from odoo import models, fields, apiimport requests
class PokemonCustom(models.Model):    _name = 'pokemon.list'    _description = 'Pokemon List'
    pokemon_id = fields.Integer(string='Pokemon ID', help='ID of the Pokemon')    pokemon_name = fields.Char(string='Pokemon Name', help='Name of the Pokemon')
    def get_all_pokemon(self):        response = requests.get(f'https://pokeapi.co/api/v2/pokemon?limit=10000')                if response.status_code == 200:            data = response.json()
            for pokemon in data['results']:                pokemon_name = pokemon['name']                pokemon_id = int(pokemon['url'].split('/')[-2])
                existing_pokemon = self.search([('pokemon_id', '=', pokemon_id)])                if not existing_pokemon:                    self.create({                        'pokemon_name': pokemon_name,                        'pokemon_id': pokemon_id                    })
    def get_pokemon(self):        random_number = self.get_unique_random_number()        response = requests.get(f'https://pokeapi.co/api/v2/pokemon/{random_number}/')
        if response.status_code == 200:            data = response.json()
            pokemon_name = data['name']            pokemon_id = data['id']
            self.write({                'pokemon_name': pokemon_name,                'pokemon_id': pokemon_id            })


.xml 

     
          Pokemon List      pokemon.list                                                   
          Pokemon List      pokemon.list      tree,form   
      


manifest

# -*- coding: utf-8 -*-{    'name': "Pokemon List",
    'summary': "Manage Pokémon in Odoo",
    'description': """Long description of the module's purpose.    """,
    'author': "Your Company",    'website': "https://www.yourcompany.com",
    'category': 'Uncategorized',    'version': '0.1',    'installable': True,    'application': True,
    'depends': ['base', 'contacts'],
    'data': [        'views/pokemon.xml',        'views/res_partner.xml',        'security/ir.model.access.csv'    ],
    'demo': [        'demo/demo.xml',    ],
    'images': [        'static/description/icon.png',    ],}


security

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_pokemon_custom,pokemon.list,model_pokemon_list,base.group_user,1,1,1,1



Avatar
Abbandona
Risposta migliore

Hi,

here is code please try this 
.py

# models/https://pokeapi.co/api/v2/pokemon/{random_number}/ ')

        if response.status_code == 200:

            data = response.json()

            pokemon_name = data['name']

            pokemon_id = data['id']

            self.write({

                'pokemon_name': pokemon_name,

                'pokemon_id': pokemon_id

            })

View file (XML) formatting

You need valid XML syntax and proper tree / form views:

<!-- views/pokemon.xml -->

<odoo>

    <record id="view_pokemon_list_tree" model="ir.ui.view">

        <field name="name">pokemon.list.tree</field>

        <field name="model">pokemon.list</field>

        <field name="arch" type="xml">

            <tree>

                <field name="pokemon_id"/>

                <field name="pokemon_name"/>

            </tree>

        </field>

    </record>


    <record id="view_pokemon_list_form" model="ir.ui.view">

        <field name="name">pokemon.list.form</field>

        <field name="model">pokemon.list</field>

        <field name="arch" type="xml">

            <form>

                <sheet>

                    <group>

                        <field name="pokemon_id"/>

                        <field name="pokemon_name"/>

                    </group>

                </sheet>

            </form>

        </field>

    </record>


    <menuitem id="menu_pokemon_root" name="Pokemon"/>

    <menuitem id="menu_pokemon_list" name="Pokemon List" parent="menu_pokemon_root" action="action_pokemon_list"/>


    <record id="action_pokemon_list" model="ir.actions.act_window">

        <field name="name">Pokemon List</field>

        <field name="res_model">pokemon.list</field>

        <field name="view_mode">tree,form</field>

    </record>

</odoo>


security file
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

access_pokemon_list,pokemon.list,model_pokemon_list,base.group_user,1,1,1,1

Put your module inside odoo/addons/ or your custom addons path.

i hope it is usefull


Restart Odoo server :

Avatar
Abbandona
Risposta migliore

Hi,

Here are potential reasons why your custom module might not be showing up in the Apps list:

1. File Structure: Double-check that the file structure within the module directory is accurate, as Odoo expects a specific arrangement.

2.Update Module List: Remember to refresh the module list in Odoo's Apps menu after placing the module in the correct directory.

Activate Developer Mode , Go to Apps and Click on Update Apps List then Update.

3. Check __manifest__.py : Ensure the 'application': True, line is present to mark it as an application

Please share screenshots for better understanding of the Issue is


Hope it helps

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
feb 25
3675
0
mag 24
46
1
apr 24
3428
4
set 23
4923
2
set 23
7135