Skip to content

Commit

Permalink
[FIX] point_of_sale: set the payment date based on TZ
Browse files Browse the repository at this point in the history
If a user is in an early timezone (e.g. UTC-5), an order made on the
...-01 19:15:00 or, converted to UTC, as ...-02 00:15:00
fields.Date.today() returns the days ...-02 instead of ...-01
Use context_today to convert in the right timezone.

This slightly change the return format of _payment_fields to return a date
instead of a datetime.

Followup of 7272abe that was adding the timezone in the context

Closes odoo#22651
  • Loading branch information
celm1990 authored and mart-e committed Apr 11, 2018
1 parent fe7b9ab commit 2157540
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addons/point_of_sale/models/pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def _order_fields(self, ui_order):
}

def _payment_fields(self, ui_paymentline):
payment_date = ui_paymentline['name']
payment_date = fields.Date.context_today(self, fields.Datetime.from_string(payment_date))
return {
'amount': ui_paymentline['amount'] or 0.0,
'payment_date': ui_paymentline['name'],
'payment_date': payment_date,
'statement_id': ui_paymentline['statement_id'],
'payment_name': ui_paymentline.get('note', False),
'journal': ui_paymentline['journal_id'],
Expand Down Expand Up @@ -811,7 +813,7 @@ def _prepare_bank_statement_line_payment_values(self, data):
"""Create a new payment for the order"""
args = {
'amount': data['amount'],
'date': data.get('payment_date', fields.Date.today()),
'date': data.get('payment_date', fields.Date.context_today(self)),
'name': self.name + ': ' + (data.get('payment_name', '') or ''),
'partner_id': self.env["res.partner"]._find_accounting_partner(self.partner_id).id or False,
}
Expand Down

0 comments on commit 2157540

Please sign in to comment.