I was trying to create a record with a few required fields in an editable tree view of a one2many field.
If I entered a record correctly and saved it, the creating and saving of the record were always OK.
But, if I accidentally missed one or few required fields when creating a new record, I received warning messages, which was fine to this point. Then, I entered the missed required fields and saved the record. Then, multiple same records (normally the same number of the warning messages) were saved in the tree view, which was definitely wrong, because I only entered one record in the tree view.
I checked the record in the postgresql database. Yes, there were multiple same records. I also traced the create function. of model. Yes, it was called multiple times and each time it added a same record. The problem only occurs within the tree view of a one2many field. No problem with a normal tree view on normal fields.
How could this problem happen? Is there a fix or is it a bug of openerp v7?
======== lgp_testing.py ========
from openerp.osv import osv
from openerp.osv import fields
class lgp_testing(osv.osv):
_name = 'lgp.testing'
_description = u'testing'
_columns = {
'name': fields.char(u'name', size=60, required=True),
'detail': fields.one2many('lgp.testingdetails', 'name', u'detail'),
}
lgp_testing()
class lgp_testingdetails(osv.osv):
_name = 'lgp.testingdetails'
_description = u'testingdetails'
_columns = {
'name': fields.many2one('lgp.testing', u'name', ondelete='no action'),
'val': fields.char(u'val', size=100, required=True),
'date': fields.date(u'date', required=True),
}
lgp_testingdetails()
======== lgp_testing_view.xml ========
<openerp>
<data>
<record model="ir.ui.view" id="view_testing_form">
<field name="name">testing</field>
<field name="model">lgp.testing</field>
<field name="priority" eval="10"/>
<field name="arch" type="xml">
<form string="testing">
<group colspan="4" col="4">
<field name="name" string="name"/>
</group>
<field name="detail" string="detail" nolabel="1">
<tree string="testingdetails" editable="bottom">
<field name="val" string="val" required="True"/>
<field name="date" string="date" required="True"/>
</tree>
</field>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_testing_tree">
<field name="name">testing</field>
<field name="model">lgp.testing</field>
<field name="priority" eval="10"/>
<field name="arch" type="xml">
<tree string="testing">
<field name="name" string="name"/>
<field name="detail" string="detail"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_testing">
<field name="name">testing</field>
<field name="res_model">lgp.testing</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_testing_tree"/>
</record>
<menuitem id="menu_testing" name="testing" parent="menu_settings" action="action_testing" sequence="2"/>
</data>
</openerp>
Which editable list are you talking about? Not sure that's a Bug.
The editable list is what I created from a one2many field. It appears that the problem does not show in the normal editable list. At least I can repeat the problem in the tree view of one2many fields, but not in a normal tree view.
The only way to deal with your problem, is to begin by posting your code, and if possible to attach some "Print Screen" to illustrate this case
I posted some very simple code that reproduce the errors. How could I post screenshots? My karma is less than 30 now.