diff --git a/models/pos_transaction.py b/models/pos_transaction.py index a0765fa..3c99eab 100644 --- a/models/pos_transaction.py +++ b/models/pos_transaction.py @@ -20,7 +20,8 @@ class PosTransaction(models.Model): ean13_verif = fields.Char('EAN13 Vérification Poids', size=13) date_iso = fields.Char('Date ISO', compute="_compute_date_iso") container_ean13 = fields.Char('EAN13 Container', size=13) - weight_net = fields.Float('Poids Net') + weight_net = fields.Float('Poids Net (en kg)', digits=(12,3)) + weight_tare = fields.Float('Poids Tare (en kg)', digits=(12,3)) price_net = fields.Float('Prix total') price_product = fields.Float('Prix au kilo') product_id = fields.Many2one('product.product', string='Produit ID') @@ -31,7 +32,6 @@ class PosTransaction(models.Model): transaction_ids = [] for transaction in transactions: - transaction_id = transaction.pop('id', False) if transaction_id: self.browse(transaction_id).write(transaction) diff --git a/static/src/js/container.js b/static/src/js/container.js index 056984b..dc4d9a8 100644 --- a/static/src/js/container.js +++ b/static/src/js/container.js @@ -165,9 +165,26 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) } }, + get_product_weight_string: function(){ + var product = this.get_product(); + var defaultstr = (this.weight || 0).toFixed(3) + ' kg'; + if(!product || !this.pos){ + return defaultstr; + } + var unit_id = product.uom_id; + if(!unit_id){ + return defaultstr; + } + var unit = this.pos.units_by_id[unit_id[0]]; + var weight = round_pr(this.weight || 0, unit.rounding); + var weightstr = weight.toFixed(Math.ceil(Math.log(1.0/unit.rounding) / Math.log(10) )); + weightstr += ' ' + unit.name; + return weightstr; + }, + get_product_weight_string_brut: function(){ var product = this.get_product(); - var defaultstr = (this.weight + this.weight_container || 0).toFixed(3) + ' Kg'; + var defaultstr = (this.weight + this.weight_container || 0).toFixed(3) + ' kg'; if(!product || !this.pos){ return defaultstr; } @@ -381,13 +398,6 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) var container = this.gui.get_current_screen_param('container'); - // queue.schedule(function () { - // return self.pos.proxy.reset_weight().then(function () { - // self.set_weight(0); - // self.set_price(0); - // }); - // }, {duration: 500}); - // format price var scale_screen = this.gui.screen_instances['balancescale']; var price = scale_screen.format_price(scale_screen.get_product_price()); @@ -433,9 +443,9 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) scale_screen.weight = weight; scale_screen.$('.weight').text(scale_screen.get_product_weight_string()); scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0)); - scale_screen.$('.weight-brut').text(''); + scale_screen.$('.weight-brut').text('0.000 kg'); - var container_text = '' + var container_text = '0.000 kg' scale_screen.$('.tare-container').text(container_text); }, @@ -810,6 +820,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) fields['write_date'] = date_time; fields['weight_net'] = scale_screen.weight; + fields['weight_tare'] = container.weight; var pricelist = scale_screen._get_active_pricelist(); fields['price_product'] = (product ? product.get_price(pricelist, scale_screen.weight) : 0) || 0; diff --git a/static/src/js/models_and_db.js b/static/src/js/models_and_db.js index 77d07c0..ac2a9d1 100644 --- a/static/src/js/models_and_db.js +++ b/static/src/js/models_and_db.js @@ -283,7 +283,7 @@ odoo.define('vracoop_pos_free_balance_v2.models_and_db_balance', function (requi models.load_models({ model: 'pos.transaction', - fields: ['product_id', 'name', 'balance_id', 'ean13', 'write_date', 'container_ean13', 'weight_net', 'price_product', 'price_net'], + fields: ['product_id', 'name', 'balance_id', 'ean13', 'write_date', 'container_ean13', 'weight_net', 'price_product', 'price_net', 'weight_tare'], domain: function(self){ return [['write_date','>',self.db.get_today_date()]]; }, loaded: function(self, transactions){ self.db.add_transactions(transactions); diff --git a/static/src/xml/pos.xml b/static/src/xml/pos.xml index fcf3e95..d69e21e 100644 --- a/static/src/xml/pos.xml +++ b/static/src/xml/pos.xml @@ -96,14 +96,14 @@
Poids Brut total:
- 0.00 + 0.000 kg
Tare contenant:
- + 0.000 kg
@@ -113,37 +113,8 @@ -
-
Poids Net
@@ -163,15 +134,14 @@
Poids Brut total:
- 0.000 + 0.000 kg
Tare contenant:
- 0.000 - + 0.000 kg
diff --git a/views/pos_transaction.xml b/views/pos_transaction.xml index 46ff045..5bdcd22 100644 --- a/views/pos_transaction.xml +++ b/views/pos_transaction.xml @@ -35,6 +35,7 @@ +