Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
11556 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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)
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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.