تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
6500 أدوات العرض

Hi !

I added a custom field in the general settings but I can't save the field. When I take a look at the field in DB, it is always set to False

python file:

from odoo import fields, models, api

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

mm_access_token = fields.Char("MM access token")

xml file:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_mm" model="ir.ui.view">
<field name="name">res.config.settings.view.mattermost</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='multi_company']" position="after">
<div name="mattermost">
<h2>Mattermost Integration</h2>
<div class="row mt16 o_settings_container" id="multi_branch">
<div class="col-12 col-lg-6 o_setting_box">
<label for="mm_access_token" string="Mattermost Access Token"/>
<field name="mm_access_token" class="oe_inline"/>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

الصورة الرمزية
إهمال
أفضل إجابة

Create a field in the res.company and then create a related field in the res config obj.

Ex:

_inherit = 'res.company'
mm_access_token = fields.Char("MM access token")


_inherit = 'res.config.settings'
mm_access_token = fields.Char("MM access token", related='company_id.mm_access_token')

 

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

now I'm getting:

ERROR: column res_company.mm_access_token does not exist

Now in my .py file I have:

class Company(models.Model):
_inherit = 'res.company'

mm_token = fields.Char("Mattermost token")

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

mm_access_token = fields.Char("MM access token", related='company_id.mm_token')

When I update the module with the -u, I dont have any error but the field does not appear anymore in the config view
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أبريل 24
1470
1
أبريل 25
866
Odoo Server Error تم الحل
1
أبريل 25
1019
0
نوفمبر 24
1289
0
أكتوبر 24
1383