diff --git a/models/pos_transaction.py b/models/pos_transaction.py index 3c99eab..34f86c1 100644 --- a/models/pos_transaction.py +++ b/models/pos_transaction.py @@ -14,7 +14,7 @@ class PosTransaction(models.Model): _description = 'Table des Transactions' name = fields.Char('Ref Produit') - balance_id = fields.Char('Id de la balance') + balance_id = fields.Char('Id de la balance/caisse') qrcode = fields.Char("QRCode") ean13 = fields.Char('EAN13 Poids Produits', size=13) ean13_verif = fields.Char('EAN13 Vérification Poids', size=13) diff --git a/static/src/js/container.js b/static/src/js/container.js index b3ec9a9..afc8b16 100644 --- a/static/src/js/container.js +++ b/static/src/js/container.js @@ -30,7 +30,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) show: function(){ var self = this; - if (this.pos.config.balance_id) { + if (this.pos.config.is_balance_free) { var queue = this.pos.proxy_queue; var container = this.gui.get_current_screen_param('container'); @@ -398,7 +398,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) 'name':'balancescale', 'widget': BalanceScaleScreenWidget, 'condition': function(){ - return this.pos.config.balance_id; + return this.pos.config.is_balance_free; }, }); @@ -642,7 +642,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) 'name':'products-balance', 'widget': ProductBalanceScreenWidget, 'condition': function(){ - return this.pos.config.balance_id; + return this.pos.config.is_balance_free; }, }); @@ -765,7 +765,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) 'name':'balancecontainerscale', 'widget': BalanceContainerScaleScreenWidget, 'condition': function(){ - return this.pos.config.balance_id; + return this.pos.config.is_balance_free; }, }); @@ -820,7 +820,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) 'name': 'presentation', 'widget': PresentationScreenWidget, 'condition': function(){ - return this.pos.config.balance_id; + return this.pos.config.is_balance_free; }, }); @@ -928,7 +928,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) 'name': 'confirmation', 'widget': ConfirmationScreen, 'condition': function(){ - return this.pos.config.balance_id; + return this.pos.config.is_balance_free; }, }); @@ -936,14 +936,14 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) chrome.Chrome.include({ build_widgets: function(){ this._super(); - if (this.pos.config.balance_id) { + if (this.pos.config.is_balance_free) { this.gui.set_startup_screen('presentation'); } }, build_chrome: function() { this._super(); - if (this.pos.config.balance_id) { + if (this.pos.config.is_balance_free) { this.$('.pos-topheader').addClass('oe_hidden'); } else { @@ -974,7 +974,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) renderElement: function(){ var self = this; this._super(); - if (this.pos.config.balance_id) { + if (this.pos.config.is_balance_free) { if (this.pos.get_order()) { this.$el.removeClass('oe_invisible'); } else { diff --git a/static/src/js/models_and_db.js b/static/src/js/models_and_db.js index ac2a35a..d8bc93c 100644 --- a/static/src/js/models_and_db.js +++ b/static/src/js/models_and_db.js @@ -145,13 +145,20 @@ odoo.define('vracoop_pos_free_balance_v2.models_and_db_balance', function (requi } }, - // returns the header text from config + // returns the id of balance/caisse from config get_balance_id: function(){ if (this.config.balance_id) { return this.config.balance_id; } }, + // returns if the pos is balance from config + get_is_balance_free: function(){ + if (this.config.is_balance_free) { + return this.config.is_balance_free; + } + }, + get_is_comptoir: function(){ if (this.config.is_comptoir) { return this.config.is_comptoir; @@ -264,6 +271,36 @@ odoo.define('vracoop_pos_free_balance_v2.models_and_db_balance', function (requi }); + // Add container to order line + models.Orderline = models.Orderline.extend({ + + export_as_JSON: function(){ + var pack_lot_ids = []; + if (this.has_product_lot){ + this.pack_lot_lines.each(_.bind( function(item) { + return pack_lot_ids.push([0, 0, item.export_as_JSON()]); + }, this)); + } + return { + qty: this.get_quantity(), + price_unit: this.get_unit_price(), + price_subtotal: this.get_price_without_tax(), + price_subtotal_incl: this.get_price_with_tax(), + discount: this.get_discount(), + product_id: this.get_product().id, + tax_ids: [[6, false, _.map(this.get_applicable_taxes(), function(tax){ return tax.id; })]], + id: this.id, + pack_lot_ids: pack_lot_ids, + //custom starts here + tare: this.get_tare(), + container_id: this.get_container() ? this.get_container().id : null, + container_barcode: this.get_container() ? this.get_container().barcode : null, + container_weight: this.get_container() ? this.get_container().weight : null, + caisse_id: this.pos.config.balance_id, + }; + }, + }), + models.load_models({ model: 'pos.transaction', fields: ['product_id', 'name', 'balance_id', 'ean13', 'write_date', 'container_ean13', 'weight_net', 'price_product', 'price_net', 'weight_tare'], diff --git a/views/pos_config_views.xml b/views/pos_config_views.xml index b3d9221..5562adc 100644 --- a/views/pos_config_views.xml +++ b/views/pos_config_views.xml @@ -8,6 +8,22 @@
+
+
+
+
+ Caisse ID +
+ Définition de l'ID Caisse pour l'API +
+
+
+
+
+
+