New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master pos one user per pos #28567

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
9 participants
@switch87
Contributor

switch87 commented Nov 12, 2018

pos.config

https://drive.google.com/a/odoo.com/file/d/1NimIRaO_c5Z_l0xs-0cPRXlgwvX174kV/view?usp=drivesdk

  • Add a checkbox : "Login with Employees"
  • If set to TRUE, an "Allowed Employees" many2many appear
  • If employees many2many is empty, all employees can log on this PoS (Is it possible to add a tooltip on the field Allowed Employees ?)
  • If set to FALSE, can only log in with users (that have the PoS User access right)

hr.employee

PoS session

  • on startup filter on allowed employees.

Open the PoS if "Log in with Employees" = FALSE

  • Same behaviour than now, when I open the PoS, I'm logged in with the user, I can directly start working
  • If I click on the user name, I can choose to connect with another user
  • The button to close the session is visible

Open he PoS if "Log in with Employees" = TRUE

  • When I open the PoS, the first screen I see is the login screen.
  1. I choose my employee and enter my pin code (if there is pin code on my employee, otherwise not required) (I can only see employees that have access to that PoS)
  2. I scan my barcode
  3. I scan my rfid card (future development)
  • When I click on the employee name, I can log in with another employee
  • If the employee is linked to a user that has the pos user/manager access right, I can see the button the close the session. Otherwise I cannot close the session (and thus cannot access backend).
  • Add field employee on all records created by PoS (and replace the field user by that one) (on pos.orders)

Lock Screen

@switch87 switch87 force-pushed the odoo-dev:master-pos-one-user-per-pos branch from f78e4b4 to f0b1ef4 Nov 20, 2018

@robodoo robodoo removed the CI 🤖 label Nov 20, 2018

@switch87 switch87 force-pushed the odoo-dev:master-pos-one-user-per-pos branch from f0b1ef4 to 467e5d5 Nov 20, 2018

@robodoo robodoo added the CI 🤖 label Nov 20, 2018

@@ -369,3 +389,26 @@ def _update_employee_manager(self, manager_id):
('parent_id', '=', department.manager_id.id)
])
employees.write({'parent_id': manager_id})
@api.model_cr_context
def _init_column(self, column_name):

This comment has been minimized.

@hmo-odoo

hmo-odoo Nov 22, 2018

Contributor

Hello @switch87 ,

what's purpose of this method in department model ? department model does not have "barcode", "pin" columns.

This comment has been minimized.

@switch87

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Nov 22, 2018

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Nov 29, 2018

@jorenvo

I'm sick today so I didn't do a full in-depth review yet. But in case you're anxious to get started here are already some comments you can start working on.

Show resolved Hide resolved addons/point_of_sale/models/pos_order.py Outdated
Show resolved Hide resolved addons/point_of_sale/models/pos_order.py Outdated
Show resolved Hide resolved addons/point_of_sale/models/pos_order.py Outdated
Show resolved Hide resolved addons/hr/models/hr.py
Show resolved Hide resolved addons/hr/models/hr.py Outdated
Show resolved Hide resolved addons/point_of_sale/static/src/js/chrome.js Outdated
Show resolved Hide resolved addons/point_of_sale/static/src/js/chrome.js Outdated
Show resolved Hide resolved addons/point_of_sale/static/src/js/chrome.js Outdated
Show resolved Hide resolved addons/point_of_sale/static/src/js/gui.js Outdated
Show resolved Hide resolved addons/point_of_sale/static/src/js/gui.js Outdated

@pha-odoo pha-odoo force-pushed the odoo-dev:master-pos-one-user-per-pos branch from 050dd1b to a1daa8a Dec 5, 2018

@robodoo robodoo removed the CI 🤖 label Dec 5, 2018

@@ -139,6 +139,10 @@
<field name="company_id" groups="base.group_multi_company"/>
<field name="user_id" string="Related User"/>
</group>
<group string="Login Information" name="identification_group">
<field name="barcode"/>

This comment has been minimized.

@antonylesuisse

antonylesuisse Dec 5, 2018

Contributor

<button type="object" name="_generate_random_barcode" attrs="{'invisible':[('barcode','!=','')]}"/>

    def _default_random_barcode(self):
	for i in self: i.barcode = "".join(choice(digits) for i in range(8))
@@ -174,6 +174,7 @@ def _compute_iface_start_categ_domain_ids(self):
module_pos_reprint = fields.Boolean(string="Reprint Receipt")
is_posbox = fields.Boolean("PosBox")
is_header_or_footer = fields.Boolean("Header & Footer")
module_pos_hr = fields.Boolean(help="If not enabled, only users in the 'Point of Sale' group can log in.")

This comment has been minimized.

@antonylesuisse

antonylesuisse Dec 5, 2018

Contributor

Show employee selection screen

loaded: function(self,users){
self.user = users[0];
self.user.role = 'manager';
self.employee = self.user;

This comment has been minimized.

@antonylesuisse
@@ -55,6 +55,8 @@ exports.PosModel = Backbone.Model.extend({
this.company = null;
this.user = null;
this.users = [];
this.employee = null;

This comment has been minimized.

@antonylesuisse

antonylesuisse Dec 5, 2018

Contributor

doctring

var employee = {
name:
id:
barcode
user_id
pin
}

[hr.employee_id, hr_employee_name]

@@ -2131,7 +2107,8 @@ exports.Order = Backbone.Model.extend({
pos_session_id: this.pos_session_id,
pricelist_id: this.pricelist ? this.pricelist.id : false,
partner_id: this.get_client() ? this.get_client().id : false,
user_id: this.pos.get_cashier().id,
user_id: this.pos.user.id,

This comment has been minimized.

@antonylesuisse

antonylesuisse Dec 5, 2018

Contributor

wrong it should be employee.user_id if employee is selected and has a user_id else this.pos.user.id

@@ -2131,7 +2107,8 @@ exports.Order = Backbone.Model.extend({
pos_session_id: this.pos_session_id,
pricelist_id: this.pricelist ? this.pricelist.id : false,
partner_id: this.get_client() ? this.get_client().id : false,
user_id: this.pos.get_cashier().id,
user_id: this.pos.user.id,
employee_id: this.pos.config.module_pos_hr ? this.pos.get_cashier().id : false,

This comment has been minimized.

@antonylesuisse

antonylesuisse Dec 5, 2018

Contributor

employee_id: this.employee.id

class PosConfig(models.Model):
_inherit = 'pos.config'
employees = fields.Many2many(

This comment has been minimized.

@antonylesuisse

antonylesuisse Dec 5, 2018

Contributor

employees_ids

class PosOrder(models.Model):
_inherit = "pos.order"
employee_id = fields.Many2one(

This comment has been minimized.

@antonylesuisse

antonylesuisse Dec 5, 2018

Contributor

employee_id = fields.Many2one( 'hr.employee',string='Employee',states={'done': [('readonly', True)], 'invoiced': [ ('readonly', True)]}, help="Person who uses the cash register. It can be a reliever, a student or an interim employee.",)

@switch87 switch87 force-pushed the odoo-dev:master-pos-one-user-per-pos branch 3 times, most recently from 0e0bfd4 to 34f934b Dec 5, 2018

@robodoo robodoo added the CI 🤖 label Dec 5, 2018

@@ -244,6 +255,7 @@ def _sync_user(self, user):
vals['tz'] = user.tz
return vals

This comment has been minimized.

@jorenvo

jorenvo Dec 6, 2018

Contributor
Suggested change Beta
Show resolved Hide resolved addons/point_of_sale/data/point_of_sale_demo.xml
}
.pos .login-button{
font-size: initial;
height: -webkit-fill-available;

This comment has been minimized.

@jorenvo

jorenvo Dec 6, 2018

Contributor

This is a webkit specific value. Is there no better cross-browser way to do what you want here?

this.show();
} else {
this.hide();
}

This comment has been minimized.

@jorenvo

jorenvo Dec 6, 2018

Contributor
Suggested change Beta
}
}
return this._super();

Call this._super(); here as well. It's defined by web.Widget, which PosBaseWidget inherits from. Ideally you should return it as well, because start is expected to return a Deferred.

this.icon = options.icon[0];
this.color = options.icon[1];
this.icon_mouseover = options.icon_mouseover[0];
this.color_mouseover = options.icon_mouseover[1];

This comment has been minimized.

@jorenvo

jorenvo Dec 6, 2018

Contributor

Okay, so now you split it up into two properties on the widget which is good. But what's the reason you're still passing it in as an Array of 2 elements via options? It's bit weird for developers who want to use this widget in the future.

'title':_t('Change Cashier'),})
.then(function(employee){
self.pos.set_cashier(employee);
$('.username').text(employee.name);

This comment has been minimized.

@jorenvo

jorenvo Dec 6, 2018

Contributor

Can you try to instead call renderElement of the UsernameWidget? This way you avoid the global CSS selector and when people write apps that modify that widget this will keep working.

unlock_screen: function() {
var screen = (this.gui.pos.get_order() ? this.gui.pos.get_order().get_screen_data('previous-screen') : this.gui.startup_screen) || this.gui.startup_screen;
this.gui.show_screen(screen);

This comment has been minimized.

@jorenvo

jorenvo Dec 6, 2018

Contributor

@lap-odoo This is more a functional question. When an employee logs in via the lock screen, should we always show:

  • the startup screen of the POS (e.g. the tables in restaurant mode) or,
  • the screen that was shown when the previous employee logged out (e.g. some in progress order)
import base64
import logging
from odoo import api, fields, models
from odoo import api, fields, models, SUPERUSER_ID

This comment has been minimized.

@jorenvo

jorenvo Dec 6, 2018

Contributor
Suggested change Beta
from odoo import api, fields, models, SUPERUSER_ID
from odoo import api, fields, models

Unused.

@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from functools import partial

This comment has been minimized.

@jorenvo

jorenvo Dec 6, 2018

Contributor
Suggested change Beta
from functools import partial

Unused.

from functools import partial
from odoo import models, fields, api
from odoo.exceptions import ValidationError

This comment has been minimized.

@jorenvo

jorenvo Dec 6, 2018

Contributor
Suggested change Beta
from odoo.exceptions import ValidationError

Unused.

@robodoo robodoo removed the CI 🤖 label Dec 6, 2018

@switch87 switch87 force-pushed the odoo-dev:master-pos-one-user-per-pos branch 2 times, most recently from 7d0dcbe to cc71dfc Dec 6, 2018

@pha-odoo pha-odoo force-pushed the odoo-dev:master-pos-one-user-per-pos branch 3 times, most recently from 1291b32 to 5e396ca Dec 7, 2018

@robodoo robodoo added the CI 🤖 label Dec 7, 2018

def _compute_cashier(self):
for order in self:
if order.employee_id: order.cashier = order.employee_id.name
else: order.cashier = order.user_id.name

This comment has been minimized.

@antonylesuisse

antonylesuisse Dec 7, 2018

Contributor

order.cashier = order.employee_id.name if order.employee_id else order.user_id.name

class PosSession(models.Model):
_inherit = 'pos.session'
employee_id = fields.Many2one('hr.employee', string='Sales Person', index=True, readonly=True)

This comment has been minimized.

@antonylesuisse

antonylesuisse Dec 7, 2018

Contributor

????

[IMP] point_of_sale: Connect with Employee on PoS
=========
PURPOSE
=========

{Any employee can work on a PoS session, even if he has no user. This decreases the cost of PoS App.}

We are not competitive enough on the PoS Market because customers have to pay one user per cashier while they expect to pay one user per cash station.

===============
SPECIFICATIONS
===============

pos.config
- Add a checkbox : "Login with Employees"
- If set to TRUE, an "Allowed Employees" many2many appear
- If employees many2many is empty, all employees can log on this PoS
- If set to FALSE, can only log in with the currently logged user

hr.employee
- The barcode and pin fields were be moved to the hr.employee
- Set a barcode (not pin) by default at the creation of any employee
- No Employees module with PoS > dependency to hr

Open the PoS if "Log in with Employees" = FALSE
- Same behaviour than now, when I open the PoS, I'm logged in with the current user and can start working at once. The only difference is that it is not possible to switch users anymore.
- The button to close the session is visible

Open he PoS if "Log in with Employees" = TRUE
- When I open the PoS, the first screen I see is the login screen.
(a) I choose my employee and enter my pin code (if there is pin code on my employee, otherwise not required) (I can only see employees that have access to that PoS)
(b) I scan my barcode
(c) I scan my rfid card (future development)
- When I click on the employee name, I can log in with another employee
- If the employee is linked to a user that has the pos user/manager access right, I can see the button the close the session. Otherwise I cannot close the session (and thus cannot access backend).
- Add field employee on all records created by PoS (and replace the field user by that one) (on pos.orders)

Lock Screen
- Improve the PoS Interface
- Add a new feature to allow to "lock" the session. When a session has been locked, the user/employee has to re-log-in to access the PoS
- When I try to re-log-in, by default suggest the last employee logged in in the login screen

Migration
Plan a migration strategy > barcode and pin is now on the employee and not on the user anymore

@pha-odoo pha-odoo force-pushed the odoo-dev:master-pos-one-user-per-pos branch from 5e396ca to 0c2c903 Dec 7, 2018

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Dec 7, 2018

@qle-odoo

This comment has been minimized.

Contributor

qle-odoo commented Dec 7, 2018

@robodoo robodoo added the r+ 👌 label Dec 7, 2018

robodoo pushed a commit that referenced this pull request Dec 7, 2018

[IMP] point_of_sale: Connect with Employee on PoS
=========
PURPOSE
=========

{Any employee can work on a PoS session, even if he has no user. This decreases the cost of PoS App.}

We are not competitive enough on the PoS Market because customers have to pay one user per cashier while they expect to pay one user per cash station.

===============
SPECIFICATIONS
===============

pos.config
- Add a checkbox : "Login with Employees"
- If set to TRUE, an "Allowed Employees" many2many appear
- If employees many2many is empty, all employees can log on this PoS
- If set to FALSE, can only log in with the currently logged user

hr.employee
- The barcode and pin fields were be moved to the hr.employee
- Set a barcode (not pin) by default at the creation of any employee
- No Employees module with PoS > dependency to hr

Open the PoS if "Log in with Employees" = FALSE
- Same behaviour than now, when I open the PoS, I'm logged in with the current user and can start working at once. The only difference is that it is not possible to switch users anymore.
- The button to close the session is visible

Open he PoS if "Log in with Employees" = TRUE
- When I open the PoS, the first screen I see is the login screen.
(a) I choose my employee and enter my pin code (if there is pin code on my employee, otherwise not required) (I can only see employees that have access to that PoS)
(b) I scan my barcode
(c) I scan my rfid card (future development)
- When I click on the employee name, I can log in with another employee
- If the employee is linked to a user that has the pos user/manager access right, I can see the button the close the session. Otherwise I cannot close the session (and thus cannot access backend).
- Add field employee on all records created by PoS (and replace the field user by that one) (on pos.orders)

Lock Screen
- Improve the PoS Interface
- Add a new feature to allow to "lock" the session. When a session has been locked, the user/employee has to re-log-in to access the PoS
- When I try to re-log-in, by default suggest the last employee logged in in the login screen

Migration
Plan a migration strategy > barcode and pin is now on the employee and not on the user anymore

closes #28567
@robodoo

This comment has been minimized.

Contributor

robodoo commented Dec 7, 2018

Merged, thanks!

@robodoo robodoo closed this Dec 7, 2018

@switch87 switch87 deleted the odoo-dev:master-pos-one-user-per-pos branch Dec 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment