Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
6538 Visualizações

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>

Avatar
Cancelar
Melhor resposta

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')

 

Avatar
Cancelar
Autor Melhor resposta

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
Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
0
abr. 24
1486
1
abr. 25
906
1
abr. 25
1039
0
nov. 24
1298
0
out. 24
1396