I'm tryng to write into my db in uppercase. I've used the on change method in this way:
# -*- encoding: utf-8 -*-
from openerp import models, fields
class mymodule_tbl(models.Model):
_name = 'tbl
_description = 'Insert into my db'
sdescription = fields.Text('Description', required=True)
def uppercase(self, cr, uid, ids, sdescription, context=None):
result = {'value': {'sdescription': str(sdescription).upper()}}
return result
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_mymodule_tbl_search" model="ir.ui.view">
<field name="name">MyModule</field>
<field name="model">tbl/field>
<field name="arch" type="xml">
<search>
<field name="sdescription"/>
</search>
</field>
</record>
<record id="view_mymodule_tbl_tree" model="ir.ui.view">
<field name="name">mymodule_tbl.tree.view</field>
<field name="model">tbl/field>
<field name="arch" type="xml">
<tree string="MyModule" export="false">
<field name="sdescription" on_change="uppercase(sdescription)"/>
</tree>
</field>
</record>
<record id="view_mymodule_tbl_form" model="ir.ui.view">
<field name="name">mymodule_tbl.form.view</field>
<field name="model">tb</field>
<field name="arch" type="xml">
<form string="mymodule tbl" duplicate="false">
<group>
<field name="sdescription" on_change="uppercase(sdescription)"/>
</group>
</form>
</field>
</record>
<record id="action_mymodule_tbl" model="ir.actions.act_window">
<field name="name">Tbl</field>
<field name="res_model">tbl/field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" eval="False"/>
<field name="context">{}</field>
</record>
<menuitem action="action_mymodule_tbl" id="menu_action_mymodule_tbl" parent="mail.mail_feeds" sequence="70"/>
</data>
</openerp>
but it doesn't work. Any idea?
Thanks!
-------------------------------
I've edited my post with the right code.
You want to set value in default_code field? and default_code field is available in view?
I made a mistake with default_code field. Thank you.