The function "Write" after new o2m record don't update form and don't be saved

Bug #656747 reported by David Diz

This bug report was converted into a question: question #137748: The function "Write" after new o2m record don't update form and don't be saved.

6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Web Client
Invalid
Undecided
Unassigned

Bug Description

class A(osv.osv):
    _name="A"

    def write(self, cr, uid, ids, vals, context=None):
        eval = vals.get('b_ids', 0)
        for item in eval:
            vals['state_a'] = eval[i][2]['state_b']
        return super(A, self).write(cr, uid, ids, vals, context)

    _columns={
        "name": fields.char('Name', size=25 ),
        "b_ids": fields.one2many('B', 'a_id', 'Evals' ),
        "state_a": fields.selection([("O","Open"), ("C","Close")], 'State'),
        }
A()

class B(osv.osv):
    _name='B'

    _columns={
        "name": fields.char('Name', size=25 ),
        "a_id": fields.many2one('A'),
        "state_b": fields.selection([("O","Open"), ("C","Close")], 'State'),
        }

    _defaults = {
        'a_id': lambda self, cr, uid, context: context.get('a', False),
    }

B()

-In the form of the A object i have a o2m grid with its B objects.
-Now i create a new B object from the grid.
-The write function of the A object is called and the new value of "state" is stored in the database but not displayed in the form.
-If i press the cancel button of the form the new value of the "state" field is displayed but if i press the save button the new value is deleted from the database and not displayed in the saved form.

This behavior does not happen in the GTK client.

David Diz (daviddiz)
description: updated
Revision history for this message
DBR (OpenERP) (dbr-openerp) wrote :

class A(osv.osv):
    _name="A"

    def write(self, cr, uid, ids, vals, context=None):
        eval = vals.get('b_ids', 0)
        for item in eval:
            vals['state_a'] = eval[i][2]['state_b']
        return super(A, self).write(cr, uid, ids, vals, context)

    _columns={
        "name": fields.char('Name', size=25 ),
        "b_ids": fields.one2many('B', 'a_id', 'Evals' ),
        "state_a": fields.selection([("O","Open"), ("C","Close")], 'State'),
        }
A()

class B(osv.osv):
    _name='B'

    _columns={
        "name": fields.char('Name', size=25 ),
        "a_id": fields.many2one('A'),
        "state_b": fields.selection([("O","Open"), ("C","Close")], 'State'),
        }

    _defaults = {
        'a_id': lambda self, cr, uid, context: context.get('a', False),
    }

B()

-In the form of the A object i have a o2m grid with its B objects.
-Now i create a new B object from the grid.
-The write function of the A object is called and the new value of "state" is stored in the database but not displayed in the form.
-If i press the cancel button of the form the new value of the "state" field is displayed but if i press the save button the new value is deleted from the database and not displayed in the saved form.

This behavior does not happen in the GTK client.

Changed in openobject-client-web:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.