Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //EXTENDER ORDERLINES (add button that on click insert new <li> object //
  2.  
  3.  
  4.  <t t-extend="Orderline">
  5.         <t t-jquery=".info-list" t-operation="after">
  6.             <t t-if='line.product.pos_categ_id[0]'>
  7.                 <t t-if="line.state !== 'Done'">
  8.                     <t t-if="line.state !== 'Kitchen confirmed cancel'">
  9.                         <div class='new_control-button forchild '>
  10.                             <i class='fa fa-futbol-o' /> Children
  11.                         </div>
  12.                     </t>
  13.                 </t>
  14.             </t>
  15.         </t>
  16.     </t>
  17.  
  18.     <t t-extend="Orderline">
  19.         <t t-jquery=".info-list" t-operation="append">
  20.             <t t-if='line.product.pos_categ_id[0]'>
  21.                 <t t-if="line.state !== 'Done'">
  22.                     <t t-if="line.state !== 'Kitchen confirmed cancel'">
  23.                         <t t-if="line.children == true">
  24.                             <li class='info'>|
  25.                                 <i class='fa fa-futbol-o'/>For Children</li>
  26.                         </t>
  27.  
  28.                     </t>
  29.                 </t>
  30.             </t>
  31.         </t>
  32.     </t>
  33.  
  34.  
  35.  
  36. // EXTENDED KITCHEN LINE  
  37. <t t-extend="KitchenLine">
  38.           <t t-jquery=".cooking-status-warning" t-operation="before">
  39.                 <t t-if='line.get_child()'>
  40.                  <td><i style="color:blue;font-weight:bold" class="fa fa-futbol-o blink" /><t t-esc='line.get_child()'/</td>
  41.                 </t>
  42.                 <t t-if='!line.get_child()'>
  43.                  <td>NO</td>
  44.                 </t>
  45.  
  46.           </t>
  47. </t>
  48.  
  49. //js to do the job, probably a mistake in code ??.
  50.  
  51. odoo.define('pos_restaurant_extended_screen', function (require) {
  52. "use strict";
  53.  
  54.     var chrome = require('point_of_sale.chrome');
  55.     var gui = require('point_of_sale.gui');
  56.     var models = require('point_of_sale.models');
  57.     var screens = require('point_of_sale.screens');
  58.     var core = require('web.core');
  59.     var _t = core._t;
  60.     var qweb = core.qweb;
  61.  
  62. var _super_orderline = models.Orderline.prototype;
  63.  
  64. models.Orderline = models.Orderline.extend({
  65.             initialize: function() {
  66.                 _super_orderline.initialize.apply(this,arguments);
  67.                 this.children = this.children || "";
  68.             },
  69.  
  70.             init_from_JSON: function(json){
  71.             if (json.children) {
  72.                this.children = json.children;
  73.                }
  74.             _super_orderline.init_from_JSON.apply(this,arguments);
  75.  
  76.             },
  77.  
  78.             set_child: function(children){
  79.                 this.children = children;
  80.                 this.trigger('change',this);
  81.             },
  82.  
  83.             get_child: function(children){
  84.                 return this.children;
  85.             },
  86.  
  87.             export_as_JSON: function(){
  88.                 var json = _super_orderline.export_as_JSON.apply(this,arguments);
  89.                 if (this.children) {
  90.                     json.children = this.children;
  91.                 }
  92.                 return json;
  93.             }
  94.  
  95.  
  96.     })
  97.  
  98. screens.OrderWidget.include({
  99.          render_orderline: function(orderline){
  100.              var self = this;
  101.              var el_node = this._super(orderline);
  102.              var child_button = el_node.querySelector('.forchild');
  103.              if(child_button) {
  104.                    child_button.addEventListener('click', function() {
  105.                        var children = orderline.get_child(children);
  106.                        if (children) {
  107.                                     var children = false;
  108.                                     orderline.set_child(children);
  109.                                     orderline.order.state = true;
  110.                                     orderline.state = 'Confirmed';
  111.                                     orderline.trigger('change', orderline);
  112.                                     orderline.order.trigger('change', orderline.order);
  113.                                     orderline.order.trigger('change:sync');
  114.                                     orderline.order.state = false;
  115.                        }else{
  116.  
  117.                                     var children = true;
  118.                                     orderline.set_child(children);
  119.                                     orderline.order.state = true;
  120.                                     orderline.state = 'High Priority';
  121.                                     orderline.trigger('change', orderline);
  122.                                     orderline.order.trigger('change', orderline.order);
  123.                                     orderline.order.trigger('change:sync');
  124.                                     orderline.order.state = false;
  125.                        }
  126.              })
  127.  
  128.  
  129.              }
  130.  
  131.              return el_node;
  132.          },
  133.     })
  134.  
  135.  
  136. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement