[IMP] point_of_sale: accept tips from customers
This commit is contained in:
@@ -94,6 +94,7 @@ class pos_config(osv.osv):
|
||||
'barcode_nomenclature_id': fields.many2one('barcode.nomenclature','Barcodes', help='Defines what kind of barcodes are available and how they are assigned to products, customers and cashiers', required=True),
|
||||
'group_pos_manager_id': fields.many2one('res.groups','Point of Sale Manager Group', help='This field is there to pass the id of the pos manager group to the point of sale client'),
|
||||
'group_pos_user_id': fields.many2one('res.groups','Point of Sale User Group', help='This field is there to pass the id of the pos user group to the point of sale client'),
|
||||
'tip_product_id': fields.many2one('product.product','Tip Product', help="The product used to encode the customer tip. Leave empty if you do not accept tips."),
|
||||
}
|
||||
|
||||
def _check_cash_control(self, cr, uid, ids, context=None):
|
||||
|
||||
@@ -700,6 +700,7 @@
|
||||
<field name="iface_invoicing" />
|
||||
<field name="iface_precompute_cash" />
|
||||
<field name="iface_start_categ_id" />
|
||||
<field name="tip_product_id" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="iface_fullscreen" />
|
||||
|
||||
@@ -1179,6 +1179,8 @@ td {
|
||||
border-top: 1px solid;
|
||||
border-left: 1px solid;
|
||||
border-color: #cacaca;
|
||||
width: 296px;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
}
|
||||
.pos .payment-numpad .numpad button {
|
||||
@@ -1267,6 +1269,9 @@ td {
|
||||
position: relative;
|
||||
transition: background-color, border-color, color 150ms linear;
|
||||
}
|
||||
.payment-screen .payment-buttons .button:hover {
|
||||
background-color: #efefef;
|
||||
}
|
||||
.payment-screen .payment-buttons .button:first-child {
|
||||
border-top-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
|
||||
@@ -1470,6 +1470,33 @@ openerp.point_of_sale.load_models = function load_models(instance, module){ //mo
|
||||
get_last_orderline: function(){
|
||||
return this.orderlines.at(this.orderlines.length -1);
|
||||
},
|
||||
get_tip: function() {
|
||||
var tip_product = this.pos.db.get_product_by_id(this.pos.config.tip_product_id[0]);
|
||||
var lines = this.get_orderlines();
|
||||
if (!tip_product) {
|
||||
return 0;
|
||||
} else {
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (lines[i].get_product() === tip_product) {
|
||||
return lines[i].get_unit_price();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
set_tip: function(tip) {
|
||||
var tip_product = this.pos.db.get_product_by_id(this.pos.config.tip_product_id[0]);
|
||||
var lines = this.get_orderlines();
|
||||
if (tip_product) {
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (lines[i].get_product() === tip_product) {
|
||||
lines[i].set_unit_price(tip);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.add_product(tip_product, {quantity: 1, price: tip });
|
||||
}
|
||||
},
|
||||
remove_orderline: function( line ){
|
||||
this.assert_editable();
|
||||
this.orderlines.remove(line);
|
||||
|
||||
@@ -1563,6 +1563,27 @@ openerp.point_of_sale.load_screens = function load_screens(instance, module){ //
|
||||
this.$('.js_invoice').removeClass('highlight');
|
||||
}
|
||||
},
|
||||
click_tip: function(){
|
||||
var self = this;
|
||||
var order = this.pos.get_order();
|
||||
var tip = order.get_tip();
|
||||
var change = order.get_change();
|
||||
var value = tip;
|
||||
|
||||
if (tip === 0 && change > 0 ) {
|
||||
value = change;
|
||||
}
|
||||
|
||||
this.gui.show_popup('number',{
|
||||
'title': tip ? _t('Change Tip') : _t('Add Tip'),
|
||||
'value': value,
|
||||
'confirm': function(value) {
|
||||
order.set_tip(Number(value));
|
||||
self.order_changes();
|
||||
self.render_paymentlines();
|
||||
}
|
||||
});
|
||||
},
|
||||
click_set_customer: function(){
|
||||
this.gui.show_screen('clientlist');
|
||||
},
|
||||
@@ -1592,6 +1613,10 @@ openerp.point_of_sale.load_screens = function load_screens(instance, module){ //
|
||||
this.$('.js_set_customer').click(function(){
|
||||
self.click_set_customer();
|
||||
});
|
||||
|
||||
this.$('.js_tip').click(function(){
|
||||
self.click_tip();
|
||||
});
|
||||
this.$('.js_invoice').click(function(){
|
||||
self.click_invoice();
|
||||
});
|
||||
|
||||
@@ -593,6 +593,11 @@
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
<t t-if='widget.pos.config.tip_product_id'>
|
||||
<div class='button js_tip'>
|
||||
<i class='fa fa-heart' /> Tip
|
||||
</div>
|
||||
</t>
|
||||
<t t-if='widget.pos.config.iface_cashdrawer'>
|
||||
<div class='button js_cashdrawer'>
|
||||
<i class='fa fa-archive' /> Open Cashbox
|
||||
|
||||
Reference in New Issue
Block a user