Hi,
I would like to extend the functionality of the pos module :
1 : I would like to add a functionality to separate the orderlines
Example Order :
1x Dish
1X Dish 2
---- Next ---
1x Dessert
1x dessert 1
--- Next ---
2x coffees
When i tried with my script, the next instruction display only once and in Start order ...
Can you help me ?
XML & Script
XML :
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="NextButton">
<div class='control-button'>
<i class='fa fa-leaf' /> Next
</div>
</t>
<t t-extend="OrderWidget">
<t t-jquery=".orderlines" t-operation="append">
<t t-if="order.get_next()">
<li class="orderline-instruction">
<span><t t-esc="order.get_next()" /></span>
</li>
</t>
</t>
</t>
</templates>
JS script :
odoo.define('pos_expanded.next', function (require) {
"use strict";
var pos_screens = require('point_of_sale.screens');
var models = require('point_of_sale.models');
var _super_order = models.Order.prototype;
models.Order = models.Order.extend({
initialize: function(attr, options) {
_super_order.initialize.call(this,attr,options);
this.next = this.next || "";
},
set_next: function(next){
var orderlines = this.pos.get_order().get_orderlines();
var order = this.pos.get_order();
//console.log("last orderline", this.get_last_orderline());
//console.log("orderlines", orderlines);
//console.log("order", order);
//var list_container = $('.orderlines');
//list_container.append("<li class='orderline-next'>"+next+"</li>");
this.next = next;
this.trigger('change',this);
},
get_next: function(next){
return this.next;
},
can_be_merged_with: function(order) {
if (order.get_next() !== this.get_next()) {
return false;
} else {
return _super_order.can_be_merged_with.apply(this,arguments);
}
},
clone: function(){
var order = _super_order.clone.call(this);
order.next = this.next;
return order;
},
export_as_JSON: function(){
var json = _super_order.export_as_JSON.call(this);
json.next = this.next;
return json;
},
init_from_JSON: function(json){
_super_order.init_from_JSON.apply(this,arguments);
this.next = json.next;
},
});
var NextButton = pos_screens.ActionButtonWidget.extend({
template: 'NextButton',
button_click: function(){
console.log('Next');
var order = this.pos.get_order();
var orderlines = this.pos.get_order().get_orderlines();
order.set_next(" --- Next --- ");
},
});
pos_screens.define_action_button({
'name': 'next',
'widget': NextButton
});
});