Hello,
I'm currently making a custom module for Odoo 9 and I want to create a configuration view to set 3 values.
I have a view with a record to call it in an xml file :
<record id="view_magento_config_settings_form_pos" model="ir.ui.view"> <field name="name">to.magento.form</field> <field name="model">to.magento</field> <field name="arch" type="xml"> <form class="oe_form_configuration"> <header> <button string="Apply" type="object" name="execute" class="oe_highlight"/> <button string="Cancel" type="object" name="cancel" class="oe_link"/> </header> <group string="General informations"> <label for="id" string="URL"/> <div> <field name="url" class="oe_inline"/> </div> <label for="id" string="API User"/> <div> <field name="api_user" class="oe_inline"/> </div> <label for="id" string="API Key"/> <div> <field name="api_key" class="oe_inline"/> </div> </group> </form> </field> </record>
<record id="action_magento_configuration" model="ir.actions.act_window"> <field name="name">Configure Magento</field> <field name="res_model">to.magento</field> <field name="view_mode">form</field> <field name="target">inline</field> </record> |
I have a model too in a python file :
class to_magento (osv.TransientModel): _inherit = 'res.config.settings' _name = 'to.magento' _columns = { 'url' : fields.char('URL', size=32, select=2, required=True, help='An internal identification for this url'), 'api_user' : fields.char('API User', size=32, select=3, required=True, help='An internal identification for this API User'), 'api_key' : fields.char('API Key', size=32, select=4, required=True, help='An internal identification for this API Key'), } |
I have the following view that apear :
http://i.imgur.com/c2XqK77.png
When I use the Apply button, in the database, the values are recorded but when I reload the page, it show me void fields and when I apply again, a new line is created in the database.
My problem is here. I want to have only one line in the database with an unique value for each field, that is loaded when exists in my settings view.
How can I do that ?
Thank you in advance for your help !