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

Why this else condition is excecuted every time after if condition is true ,any syntax error or logical error ,please need help. [Closed]

By
Odoo
on 6/18/14, 3:42 AM 545 views

The Question has been closed for reason: too subjective and argumentative

by
Odoo
on 06/30/2014 08:27:56

EDIT:

day_obj=self.read(cr,uid,ids,['date_of_join','current_date'],context=context)
             scheme_ids = self.pool.get('scheme.type.info').search(cr, uid, [], context=context)
             calc_vacation=self.pool.get('scheme.type.info').read(cr,uid,scheme_ids,['interval','criteria','interval1','salary'],context=context)

for cal_val in calc_vacation:
                
                 if total_days in range(cal_val['interval'],cal_val['interval1']):
                     msg=cal_val['criteria']
                     m=cal_val['salary']
                     break
                 else:
                        raise osv.except_osv(_('Hi!'), _('Please Add a category'))

 

 

##Error is resolved------------------------ Thanks...............

Wrong indention maybe? Are you sure the conditon is true?

René Schuster
on 6/18/14, 3:46 AM

yes condition is true..indention is correct

Odoo
on 6/18/14, 3:49 AM

Sorry, I cannot understand your code. It seem to me that calc_val is a list variable, how do you use as iterator variable? i.e. calc_vacation = ['a', 'b', 'c'] for calc_val in calc_vacation: print calc_val Output a b c If I understood cal_val['interval'] cannot work

Antonio M. Vigliotti
on 6/18/14, 5:10 AM
1
Antonio M. Vigliotti
On 6/18/14, 5:13 AM

Sorry, I did not undestand, before.

calc_vacation is a set of dictionary.

So cal_val in calc_vacation every iteration is a dictionary.

Then

1st loop fails because total_days's value 134 is not in range cal_val['interval']'s value 1 and cal_val['interval1']'s val 's value 100

 

Antonio M. Vigliotti

 

cal_val['interval'] is a number cal_val['interval1'] is also a number

Odoo
on 6/18/14, 5:55 AM

This is the out put------ day_obj#################### [{'current_date': '2014-06-18', 'date_of_join': '2014-02-04', 'id': 8}] scheme_ids################ [8, 9, 10] calc_vacation####################### [{'salary': 2500.0, 'interval1': 100, 'interval': 1, 'id': 8, 'criteria': 2}, {'salary': 3000.0, 'interval1': 200, 'interval': 101, 'id': 9, 'criteria': 3}, {'salary': 3500.0, 'interval1': 365, 'interval': 201, 'id': 10, 'criteria': 4}] total_days 134 ******************************88Inside Else**********8 ###################Inside if %%%%%%%%%%%%%%%%%% 134 ###################cal_val['interval'] %%%%%%%%%%%%%%%%%% 101 ###################cal_val['interval1'] %%%%%%%%%%%%%%%%%% 200

Odoo
on 6/18/14, 5:56 AM
0
Vũ Quốc Hoàng
On 6/20/14, 2:21 AM

The space before raise

0

Odoo

--Odoo --
1328
| 5 2 5
kerala, India
--Odoo --

Working as a Odoo Functional and Technical Expert

Odoo
On 6/20/14, 2:58 AM

@Libu Koshy: Else statement is executed because based on the above example condition first iteration value is failed. In else statement osv.except_osv is used its through message and for loop execution stops

Else statement is executed because based on the above example condition first iteration value is failed. In else statement osv.except_osv is used its through message and for loop execution stops

Odoo
on 6/20/14, 2:59 AM

About This Community

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

Question tools

5 follower(s)

Stats

Asked: 6/18/14, 3:42 AM
Seen: 545 times
Last updated: 3/16/15, 8:10 AM