Odoo Help


how to display object form from function [Closed]

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

The Question has been closed

Sudhir Arya (ERP Harbor Consulting Services)
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 (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
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 (ERP Harbor Consulting Services)
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 (ERP Harbor Consulting Services)
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: 1347 times
Last updated: 3/16/15, 8:10 AM