无法访问Odoo中的视图

问题描述 投票:0回答:1

我正在尝试在Odoo中定义自定义设置。我用这个链接来帮助我http://ludwiktrammer.github.io/odoo/custom-settings-odoo.html

我换了

<menuitem id="your_settings_menu" name="Your settings"
    parent="base.menu_config" action="your_settings_action"/>

通过

<menuitem id="mattermost_settings_menu" name="Mattermost settings" parent="base.menu_administration"
     action="mattermost_settings_action" />

因为我有这个错误:在系统中找不到外部ID:base.menu_config“

现在,没有编译错误,当我点击菜单时出现此错误:

Uncaught TypeError: Cannot read property 'settingView' of undefined
http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:5
Traceback:
TypeError: Cannot read property 'settingView' of undefined
    at Class._moveToTab (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:5:42)
    at Class._renderLeftPanel (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:8:315)
    at Class._render (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:7:716)
    at Class.prototype.(anonymous function) [as _render] (http://127.0.0.1:8069/web/content/383-805b1f7/web.assets_common.js:3538:488)
    at Class.start (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:1275:335)
    at Class.prototype.(anonymous function) [as start] (http://127.0.0.1:8069/web/content/383-805b1f7/web.assets_common.js:3538:488)
    at Class.start (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:1609:20)
    at Class.prototype.(anonymous function) [as start] (http://127.0.0.1:8069/web/content/383-805b1f7/web.assets_common.js:3538:488)
    at Class.start (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:3:654)
    at Class.prototype.(anonymous function) [as start] (http://127.0.0.1:8069/web/content/383-805b1f7/web.assets_common.js:3538:488)

这是我的xml文件:

<record id="res_config_settings_mm" model="ir.ui.view">
    <field name="name">Mattermost config</field>
    <field name="model">mattermost.settings</field>
    <field name="arch" type="xml">
        <form string="Your configuration" class="oe_form_configuration">
            <header>
                <button string="Save" type="object"
                    name="execute" class="oe_highlight"/>
                or
                <button string="Cancel" type="object"
                    name="cancel" class="oe_link"/>
            </header>
            <group string="Company">
                <label for="id" string="Name &amp; Phone"/>
                <div>
                    <div>
                        <label for="company_name"/>
                        <field name="company_name"/>
                    </div>
                    <div>
                        <label for="company_phone"/>
                        <field name="company_phone"/>
                    </div>
                </div>
            </group>
        </form>
    </field>
</record>

<record id="mattermost_settings_action" model="ir.actions.act_window">
    <field name="name">Mattermost config</field>
    <field name="res_model">mattermost.settings</field>
    <field name="view_id" ref="res_config_settings_mm"/>
    <field name="view_mode">form</field>
    <field name="target">inline</field>
</record>

<menuitem id="mattermost_settings_menu" name="Mattermost settings" parent="base.menu_administration"
     action="mattermost_settings_action" />

这是我的python文件:

class MattermostConfig(models.TransientModel):
    _inherit = 'res.config.settings'
    _name = 'mattermost.settings'

    company_name = fields.Char()
    company_phone = fields.Char()

    @api.model
    def get_default_company_values(self, fields):
        _logger.critical('\n\nget_default_company_values\n\n')
        company = self.env.user.company_id
        return {
            'company_name': company.name,
            'company_phone': company.phone,
        }

    @api.one
    def set_company_values(self):
        _logger.critical('\n\nset_company_values\n\n')
        company = self.env.user.company_id
        company.name = self.company_name
        company.phone = self.company_phone

你知道怎么解决这个问题吗?

view settings odoo
1个回答
0
投票

首先,base.menu_config是新版Odoo中的base_setup.menu_config

其次,在您显示的日志上,问题在于从资产后端继承的视图。因此,如果问题仍然存在且您有Bash shell,则可以尝试以下操作:

cd <your_module's_directory>
find . -type f -exec grep -I -n "settingView"

否则,您可以在__manifest__.py文件中注释所有XML文件,然后逐个取消注释。

© www.soinside.com 2019 - 2024. All rights reserved.