Odoo Help


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.


How to made default state as To Submit while creating Leave Request?

Sairam Bandaru
on 10/15/15, 6:33 AM 290 views

I used defaults attribute and made state field value as 'draft' and once I saved the form its going to To Approve state

Help me out to resolve this 

Thanks in Advance

Sairam Bandaru
On 10/16/15, 2:36 AM

Hi Found solution that is happening because of the work flow defined for the Leave Request

Workflow starting from the Confirm stage so that was happen now I changed workflow to start at the to Submit state now working fine.



Axel Mendoza

--Axel Mendoza--
| 6 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 10/15/15, 6:43 AM

Just override the create method of your model, like:

from openerp import api, models 
class leave(models.Model)
_inherit = "module.model_leave"

@api.returns('self', lambda value: value.id)
def create(self, vals):
vals['state'] = 'approve'
return super(leave, self).create(vals)

In Create method state value coming as 'draft' only but once saved the form its going to confirm state

Sairam Bandaru
on 10/15/15, 7:04 AM

The create method get executed when the record is about to be saved, so you will get displayed the record in the form as draft using your defaults and when the user clic save the state field will became approve in the create method.

Axel Mendoza
on 10/15/15, 7:07 AM

Due to workflows defined for the object create state value is not effecting

Sairam Bandaru
on 10/16/15, 2:37 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)


Asked: 10/15/15, 6:33 AM
Seen: 290 times
Last updated: 10/16/15, 3:01 AM