You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.8 KiB

# © 2019 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import json
from odoo import http
from odoo.http import request
from odoo.http import Response
from datetime import datetime, date
from pytz import timezone
class Main(http.Controller):
@http.route("/transactions", auth='none', type='http',method=['GET'])
def check_method_get(self,**post):
headers = {'Content-Type': 'application/json'}
pos_sessions = request.env['pos.session'].sudo().search([
('state', '=', 'opened'),
('rescue', '=', False)], limit=1)
if post.get('datetime', ''):
date_get = post.get('datetime', '')
transaction_ids = request.env[
'pos.transaction'].sudo().search([('create_date', '>=', date_get)])
else:
today_datetime_utc = datetime.now()
today_datetime = datetime(
today_datetime_utc.year,
today_datetime_utc.month,
today_datetime_utc.day,
00,
00,
00)
transaction_ids = request.env[
'pos.transaction'].sudo().search([('create_date', '>=', today_datetime)])
balance_id = pos_sessions.config_id.balance_id
today_datetime_utc = datetime.now(timezone('UTC'))
if hasattr(today_datetime_utc, 'isoformat'):
date = today_datetime_utc.isoformat('T')[:19]
data = {
'balance_id': balance_id,
'date': date,
'transactions': transaction_ids.read(
['qrcode', 'balance_id', 'ean13', 'ean13_verif', 'date_iso'])
}
return Response(json.dumps(data), headers=headers)