Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
11552 Visualizzazioni

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

Avatar
Abbandona
Autore Risposta migliore

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)
Avatar
Abbandona
Risposta migliore

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.

Avatar
Abbandona
Autore

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.