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.


Onchange get weekday name

on 9/23/16, 4:26 AM 222 views

hi all

i have this field

class holidays_detail(models.Model):
    _name = 'holiday.detail'

    date_start = fields.Date(string='Start Date',required=True )   

     hari = fields.Char(string='Day')

i want when i choose date ini field date_start its onchange to field hari with value (weekday name ex :Sunday)

i have this method

def onchange_date(self, cr, uid, ids, date_start):
        res ={}       

         if date_start :
            a = datetime.strptime(date_start,"%Y-%m-%d")           

             if a :
                b = datetime.strftime(a, '%A')               

                res = {'hari': b }                

             return {'value': res}      

          return True

its work ! but when i save its getting error  like this

File "/home/susi/odoo/openerp-8.0/openerp/sql_db.py", line 234, in execute    res = self._obj.execute(query, params)

DataError: invalid input syntax for integer: "Friday"

LINE 1: ...('holiday_detail_id_seq'), 7, '2016-09-23', NULL, 'Friday', ...


anyone can help me what wrong with my code ? thanks before

Martin Varela
On 9/23/16, 10:32 AM

Check hari field on DB table, it seems to be an integer instead of char.

Did you initially defined the field as an integer? If so, restart the service and update the module. After that, the field should be defined as char in DB

thanks martin

on 9/26/16, 11:43 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)


Asked: 9/23/16, 4:26 AM
Seen: 222 times
Last updated: 9/26/16, 11:43 PM