Odoo Help


how to display object form from function [Closed]

mihir shah
on 5/3/13, 5:43 AM 1,276 views

The Question has been closed

Sudhir Arya (SA)
on 05/19/2014 13:32:16

def confirmation(self, cr, uid, ids, context={}): ir_model_data = self.pool.get('ir.model.data')

                'type': 'ir.actions.act_window',
        'view_type': 'form',
        'view_mode': 'form',
        'res_model': 'die.approval',}

            return v

def action_confirm_draft(self, cr, uid, ids, context={}):
            if  self.confirmation(cr, uid, ids, context) : 
                self.write(cr, uid, ids, {'state': 'sample','approved_by':uid})
                return True
                    return False

i want to display form after every stage is changed , for that i made tow function , the prob is the confirmation function is not returning form , either the stage is changed directly wat should i do ?

Sudhir Arya (SA)
On 5/3/13, 7:24 AM

Your code is ok for returning action but problem is that you are not returning action from action_confirm_draft method.

Try this:

def action_confirm_draft(self, cr, uid, ids, context=None):
    if context is None:
        context = {}
    val = self.confirmation(cr, uid, ids, context)
    if val: 
        self.write(cr, uid, ids, {'state': 'sample','approved_by':uid})
        return Val
        return False

hey sudhir thank you , the code is working , the form is being opened , but there is one problem , on discarding the form , den also the state is being changed .

mihir shah
on 5/3/13, 8:36 AM

That's your code. Your code changes the state before form is being opened. In what scenario/condition you want to change state?

Sudhir Arya (SA)
on 5/3/13, 8:43 AM

if the form is being filled and on saving data for model die.approval i want to changed the state else it should not change it

mihir shah
on 5/3/13, 8:47 AM

Then you should change your code. Removed self.write from action_confirm_draft method and override create method of die.approval object and in that method you can change state.

Sudhir Arya (SA)
on 5/3/13, 8:57 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 5/3/13, 5:43 AM
Seen: 1276 times
Last updated: 3/16/15, 8:10 AM