Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
6607 Zobrazení

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>

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Autor Nejlepší odpověď

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')

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
čvc 24
8535
0
dub 17
3223
1
dub 17
4598
2
lis 15
4958
0
bře 15
4711