From 3d88cb1d65af3a13d0ca60ce9b4bb88ed77ec089 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Wed, 17 Jun 2009 16:19:14 +0200 Subject: [PATCH] [IMP] point_of_sale: receipt report: better date formatting bzr revid: olt@tinyerp.com-20090617141914-q45nj9rw1jf3zs34 --- addons/point_of_sale/report/pos_receipt.py | 7 +++++++ addons/point_of_sale/report/pos_receipt.rml | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/report/pos_receipt.py b/addons/point_of_sale/report/pos_receipt.py index 687519d2457..69f4bd706c2 100644 --- a/addons/point_of_sale/report/pos_receipt.py +++ b/addons/point_of_sale/report/pos_receipt.py @@ -22,6 +22,7 @@ import time from report import report_sxw +from mx.DateTime.ISO import ParseAny import pooler @@ -35,11 +36,17 @@ class order(report_sxw.rml_parse): self.localcontext.update({ 'time': time, + 'dformat': '%Y/%m/%d %H:%M:%S', 'disc': self.discount, 'net': self.netamount, + 'formatdate': self.formatdate, 'address': partner.address and partner.address[0] or False, }) + def formatdate(self, datestr): + dateobj = ParseAny(datestr) + return dateobj.strftime(self.localcontext['dformat']) + def netamount(self, order_line_id): sql = 'select (qty*price_unit) as net_price from pos_order_line where id = %s' self.cr.execute(sql, (order_line_id,)) diff --git a/addons/point_of_sale/report/pos_receipt.rml b/addons/point_of_sale/report/pos_receipt.rml index 75b5ce3f01e..067d775db2f 100644 --- a/addons/point_of_sale/report/pos_receipt.rml +++ b/addons/point_of_sale/report/pos_receipt.rml @@ -83,8 +83,8 @@ Tel : [[ address and address.phone ]] E-mail : [[ address and address.email ]] Salesman : [[ o.salesman_id.name ]] - Sale Date : [[ o.date_order ]] - Receipt Printing Date : [[ time.strftime('%d/%m/%Y %H:%M') ]] + Sale Date : [[ formatdate(o.date_order) ]] + Receipt Printing Date : [[ time.strftime(dformat) ]]