[IMP] pms: add add exp date to jwt data

This commit is contained in:
miguelpadin
2021-08-05 23:06:32 +02:00
committed by Darío Lodeiros
parent 78da297eb4
commit 41a1df4fda
14 changed files with 106 additions and 25 deletions

View File

@@ -1,2 +1,3 @@
from . import res_users
from . import jwt_access_token
from . import pms_reservation

View File

@@ -7,10 +7,7 @@ class JwtAccessToken(models.Model):
_name = "jwt_provider.access_token"
_description = "Store user access token for one-time-login"
token = fields.Char(
"Access Token",
required=True
)
token = fields.Char("Access Token", required=True)
user_id = fields.Many2one(
comodel_name="res.users",
string="User",

View File

@@ -0,0 +1,61 @@
import json
from odoo import fields, models
class PmsReservation(models.Model):
_inherit = "pms.reservation"
pwa_action_buttons = fields.Char(compute="_compute_pwa_action_buttons")
def _compute_pwa_action_buttons(self):
"""Return ordered button list, where the first button is
the preditive action, the next are active actions:
- "Assign": Predictive: Reservation by assign
Active- Idem
- "checkin": Predictive- state 'confirm' and checkin day
Active- Idem and assign
- "checkout": Predictive- Pay, onboard and checkout day
Active- Onboard and checkout day
- "Paymen": Predictive- Onboard and pending amount > 0
Active- pending amount > 0
- "Invoice": Predictive- qty invoice > 0, onboard, pending amount = 0
Active- qty invoice > 0
- "Cancel": Predictive- Never
Active- state in draft, confirm, onboard, full onboard
"""
for reservation in self:
active_buttons = {}
for k in ["Assign", "Checkin", "Checkout", "Payment", "Invoice", "Cancel"]:
if k == "Assign":
if reservation.to_assign:
active_buttons[k] = True
else:
active_buttons[k] = False
elif k == "Checkin":
if reservation.allowed_checkin:
active_buttons[k] = True
else:
active_buttons[k] = False
elif k == "Checkout":
if reservation.allowed_checkout:
active_buttons[k] = True
else:
active_buttons[k] = False
elif k == "Payment":
if reservation.folio_pending_amount > 0:
active_buttons[k] = True
else:
active_buttons[k] = False
elif k == "Invoice":
if reservation.invoice_status == "to invoice":
active_buttons[k] = True
else:
active_buttons[k] = False
elif k == "Cancel":
if reservation.allowed_cancel:
active_buttons[k] = True
else:
active_buttons[k] = False
reservation.pwa_action_buttons = json.dumps(active_buttons)

View File

@@ -1,7 +1,7 @@
import logging
from odoo import _, api, fields, models
from odoo.exceptions import AccessDenied, ValidationError
from odoo import api, fields, models
from odoo.exceptions import AccessDenied
from ..lib_jwt.validator import validator