Permalink
Browse files

temp

  • Loading branch information...
pha-odoo authored and switch87 committed Dec 6, 2018
1 parent 83fa4ac commit abad4ef9f725f4b7395b0f57fae4d46e1f5a9730
@@ -5,7 +5,7 @@
import base64
import logging
from odoo import api, fields, models, SUPERUSER_ID
from odoo import api, fields, models
from odoo import tools, _
from odoo.exceptions import ValidationError, AccessError
from odoo.modules.module import get_module_resource
@@ -256,7 +256,6 @@ def _sync_user(self, user):
vals['tz'] = user.tz
return vals
@api.model
def create(self, vals):
if vals.get('user_id'):
@@ -2517,7 +2517,7 @@ td {
}
.pos .login-button{
font-size: initial;
height: -webkit-fill-available;
height: 100%;
color: #555555;
border-radius: 5px;
}
@@ -80,34 +80,14 @@ var OrderSelectorWidget = PosBaseWidget.extend({
/* ------- The User Name Widget ------- */
// Displays the current cashier's name and allows
// to switch between cashiers.
// Displays the current cashier's name
var UsernameWidget = PosBaseWidget.extend({
template: 'UsernameWidget',
init: function(parent, options){
options = options || {};
this._super(parent,options);
},
renderElement: function(){
var self = this;
this._super();
this.$el.click(function(){
self.click_username();
});
},
click_username: function(){
if(!this.pos.config.module_pos_hr) { return; }
var self = this;
this.gui.select_employee({
'security': true,
'current_employee': this.pos.get_cashier(),
'title': _t('Change Cashier'),
}).then(function(employee){
self.pos.set_cashier(employee);
self.renderElement();
});
this.pos.bind('change:cashier', function() { this.$el.text(this.pos.get('cashier') ? this.pos.get('cashier').name : this.pos.employee.name); }, this);
},
get_name: function(){
var user = this.pos.get_cashier();
@@ -148,55 +128,6 @@ var HeaderButtonWidget = PosBaseWidget.extend({
hide: function() { this.$el.addClass('oe_hidden'); },
});
var HeaderLockButtonWidget = HeaderButtonWidget.extend({
init: function(parent, options) {
this._super(parent,options);
this.icon = options.icon[0];
this.color = options.icon[1];
this.icon_mouseover = options.icon_mouseover[0];
this.color_mouseover = options.icon_mouseover[1];
},
start: function(){
if (this.pos.config.module_pos_hr) {
this.show();
} else {
this.hide();
}
},
renderElement: function() {
var self = this;
this._super();
this.iconElement = this.$el.find("i");
this.$el.css('font-size','20px');
this.iconElement.addClass(this.icon);
this.$el.css('color',this.color);
this.$el.mouseover(function(){
self.iconElement.addClass(self.icon_mouseover).removeClass(self.icon);
$(this).css('color', self.color_mouseover);
}).mouseleave(function(){
self.iconElement.addClass(self.icon).removeClass(self.icon_mouseover);
$(this).css('color', self.color);
});
},
});
var HeaderCloseButtonWidget = HeaderButtonWidget.extend({
start: function(){
var self = this;
var show_hide_close_button = function() {
if ((self.pos.get('cashier') || self.pos.get_cashier()).role == 'manager') {
self.show();
} else {
self.hide();
}
};
this.pos.bind('change:cashier', show_hide_close_button , this);
}
});
/* --------- The Debug Widget --------- */
// The debug widget lets the user control
@@ -562,7 +493,6 @@ var ClientScreenWidget = PosBaseWidget.extend({
this.$el.click(function(){
self.pos.render_html_for_customer_facing_display().then(function(rendered_html) {
self.pos.proxy.take_ownership_over_client_screen(rendered_html).then(
function(data) {
if (typeof data === 'string') {
data = JSON.parse(data);
@@ -851,18 +781,6 @@ var Chrome = PosBaseWidget.extend(AbstractAction.prototype, {
'name': 'order_selector',
'widget': OrderSelectorWidget,
'replace': '.placeholder-OrderSelectorWidget',
},{
'name': 'lock_button',
'widget': HeaderLockButtonWidget,
'append': '.pos-rightheader',
'args': {
label: _lt('Lock'),
icon: ['fa-unlock', 'green'],
icon_mouseover: ['fa-lock', 'red'],
action: function() {
this.gui.show_screen('login');
}
}
},{
'name': 'sale_details',
'widget': SaleDetailsButton,
@@ -884,11 +802,12 @@ var Chrome = PosBaseWidget.extend(AbstractAction.prototype, {
'append': '.pos-rightheader',
},{
'name': 'close_button',
'widget': HeaderCloseButtonWidget,
'widget': HeaderButtonWidget,
'append': '.pos-rightheader',
'args': {
label: _lt('Close'),
label: _t('Close'),
action: function(){
this.$el.addClass('close_button');
var self = this;
if (!this.confirmed) {
this.$el.addClass('confirm');
@@ -919,30 +838,32 @@ var Chrome = PosBaseWidget.extend(AbstractAction.prototype, {
},
],
// This method instantiates all the screens, widgets, etc.
build_widgets: function() {
var classe;
for (var i = 0; i < this.widgets.length; i++) {
var def = this.widgets[i];
if ( !def.condition || def.condition.call(this) ) {
var args = typeof def.args === 'function' ? def.args(this) : def.args;
var w = new def.widget(this, args || {});
if (def.replace) {
w.replace(this.$(def.replace));
} else if (def.append) {
w.appendTo(this.$(def.append));
} else if (def.prepend) {
w.prependTo(this.$(def.prepend));
load_widgets: function(widgets) {
for (var i = 0; i < widgets.length; i++) {
var widget = widgets[i];
if ( !widget.condition || widget.condition.call(this) ) {
var args = typeof widget.args === 'function' ? widget.args(this) : widget.args;
var w = new widget.widget(this, args || {});
if (widget.replace) {
w.replace(this.$(widget.replace));
} else if (widget.append) {
w.appendTo(this.$(widget.append));
} else if (widget.prepend) {
w.prependTo(this.$(widget.prepend));
} else {
w.appendTo(this.$el);
}
this.widget[def.name] = w;
}
}
},
// This method instantiates all the screens, widgets, etc.
build_widgets: function() {
this.load_widgets(this.widgets);
this.screens = {};
for (i = 0; i < this.gui.screen_classes.length; i++) {
var classe;
for (var i = 0; i < this.gui.screen_classes.length; i++) {
classe = this.gui.screen_classes[i];
if (!classe.condition || classe.condition.call(this)) {
var screen = new classe.widget(this,{});
@@ -978,8 +899,6 @@ return {
Chrome: Chrome,
DebugWidget: DebugWidget,
HeaderButtonWidget: HeaderButtonWidget,
HeaderLockButtonWidget: HeaderLockButtonWidget,
HeaderCloseButtonWidget: HeaderCloseButtonWidget,
OrderSelectorWidget: OrderSelectorWidget,
ProxyStatusWidget: ProxyStatusWidget,
SaleDetailsButton: SaleDetailsButton,
@@ -28,20 +28,22 @@ var Gui = core.Class.extend({
this.chrome.ready.then(function(){
self.close_other_tabs();
var order = self.pos.get_order();
if (self.pos.config.module_pos_hr) {
self.show_screen('login');
} else if (order) {
self.show_saved_screen(order);
} else {
self.show_screen(self.startup_screen);
}
self._show_first_screen();
self.pos.bind('change:selectedOrder', function(){
self.show_saved_screen(self.pos.get_order());
});
});
},
_show_first_screen: function() {
var order = this.pos.get_order();
if (order) {
this.show_saved_screen(order);
} else {
this.show_screen(this.startup_screen);
}
},
/* ---- Gui: SCREEN MANIPULATION ---- */
// register a screen widget to the gui,
@@ -114,7 +114,7 @@
<t t-if="!widget.icon">
<t t-esc="widget.label" />
</t>
<t t-if="widget.icon">
<t t-else="">
<i class='fa fa-fw' role="img"/>
</t>
</div>
@@ -60,7 +60,7 @@
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box"
title="Employees can scan their badge or enter a PIN to log in to a PoS session. Such credentials are settable in the *HR Settings* tab of the employee form.">
title="Employees can scan their badge or enter a PIN to log in to a PoS session. These credentials are configurable in the *HR Settings* tab of the employee form.">
<div class="o_setting_left_pane">
<field name="module_pos_hr"/>
</div>
@@ -1,26 +1,21 @@
# -*- coding: utf-8 -*-
from functools import partial
from odoo import models, fields, api
from odoo.exceptions import ValidationError
class PosOrder(models.Model):
_inherit = "pos.order"
employee_id = fields.Many2one(help="Person who uses the cash register. It can be a reliever, a student or an interim employee.", states={'done': [('readonly', True)], 'invoiced': [('readonly', True)]})
cashier = fields.Char(string="Cashier", compute="_compute_cashier")
employee_id = fields.Many2one('hr.employee', help="Person who uses the cash register. It can be a reliever, a student or an interim employee.", states={'done': [('readonly', True)], 'invoiced': [('readonly', True)]})
cashier = fields.Char(string="Cashier", compute="_compute_cashier", store=True)
@api.model
def _order_fields(self, ui_order):
order_fields = super(PosOrder, self)._order_fields(ui_order)
order_fields.update(
{'employee_id': ui_order.get('employee_id', False)})
order_fields['employee_id'] = ui_order.get('employee_id')
return order_fields
@api.multi
@api.depends('employee_id', 'user_id')
def _compute_cashier(self):
for rec in self:
if rec.employee_id: rec.cashier = rec.employee_id.name
else: rec.cashier = rec.user_id.name
for order in self:
if order.employee_id: order.cashier = order.employee_id.name
else: order.cashier = order.user_id.name
@@ -1,12 +1,9 @@
# -*- coding: utf-8 -*-
from functools import partial
from odoo import models, fields
class PosSession(models.Model):
_inherit = 'pos.session'
employee_id = fields.Many2one('hr.employee', string='Sales Person',
required=False, index=True, readonly=True)
employee_id = fields.Many2one('hr.employee', string='Sales Person', index=True, readonly=True)
Oops, something went wrong.

0 comments on commit abad4ef

Please sign in to comment.