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.
 
 
 

35 lines
1.3 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
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:
transaction_ids = request.env[
'pos.transaction'].sudo().search([])
balance_id = pos_sessions.config_id.balance_id
if hasattr(datetime.today(), 'isoformat'):
date = datetime.today().isoformat()
data = {
'balance_id': balance_id,
'date': date,
'transactions': transaction_ids.read(
['qrcode', 'balance_id', 'ean13', 'ean13_verif'])
}
return Response(json.dumps(data), headers=headers)