Skip to content
Permalink
Browse files

[FIX] pos_hr: remove redundant close button

Because of a bug the close-button for the point of sale session was not
visible anymore in the top-right button. Instead of fixing the problem a
close button was previously added to the lock-screen, making the
lockscreen useless.
This commit fixes the initial situation where the lock-screen can only
be left by logging in and the close button is visible in the top-right
of the session for the session manager.

Revert "[IMP] point_of_sale: Navigation as employee from frontend to backend."

This reverts commit 987951a.
  • Loading branch information...
switch87 committed Aug 5, 2019
1 parent 68b0f9c commit 0dc86f70efb770487214dd3acd63d681c52e5813
@@ -1,3 +1,5 @@
/* ********* Login Screen ********* */

.pos .login-overlay{
position: fixed;
left: 0;
@@ -36,22 +38,17 @@
font-family: 'Lato';
}
.pos .login-title{
height: 40%;
height: 55%;
vertical-align: middle;
line-height: 5;
font-size: larger;
}
.pos .login-body{
height:37%;
}

.pos .login-footer{
height:18%;
height:33%;
}

.pos .login-element{
float: left;
width: 40%;
width: 45%;
height: 60%;
}
.pos .login-barcode-img{
@@ -73,11 +73,6 @@ var LoginScreenWidget = ScreenWidget.extend({
self.unlock_screen();
});
});

this.$('.close-session').click(function() {
self.gui.close();
});

this._super();
},

@@ -0,0 +1,96 @@
odoo.define('pos_hr.tour.login_with_employees', function (require) {
"use strict";

var Tour = require("web_tour.tour");

function generate_keypad_steps(amount_str, keypad_selector) {
var steps = [];
var i;
for (i = 0; i < amount_str.length; ++i) {
var current_char = amount_str[i];
steps = steps.concat([{
content: 'press ' + current_char + ' on payment keypad',
trigger: keypad_selector + ' .input-button:contains("' + current_char + '"):visible'
}]);
}

return steps;
}

function generate_pin_keypad_steps(pin) {
return generate_keypad_steps(pin, '.popup-password');
}

function login_with_employee(name, pin) {
var steps = [{
content: 'Click on Select Cashier',
trigger: '.select-employee',
run: 'click',
}, {
content: 'Select ' + name,
trigger: '.selection-item:contains("' + name + '")'
}];
if (pin !== false) {
steps = steps.concat(generate_keypad_steps(pin, '.popup-password'));
steps = steps.concat([{
content: 'Confirm password',
trigger: '.popup-password .confirm',
run: 'click',
}]);

}
return steps;

}

var steps = [{
content: 'waiting for loading to finish',
trigger: 'body:has(.loader:hidden)',
run: function () {},
}]

// Login with an employee with no manager rights
// Check if close button is hidden
// Check if price control is disabled
steps = steps.concat(login_with_employee('Abigail Peterson', false));
steps = steps.concat([{
content: 'Check close button hidden',
trigger: 'body:not(.header-button:contains("Close"))',
run: function() {},
}, {
content: 'Check price control is disabled',
trigger: '.mode-button:contains("Price").disabled-mode',
run: function() {},
}]);

// Lock sression and check there is no close session button in the lockscreen
steps = steps.concat([{
content: 'Lock session',
trigger: '.fa-unlock',
run: 'click',
}, {
content: 'Check lock-window is shown without close button',
trigger: '.login-overlay:not(.close-session)',
run: function(){},
}]);

// Login with an admin
// check price control is enabled
// Close the session with the visible close button
steps = steps.concat(login_with_employee('Mitchell Admin', '0000'));
steps = steps.concat([{
content: 'Check price control is enabled',
trigger: 'body:not(.mode-button:contains("Price").disabled-mode)',
run: function() {},
}, {
content: 'Check close button visible, click it',
trigger: '.header-button:contains("Close")',
run: 'click',
}, {
content: 'Confirm closing',
trigger: '.header-button.confirm',
run: 'click',
}]);

Tour.register('pos_hr', { test: true, url: '/pos/web' }, steps);
});
@@ -14,11 +14,6 @@
<button class="login-button select-employee">Select Cashier</button>
</span>
</div>
<div class="login-footer">
<small>
<button class="login-button close-session">Close session</button>
</small>
</div>
</div>
</div>
</t>
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import test_frontend
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.tests import tagged, HttpCase

@tagged('post_install', '-at_install')
class TestFrontend(HttpCase):
def test_login_with_employees(self):
env = self.env(user=self.env.ref('base.user_admin'))
journal_obj = env['account.journal']
account_obj = env['account.account']

self.main_company = env.ref('base.main_company')
# set the company currency to USD, otherwise it will assume
# euro's. this will cause issues as the sales journal is in
# USD, because of this all products would have a different
# price
self.main_company.currency_id = env.ref('base.USD')

self.main_pos_config = env.ref('point_of_sale.pos_config_main')

self.account_receivable = account_obj.create({'code': 'X1012',
'name': 'Account Receivable - Test',
'user_type_id': env.ref('account.data_account_type_receivable').id,
'reconcile': True})
field = env['ir.model.fields']._get('res.partner', 'property_account_receivable_id')
env['ir.property'].create({'name': 'property_account_receivable_id',
'company_id': self.main_company.id,
'fields_id': field.id,
'value': 'account.account,' + str(self.account_receivable.id)})

cash_journal = journal_obj.create({
'name': 'Cash Test',
'type': 'cash',
'company_id': self.main_company.id,
'code': 'CSH',
'sequence': 10,
})

test_sale_journal = journal_obj.create({'name': 'Sales Journal - Test',
'code': 'TSJ',
'type': 'sale',
'company_id': self.main_company.id})

# needed because tests are run before the module is marked as
# installed. In js web will only load qweb coming from modules
# that are returned by the backend in module_boot. Without
# this you end up with js, css but no qweb.
env['ir.module.module'].search([('name', '=', 'point_of_sale')], limit=1).state = 'installed'
env['ir.module.module'].search([('name', '=', 'pos_hr')], limit=1).state = 'installed'

self.main_pos_config.write({
'journal_id': test_sale_journal.id,
'invoice_journal_id': test_sale_journal.id,
'payment_method_ids': [(0, 0, { 'name': 'Cash',
'is_cash_count': True,
'cash_journal_id': cash_journal.id,
'receivable_account_id': self.account_receivable.id,
})],
'module_pos_hr': True,
'restrict_price_control': True,
})
env['hr.employee'].search([('name', '=', 'Mitchell Admin')], limit=1).pin = '0000'

# open a session, the /pos/web controller will redirect to it
self.main_pos_config.open_session_cb()

self.start_tour("/pos/web?config_id=%d" % self.main_pos_config.id, 'pos_hr', login="admin")
@@ -10,5 +10,11 @@
<script type="text/javascript" src="/pos_hr/static/src/js/chrome.js"></script>
</xpath>
</template>

<template id="assets_tests" name="POS HR Assets Tests" inherit_id="web.assets_tests">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_hr/static/src/js/tours/pos_hr.js"></script>
</xpath>
</template>
</odoo>

0 comments on commit 0dc86f7

Please sign in to comment.
You can’t perform that action at this time.