From b02afebd1e6f96eeb615dcb093aec63798079424 Mon Sep 17 00:00:00 2001 From: Mario Arias Badilla Date: Thu, 2 Jul 2015 01:53:56 +0200 Subject: [PATCH] [FIX] point_of_sale: payment date take into account user tz When you apply payment in POS, it takes current time for "date" field on bank statement line, but should use context_timestamp to take care of user timezone adjustments. Example: If user is in time zone GMT-6:00, then after 6:00pm all bank statement lines will be recorded with date of next day, and all closing reports and related accounting will be wrong! Fixes #2199 Closes #2200 --- addons/point_of_sale/point_of_sale.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 8f84809164f..ef316a51a3c 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -862,9 +862,14 @@ class pos_order(osv.osv): statement_line_obj = self.pool.get('account.bank.statement.line') property_obj = self.pool.get('ir.property') order = self.browse(cr, uid, order_id, context=context) + date = data.get('payment_date', time.strftime('%Y-%m-%d')) + if len(date) > 10: + timestamp = datetime.strptime(date, tools.DEFAULT_SERVER_DATETIME_FORMAT) + ts = fields.datetime.context_timestamp(cr, uid, timestamp, context) + date = ts.strftime(tools.DEFAULT_SERVER_DATE_FORMAT) args = { 'amount': data['amount'], - 'date': data.get('payment_date', time.strftime('%Y-%m-%d')), + 'date': date, 'name': order.name + ': ' + (data.get('payment_name', '') or ''), 'partner_id': order.partner_id and self.pool.get("res.partner")._find_accounting_partner(order.partner_id).id or False, }