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 opjfrom 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