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.

1

Openerp Import date format

By
Prakash
on 11/13/13, 11:18 AM 2,825 views

In Openerp Import options Default Date format supports YYYY-MM-DD and Header Options Must

How to change the date format for Particular table (only) and auto fill Header details

0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 3/10/14, 10:49 AM

Openerp 7 the below code (overridden ORM load method to change the Import Data format

def checkdatatype(self, cr, uid, date, context=None):
       dateValue = False
       data = {}
       for format in ['%Y%m%d']:
            try:
                result = datetime.datetime.strptime(date, format)
                datatype = (date == result.strftime(format)) 
            except:
                pass
       if  datatype:
           msg = 'Date Type'
           data['msg'] = 'Date Type'
       else:
            msg = 'other'
            data['msg'] = 'other'
       return data     

    def load(self, cr, uid, fields, data, context=None):
        Listalldata = []
        for value in data:
            Listdata = list(value)
            Listalldata.append(Listdata)
        for listvalue in Listalldata:        
            for i, val in enumerate(listvalue):
                res = self.checkdatatype(cr, uid, str(val), context=context)
                if res['msg']=='Date Type':
                     listvalue[i] = datetime.datetime.strptime(val, '%Y%m%d').strftime('%Y-%m-%d')
        data = []
        for val in Listalldata:
            Listalldata = tuple(val)
            data.append(Listalldata)         
        return super(model_class_name, self).load(cr, uid, fields, data, context=context)
0
OpenERP4You
On 11/14/13, 3:26 AM

You can change by check the menu " Administration -> Translation -> Languages -> Click Language and check format. In this select the language and switch to form view then there u will see the field date format . You can change there after changing just relogin to the database . Job Done.

Hope this will help you.

Using this options Date Format changed in the form view {For example in Sale order Date format changed based on settings). But Import data in OpenERP always support in the format YYYY-MM-DD how to change the format in import data.

Prakash
on 11/22/13, 9:48 AM

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

0 follower(s)

Stats

Asked: 11/13/13, 11:18 AM
Seen: 2825 times
Last updated: 3/16/15, 8:10 AM