تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
6628 أدوات العرض

Hi

I'm working with a report in RML, and data table of pos_order.
Using date_order field is set to 'timestamp' format.

Use the following format for the day, month, year:

 

datetime.datetime.strptime(pos_order.date_order, DEFAULT_SERVER_DATE_FORMAT).strftime('%d/%m/%Y')

but without result.

Another solution?

Thank You.

This is a snippet of my code:

report.py

def get_pos_data(self, form):
        pos_order_obj = self.pool.get('pos.order')
        pos_order_id = pos_order_obj.search(self.cr, self.uid, [
                                                             ('date_order','>=', period.date_start),
                                                             ('date_order','<=', period.date_stop)])
        pos_order_list = []
        for pos_order in pos_order_obj.browse(self.cr, self.uid, pos_order_id):
            res = {
                'date_pos' : time.strftime('%d') + '-' + datetime.strptime(pos_order.date_order, '%d-%m-%Y').strftime('%b').upper() + '-' + time.strftime('%Y')
            }
            pos_order_list.append(res)
        return pos_order_list

report.rml

<para style="P4">[[ obj['date_pos'] ]]</para>

الصورة الرمزية
إهمال
أفضل إجابة

Your field is in string format containing date in a format different from DEFAULT_SERVER_DATE_FORMAT. As I can understand from the "report.py" your field is in format "%d-%b-%Y" where the month will be converted to uppercase. Either change the format of the field in the 'report.py' or change the format string that you pass to strptime

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

Thank You Jordan Vrtanoski.

struct_time_convert = time.strptime(pos_order.date_order, '%Y-%m-%d %H:%M:%S')

date_time_convert = datetime.fromtimestamp(mktime(struct_time_convert))

date = date_time_convert.strftime('%d/%m/%Y')

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
يوليو 24
8537
0
أبريل 17
3227
1
أبريل 17
4605
2
نوفمبر 15
4962
0
مارس 15
4713