Odoo Help


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

Sairam Bandaru
on 10/15/15, 6:33 AM 747 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--
| 7 8 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 and 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

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

2 follower(s)


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