odoo-cmd scaffld コマンドで作成した helloodood addonの中身を確認
及びインストール
自動作成されたファイルが以下
独自にカスタマイズする部分はコメントになっているので
コメントを外してインストール
-----------------------------------------------------------__init__.py
# -*- coding: utf-8 -*-
from . import controllers
from . import models
------------------------------------------------------------__manifest__.py
# -*- coding: utf-8 -*-
{
'name': "helloodoo",
'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
# ir_module_category_data.xmlに既存カテゴリー一覧があるので、それにから選んで指定すればカテゴリーリストで表示される
'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',
],
}
------------------------------------------------------------controllers/__init__.py
# -*- coding: utf-8 -*-
from . import controllers
------------------------------------------------------------controllers/controllers.py
# -*- coding: utf-8 -*-
# from odoo import http
# class Helloodoo(http.Controller):
# @http.route('/helloodoo/helloodoo/', auth='public')
# def index(self, **kw):
# return "Hello, world"
# @http.route('/helloodoo/helloodoo/objects/', auth='public')
# def list(self, **kw):
# return http.request.render('helloodoo.listing', {
# 'root': '/helloodoo/helloodoo',
# 'objects': http.request.env['helloodoo.helloodoo'].search([]),
# })
# @http.route('/helloodoo/helloodoo/objects/<model("helloodoo.helloodoo"):obj>/', auth='public')
# def object(self, obj, **kw):
# return http.request.render('helloodoo.object', {
# 'object': obj
# })
------------------------------------------------------------models/__init__.py
# -*- coding: utf-8 -*-
from . import models
------------------------------------------------------------models/models.py
# -*- coding: utf-8 -*-
# from odoo import models, fields, api
# class helloodoo(models.Model):
# _name = 'helloodoo.helloodoo'
# _description = 'helloodoo.helloodoo'
# name = fields.Char()
# value = fields.Integer()
# value2 = fields.Float(compute="_value_pc", store=True)
# description = fields.Text()
#
# @api.depends('value')
# def _value_pc(self):
# for record in self:
# record.value2 = float(record.value) / 100
------------------------------------------------------------security/ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_helloodoo_helloodoo,helloodoo.helloodoo,model_helloodoo_helloodoo,base.group_user,1,1,1,1
------------------------------------------------------------views/views.xml
<odoo>
<data>
<!-- explicit list view definition -->
<!--
<record model="ir.ui.view" id="helloodoo.list">
<field name="name">helloodoo list</field>
<field name="model">helloodoo.helloodoo</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="value"/>
<field name="value2"/>
</tree>
</field>
</record>
-->
<!-- actions opening views on models -->
<!--
<record model="ir.actions.act_window" id="helloodoo.action_window">
<field name="name">helloodoo window</field>
<field name="res_model">helloodoo.helloodoo</field>
<field name="view_mode">tree,form</field>
</record>
-->
<!-- server action to the one above -->
<!--
<record model="ir.actions.server" id="helloodoo.action_server">
<field name="name">helloodoo server</field>
<field name="model_id" ref="model_helloodoo_helloodoo"/>
<field name="state">code</field>
<field name="code">
action = {
"type": "ir.actions.act_window",
"view_mode": "tree,form",
"res_model": model._name,
}
</field>
</record>
-->
<!-- Top menu item -->
<!--
<menuitem name="helloodoo" id="helloodoo.menu_root"/>
-->
<!-- menu categories -->
<!--
<menuitem name="Menu 1" id="helloodoo.menu_1" parent="helloodoo.menu_root"/>
<menuitem name="Menu 2" id="helloodoo.menu_2" parent="helloodoo.menu_root"/>
-->
<!-- actions -->
<!--
<menuitem name="List" id="helloodoo.menu_1_list" parent="helloodoo.menu_1"
action="helloodoo.action_window"/>
<menuitem name="Server to list" id="helloodoo" parent="helloodoo.menu_2"
action="helloodoo.action_server"/>
-->
</data>
</odoo>
------------------------------------------------------------views/templates.xml
<odoo>
<data>
<!--
<template id="listing">
<ul>
<li t-foreach="objects" t-as="object">
<a t-attf-href="#{ root }/objects/#{ object.id }">
<t t-esc="object.display_name"/>
</a>
</li>
</ul>
</template>
<template id="object">
<h1><t t-esc="object.display_name"/></h1>
<dl>
<t t-foreach="object._fields" t-as="field">
<dt><t t-esc="field"/></dt>
<dd><t t-esc="object[field]"/></dd>
</t>
</dl>
</template>
-->
</data>
</odoo>
------------------------------------------------------------
とりあえずインストールは無事完了したみたいですが、アプリにがメニュー表示されません。
アクセス権とユーザーグループの設定がよくないみたいです。
helloodoo_security.xml
ファイルを追加してユーザーグループを追加
<?xml version="1.0" ?>
<odoo>
<record model="ir.module.category" id="module_management">
<field name="name">HelloOdoo</field>
<field name="description">User access level for HelloOdoo</field>
<field name="sequence">20</field>
</record>
<record id="helloodoo_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_management"/>
</record>
<record id="helloodoo_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="module_management"/>
<field name="implied_ids" eval="[(4, ref('helloodoo_user'))]"/>
</record>
</odoo>
ir.model.access.csv
にアクセス権を設定
name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_admin、Access Manager、model_helloodoo_helloodoo、helloodoo_user、1,1,1,0 access_user、Acess user、model_helloodoo_helloodoo、helloodoo_manager、1,1,1,1
これでもちょっと???
です
ちょと迷宮に迷い込んだので
とりあえず、置いとくことにします。
そのうち解決できるでしょう。