Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Res.config.settings is saving several registers, how to fix?

By
Anabela Damas
on 10/8/14, 1:09 PM 824 views

Hi, 

I don't know what I'm doing wrong. 

I'm creating a configuration menu, but everytime that I click on Apply button it creates another register in database. 

Instead of having there the configuration the openerp is saving several registers. When I go to my configuration menu to change the settings, the form is empty ready to create another configuration. If I click in apply another register is saved in database. 

My code: 

import time
import datetime
from dateutil.relativedelta import relativedelta
from operator import itemgetter
from os.path import join as opj

from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT as DF
from openerp.tools.translate import _
from openerp.osv import fields, osv
from openerp import tools


class my_mod_config_settings(osv.osv_memory):
    _name = 'my_mod.config.settings'
    _inherit = 'res.config.settings'

    _columns = {
        'entity': fields.char('Entity', size=5, help="The Entity has a size of 5 digits length."),
        'sub_entity': fields.char('Sub-entity', size=3, help="The Entity has a size of 3 digits length."),
            }
    _defaults = {
        'id_source': 'invoice_number',
    }

my_mod_config_settings()

my view:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <record id="view_my_mod_config" model="ir.ui.view">
            <field name="name">my mod settings</field>
            <field name="model">my_mod.config.settings</field>
            <field name="arch" type="xml">
                <form string="My Configuration" version="7.0" class="oe_form_configuration">
                    <header>
                        <button string="Apply" type="object" name="execute" class="oe_highlight"/>
                        or
                        <button string="Cancel" type="object" name="cancel" class="oe_link"/>
                    </header>

                    <separator string="My Configuration"/>
                    <group>
                        <label for="id" string="Options"/>
                        <div>
                        <div>
                            <label for="entity"/>
                            <field name="entity" class="oe_inline"/>
                        </div>
                        <div>
                            <label for="sub_entity"/>
                            <field name="sub_entity" class="oe_inline"/>
                        </div>
                        <div>
                            <label for="id_source"/>
                            <field name="id_source" class="oe_inline"/>
                        </div>
                        </div>
                    </group>
                </form>
            </field>
        </record>
        
        <record id="action_my_mod_config" model="ir.actions.act_window">
            <field name="name">My config</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">my_mod.config.settings</field>
            <field name="view_mode">form</field>
            <field name="target">inline</field>
        </record>
        
        <menuitem id="menu_my_mod_config" name="My config" parent="base.menu_config"
            action="action_my_mod_config"/>

    </data>
</openerp>

Thanks

0
Iwan Dermawan
On 11/22/16, 3:53 AM

Hello,
You can check this https://www.odoo.com/forum/help-1/question/create-a-custom-configuration-page-for-custom-module-51842

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/8/14, 1:09 PM
Seen: 824 times
Last updated: 11/22/16, 3:53 AM