Openbravo Issue Tracking System - Retail Modules
View Issue Details
0041486Retail ModulesWeb POSpublic2019-07-30 14:512019-08-07 08:02
aaroncalero 
alekosmp86 
highmajoralways
closedfixed 
5
 
RR19Q4 
marvintm
No
0041486: Approvals don't work in offline mode when the approval is a complex object
The OB.UTIL.Approval.requestApproval API supports approvals passed as single strings, and also as objects (with approval, message and optional params).
When a call to requestApproval is done in offline mode with an object approval, it will always return the message "<User> does not have privileges to approve this action.
Check the code of the fail function in OB.UTIL.checkApproval:
https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/file/tip/web/org.openbravo.retail.posterminal/js/utils/ob-utilitiesuipos.js#l594 [^]

The approval is compared "as is" against the saved permissions, which is wrong.
Instead of checking the approval "as is":
if (_.contains(JSON.parse(supervisor.get('permissions')), perm)) {

Get from 'perm' the real approval and then check that approval on the saved permissions:
var approvalToCheck = (typeof (perm) === 'object' ? perm.approval : perm);
if (JSON.parse(user.get('terminalinfo')).permissions[approvalToCheck]) {


Note: The same code appears 3 times on the same function.
No tags attached.
diff Issue41486.diff (2,032) 2019-07-30 15:01
https://issues.openbravo.com/file_download.php?file_id=13185&type=bug
diff Issue41486_q1.diff (2,194) 2019-07-30 15:03
https://issues.openbravo.com/file_download.php?file_id=13186&type=bug
Issue History
2019-07-30 14:51aaroncaleroNew Issue
2019-07-30 14:51aaroncaleroAssigned To => Retail
2019-07-30 14:51aaroncaleroResolution time => 1565647200
2019-07-30 14:51aaroncaleroTriggers an Emergency Pack => No
2019-07-30 15:01aaroncaleroFile Added: Issue41486.diff
2019-07-30 15:03aaroncaleroFile Added: Issue41486_q1.diff
2019-08-01 20:54alekosmp86Assigned ToRetail => alekosmp86
2019-08-02 20:02hgbotCheckin
2019-08-02 20:02hgbotNote Added: 0113794
2019-08-02 20:02hgbotStatusnew => resolved
2019-08-02 20:02hgbotResolutionopen => fixed
2019-08-02 20:02hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/31963d7f3ee66c6b6e52c59e19773d179eae9cc5 [^]
2019-08-07 08:02marvintmReview Assigned To => marvintm
2019-08-07 08:02marvintmStatusresolved => closed
2019-08-07 08:02marvintmFixed in Version => RR19Q4

Notes
(0113794)
hgbot   
2019-08-02 20:02   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 31963d7f3ee66c6b6e52c59e19773d179eae9cc5
Author: Alejandro <alekosmp86 <at> gmail.com>
Date: Thu Aug 01 16:07:23 2019 -0400
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/31963d7f3ee66c6b6e52c59e19773d179eae9cc5 [^]

Fixed issue 41486: When in offline mode, if the approval is a complex object, then
the proper value of the approval is taken from it.

---
M web/org.openbravo.retail.posterminal/js/utils/ob-utilitiesuipos.js
---