Odoo Help


Split value in char field & convert into into integer using python code

on 4/24/14, 4:23 AM 2,950 views

I want to know, how to split value entered in char field and convert each values into integer.

I have a textbox, when i enter date as 1428.1.2. I want to split date (.)

My code is

for self_data in self.browse(cr, uid, ids, context=context):

islamic_date = self_data.islamic_date islamic_date = '%.2f' % islamic_date list = islamic_date.split('.') yr = islamic_date(int(list[0])) mth = islamic_date(int(list[1])) day = islamic_date(int(list[2])) Hijri2Gregorian(yr,mth,day)

return res

_columns = { 'islamic_date' : fields.char('Islamic Date'), 'english_date' : fields.function(_get_hijri_date,type='date', select=True,string='English Date'), }

Is the code right?


Hardikgiri Goswami

--Hardikgiri Goswami--
| 2 1 5
Rajkot, India
--Hardikgiri Goswami--

OpenERP/Odoo Customization/Integration Expert / Python Programmer

Email : hardikgiri.goswami@gmail.com

Skype ID : hardikgiri.goswami

Hardikgiri Goswami
On 4/24/14, 7:37 AM

Just Remove this line from your code.

islamic_date = '%.2f' % islamic_date

I removed and work, but still error.

on 4/24/14, 7:45 AM

yr = islamic_date(str(list[0])) TypeError: 'unicode' object is not callable Error occured

on 4/24/14, 7:49 AM

Because there is no function named islamic_date(). and islamic_date is string field. It is not a FUNCTION. so you can not do islamic_date(str(list[0])).

Hardikgiri Goswami
on 4/24/14, 10:53 AM

you can do something like this yr = int(list[0]) mth = int(list[1]) day = int(list[2])

Hardikgiri Goswami
on 4/24/14, 10:55 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

0 follower(s)


Asked: 4/24/14, 4:23 AM
Seen: 2950 times
Last updated: 3/16/15, 8:10 AM