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.

0

Required fields problem in a model with different stages

By
rosey
on 11/25/13, 8:07 AM 1,246 views

I have five stages in hr.recruitment.

In each have many required fields.

I added required="true" in each field.

I added datas in the first stage & save. But it shows error that remaining stages required fields are empty.

I want the same procedure, But how can i solve the issue?

ie, Datas in the first stage added there, then save. Only when i click the second stage, required fileds of second stage give that time only.

After initial qualification, next first stage then second stage. In initial qualification both tab are invisible, when i click first stage the offer letter field should be required, when i click second stage the passport field should be required.

<page string="First Stage" attrs="{'invisible':[('state','=','draft')]}"> <group> <field name="offer_letter" required="1"/> </group> </page>

<page string="Second Stage" attrs="{'invisible':[('state','in',('draft','pending'))]}"> <group> <field name="passport" required="1"/> </group> </page>

0
Ayyappan
On 11/25/13, 8:41 AM

Try below one:

<field name="field_2" attrs="{'required':[('stage','=','two')]}"/>

If stage is in second, field_2(second field) must be in required. Otherwise should be in un-required state.


I have done the below code depends on state:

<page string="First Stage" attrs="{'invisible':[('state','=','draft')]}"> 
    <group> 
        <field name="offer_letter" attrs="{'required':[('state','=','draft')]}"/> 
    </group> 
</page>
<page string="Second Stage" attrs="{'invisible':[('state','in',('draft','pending'))]}"> 
    <group> 
        <field name="passport" attrs="{'required':[('state','=','pending')]}"/> 
    </group> 
</page>

In draft state: "offer_letter" field is required In pending state: "passport" field is required


In pyhton:

_columns = { 
'stage': fields.selection([
            ('stage_1', 'Start Qualification'),
            ('stage_2', 'First Qualification'),
            ('stage_3', 'Second qualification'),
            ('stage_4', 'Before finalisation'),
            ('stage_5', 'Finalised'),            
            ], 'Stage'
            ),
'field_1': fields.char('Field_1', size=64),
'field_2': fields.char('Field_2', size=64),
'field_3': fields.char('Field_3', size=64),
'field_4': fields.char('Field_4', size=64),
'field_5': fields.char('Field_5', size=64),
}
_defaults = {
        'stage': 'stage_1',     
        }

In xml:

<page string="First Stage"> 
    <group> 
        <field name="field_1" attrs="{'required':[('stage','=','stage_1')]}"/> 
    </group> 
</page>
<page string="Second Stage"> 
    <group> 
        <field name="field_2" attrs="{'required':[('stage','=','stage_2')]}"/> 
    </group> 
</page>  
<page string="Third Stage"> 
    <group> 
        <field name="field_3" attrs="{'required':[('stage','=','stage_3')]}"/> 
    </group> 
</page>  
<page string="Fourth Stage"> 
    <group> 
        <field name="field_4" attrs="{'required':[('stage','=','stage_4')]}"/> 
    </group> 
</page>  
<page string="Fifth Stage"> 
    <group> 
        <field name="field_5" attrs="{'required':[('stage','=','stage_5')]}"/> 
    </group> 
</page>

If you use like this, in your status bar consists 5 stages. Beginning of the flow stage is stage_1(Start Qualification) in this stage Field_1 is required, then when you click the stage_2(First Qualification) - Field_2 is required..., and the flow goes likewise.

Uncaught Error: Unknown field stage in domain [["stage","=","two"]]. Its shows the error

Remya
on 11/26/13, 8:19 AM

Above i just gave example code. If you need full functionality code, give me your files or fields details.

Ayyappan
on 11/26/13, 8:28 AM

i updated my question, please check it.

Remya
on 11/26/13, 8:56 AM

Any solution?

Remya
on 11/26/13, 10:11 AM

Can you please explain the stage? I think state field is stage. Here i explain with state.

Ayyappan
on 11/26/13, 12:13 PM

Ok its working.

Remya
on 11/27/13, 12:14 AM

Still have a doubt. I have three stage with same status type. ie, third stage, fourth stage, fifth stage. each three is status=hired. But each three stage has different fields. What will do? Please reply

rosey
on 11/27/13, 3:42 AM

In same state it is not possible. You just add another two states. Otherwise in hired state all remaining fields will be in required state.

Ayyappan
on 11/27/13, 4:24 AM

But my requirement is that. What will do? Any way to solve this?

rosey
on 11/27/13, 4:29 AM

After second stage what you want to do? Give a summary of your work. Otherwise how can i help you. In the beginning of the third stage you want one field should be required. right? and you will save the form another field should be required. is it correct?

Ayyappan
on 11/27/13, 7:17 AM

I'll explain you. I have 5 stages. In each stage i have some required field. First stage status=draft, 2nd,3rd are pending, 4th,5th are hired. In 2nd stage i have three required fields and in 3rd stage 5 required fields. same as in 4th&5th. How can i update my code? <field name="passport" attrs="{'required':[('state','=','pending')]}"/> if i give like this, it will affect 2nd & 3rd, right?

rosey
on 11/27/13, 7:30 AM

What is the difference between 2nd & 3rd stage, and 4th & 5th stage? How do you mention it is 2nd and 3nd stage? Is there any process between 2nd and 3rd?

Ayyappan
on 11/27/13, 7:39 AM

Yes. Stage names are different. 2nd=First Qualification---here we check some details and add it. if he qualified. then goes to 3rd=Second qualification---here we add some other details of the candidate. 4th=Before finalisation---here we add salary details. 5th=Finalised---here add bank details &some datas.

rosey
on 11/27/13, 7:45 AM

Both the 2nd&3rd 4th&5th different. Only status is same. 2nd&3rd-pending. 4th&5th-hired.

rosey
on 11/27/13, 7:46 AM

Ok. Here you have mentioned "First Qualification", "Second qualification", "Before finalisation", "Finalised". right? Is there any field to get this value? How the process goes to "Second qualification" from "First Qualification"? Do you click any button to change the stage?

Ayyappan
on 11/27/13, 7:52 AM

On status bar in the hr.applicant

rosey
on 11/27/13, 7:53 AM

In status bar look like this? First Qualification>Second qualification>Before finalisation>Finalised. Is it selection field?

Ayyappan
on 11/27/13, 7:55 AM

Just like that.

rosey
on 11/27/13, 7:59 AM

Give me the status bar field name and what are the fields you want to hide in the particular state.

Ayyappan
on 11/27/13, 8:04 AM

it is a large portion, and is with my senior. i just want to find out a solution for this. Can you just image some fields,please?

rosey
on 11/27/13, 8:06 AM

It is fine. Another help. How can i hide a <page> string like this? I have five page tab in the same <notebook>. 1st page is seen in stage_1=draft. 2nd page is seen i stage_2=pending. 3nd page is seen i stage_3=pending. 4th page is seen in stage_4=hired. 5nd page is seen i stage_5=hired. Stage names are same as above. Can you please suggest any code?

Remya
on 11/27/13, 12:36 PM

Hi Remya, I want to know about stage and state. is it same field? or different field? Do you mention a state is stage?

Ayyappan
on 11/27/13, 2:01 PM

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

1 follower(s)

Stats

Asked: 11/25/13, 8:07 AM
Seen: 1246 times
Last updated: 3/16/15, 8:10 AM