Odoo Help

Welcome!

This community 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.

1

how to display object form from function [Closed]

By
mihir shah
on 5/3/13, 5:43 AM 892 views

The Question has been closed

by
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
            else:
                    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 ?

1

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

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
    else:
        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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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