diff --git a/__manifest__.py b/__manifest__.py index 2a6afba59f3e5c5d3e55965e2977efcd4222220d..102f113e6ecd2f9f32bb5978d3b6eea495207c1c 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,7 +1,7 @@ { "name": "VRACOOP - POS Balance Container QRCode", "summary": "VRACOOP - POS Balance Container QRCode", - "version": "12.0.0.0.0", + "version": "12.0.0.1.0", "development_status": "Beta", "author": "Le Filament", "maintainers": ["remi-filament"], diff --git a/models/__init__.py b/models/__init__.py index 7428ce5aac659f1896ea7aebbe4246bfa2458e9c..c424d6d6d161387d227fa160b49458a092045827 100755 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,5 +1,4 @@ # © 2019 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import pos_config -# from . import pos_transaction \ No newline at end of file +from . import pos_config \ No newline at end of file diff --git a/models/__pycache__/__init__.cpython-37.pyc b/models/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index 0a1c27b63d97e8415c08ed621c252052fb8f136b..0000000000000000000000000000000000000000 Binary files a/models/__pycache__/__init__.cpython-37.pyc and /dev/null differ diff --git a/models/__pycache__/pos_config.cpython-37.pyc b/models/__pycache__/pos_config.cpython-37.pyc deleted file mode 100644 index a595e8c0c89059d79ece45ff55eaad57dd346075..0000000000000000000000000000000000000000 Binary files a/models/__pycache__/pos_config.cpython-37.pyc and /dev/null differ diff --git a/models/__pycache__/pos_transaction.cpython-37.pyc b/models/__pycache__/pos_transaction.cpython-37.pyc deleted file mode 100644 index 5ef25d93b64c09db3718f5ce028e57458c5fc417..0000000000000000000000000000000000000000 Binary files a/models/__pycache__/pos_transaction.cpython-37.pyc and /dev/null differ diff --git a/models/pos_config.py b/models/pos_config.py index 59f6a6d16ea50e6e7b0f60bceacb9236ef6bf64c..01717d9ce0d32f87ec3a9c4fbe86fc8ef0f4c9a2 100644 --- a/models/pos_config.py +++ b/models/pos_config.py @@ -9,15 +9,4 @@ class PosConfig(models.Model): is_print_container_qr = fields.Boolean( string='Impression QR Code Container') - mag_id = fields.Char("Identifiant du magasin") - # logo_balance = fields.Binary( - # string='Logo Balance', - # attachment=True) - # explication_header = fields.Char(string='Explication') - # weight_default = fields.Char(string='Poids par défault (kg)') - # balance_id = fields.Char("Identifiant de la balance") - # caisse_id = fields.Char("Identifiant de la caisse") - # logo_path = fields.Char( - # "URL Logo", compute="_compute_image_path") - # is_comptoir = fields.Boolean("Est une balance comptoir") - # allow_without_container = fields.Boolean("Autoriser les pesées sans contenant") \ No newline at end of file + mag_id = fields.Char("Identifiant du magasin") \ No newline at end of file diff --git a/models/pos_transaction.py b/models/pos_transaction.py deleted file mode 100644 index b0fab9dea3b8c1d6700d1400169063bcbecb89cb..0000000000000000000000000000000000000000 --- a/models/pos_transaction.py +++ /dev/null @@ -1,49 +0,0 @@ -# © 2020 Le Filament (<http://www.le-filament.com>) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import api, fields, models -import pytz - -from datetime import datetime -from pytz import timezone - - -class PosTransaction(models.Model): - - _name = 'pos.transaction' - _description = 'Table des Transactions' - - name = fields.Char('Ref Produit') - 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) - date_iso = fields.Char('Date ISO', compute="_compute_date_iso") - container_ean13 = fields.Char('EAN13 Container', size=13) - 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') - - @api.model - def create_from_ui(self, transactions): - # retourne la liste des ids dans le même ordre que la liste fournie - transaction_ids = [] - - for transaction in transactions: - transaction_id = transaction.pop('id', False) - if transaction_id: - self.browse(transaction_id).write(transaction) - else: - transaction_id = self.create(transaction).id - transaction_ids.append(transaction_id) - return transaction_ids - - @api.depends('write_date') - def _compute_date_iso(self): - for transaction in self: - # print("---date_iso ---", str(date_iso)) - if hasattr(transaction.write_date, 'isoformat'): - date_iso = pytz.utc.localize(transaction.write_date).astimezone(pytz.timezone('Europe/Paris')) - transaction.date_iso = date_iso.isoformat('T')[:19] diff --git a/static/src/js/custo_header.js b/static/src/js/custo_header.js deleted file mode 100755 index 6e85367ea5b4da1a3d234c9cbb7086b8a33d8c55..0000000000000000000000000000000000000000 --- a/static/src/js/custo_header.js +++ /dev/null @@ -1,69 +0,0 @@ -// © 2020 Le Filament (<http://www.le-filament.com>) -// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -odoo.define('vracoop_pos_free_balance_v2.custo_header', function (require) { -"use strict"; - -var chrome = require("point_of_sale.chrome"); -var PosBaseWidget = require('point_of_sale.BaseWidget'); - -chrome.Chrome.include({ - build_widgets: function(){ - this.widgets.push({ - 'name': 'shopname', - 'widget': ShopnameWidget, - 'replace': '.placeholder-ShopnameWidget'}); - - this.widgets.push({ - 'name': 'shopimage', - 'widget': ShopimageWidget, - 'replace': '.placeholder-ShopimageWidget'}); - this._super(); - }, - -}); - -var ShopnameWidget = PosBaseWidget.extend({ - template: 'ShopnameWidget', - init: function(parent, options){ - options = options || {}; - this._super(parent,options); - }, - renderElement: function(){ - var self = this; - this._super(); - }, - get_shopname: function(){ - var header_text = this.pos.get_name_header(); - if(header_text){ - return header_text; - }else{ - return ""; - } - }, -}); - - -var ShopimageWidget = PosBaseWidget.extend({ - template: 'ShopimageWidget', - init: function(parent, options){ - options = options || {}; - this._super(parent,options); - }, - renderElement: function(){ - var self = this; - this._super(); - }, - get_shopimage: function(){ - var header_text = this.pos.get_name_header(); - if(header_text){ - return header_text; - }else{ - return ""; - } - }, -}); -return { - 'ShopnameWidget': ShopnameWidget, - }; -}); diff --git a/static/src/js/models_and_db.js b/static/src/js/models_and_db.js deleted file mode 100644 index e9282bc3b920b69ca843adec00339f506c8e6f07..0000000000000000000000000000000000000000 --- a/static/src/js/models_and_db.js +++ /dev/null @@ -1,320 +0,0 @@ -/* - © 2020 Le Filament (<http://www.le-filament.com>) - License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -*/ - -odoo.define('vracoop_pos_free_balance_v2.models_and_db_balance', function (require) { - "use strict"; - - var PosDB = require('point_of_sale.DB'); - var models = require('point_of_sale.models'); - var rpc = require('web.rpc'); - var config = require('web.config'); - var config = require('web.config'); - - var core = require('web.core'); - var QWeb = core.qweb; - - var utils = require('web.utils'); - var field_utils = require('web.field_utils'); - var round_di = utils.round_decimals; - var round_pr = utils.round_precision; - - - // include not available => extend - models.PosModel = models.PosModel.extend({ - - scan_container_check: function(parsed_code){ - var transactions = this.db.get_transactions_sorted(1000); - var container = this.db.get_container_by_barcode( - parsed_code.base_code); - - // var selected_order = this.get_order(); - - // selected_order.add_container(container); - - var today = new Date(); - var date = today.getFullYear() + '-' + (today.getMonth()+1) + '-' + today.getDate(); - - // var isostring = today.toISOString(); - // var localestring = today.toLocaleString(); - // var dateUTC = today.toUTCString(); - var min = today.getMinutes(); - if (min < 10) { - min = "0" + today.getMinutes(); - } - - var hour = today.getHours()-1; - if (hour < 10) { - hour = "0" + hour; - } - var time = (hour) + ":" + min + ":" + today.getSeconds(); - var date_time = date + ' ' + time; - - for(var i = 0, len = transactions.length; i < len; i++) { - var transaction = transactions[i]; - if ( - (transaction.container_ean13 == parsed_code.base_code) && - transaction.write_date > date_time ) { - return transaction; - } - } - - return false; - }, - - // saves the transaction locally and try to send it to the backend. - // it returns a deferred that succeeds after having tried to send - // the container and all the other pending containers. - push_transaction: function(transaction, opts) { - opts = opts || {}; - var self = this; - - if(transaction){ - this.db.add_transactions([transaction]); - } - - var pushed = new $.Deferred(); - - this.flush_mutex.exec(function(){ - var flushed = self._save_transactions_to_server(self.db.get_transactions_sorted(), opts); - - flushed.always(function(ids){ - pushed.resolve(); - }); - - return flushed; - }); - return pushed; - }, - - // send an array of containers to the server - // available options: - // - timeout: timeout for the rpc call in ms - // returns a deferred that resolves with the list of - // server generated ids for the sent containers - _save_transactions_to_server: function (transactions, options) { - var self = this; - var transactions= transactions.filter(transaction => !( "id" in transaction)) - if (!transactions || !transactions.length) { - var result = $.Deferred(); - result.resolve([]); - return result; - } - - options = options || {}; - var timeout = typeof options.timeout === 'number' ? options.timeout : 7500 * transactions.length; - - return rpc.query({ - model: 'pos.transaction', - method: 'create_from_ui', - args: [transactions], - }, { - timeout: timeout, - }) - .then(function (server_ids) { - _.each(transactions, function(transaction, key){ - transaction["id"] = server_ids[key] - }); - self.set('failed',false); - return server_ids; - }).fail(function (type, error){ - if(error.code === 200 ){ // Business Logic Error, not a connection problem - //if warning do not need to display traceback!! - if (error.data.exception_type == 'warning') { - delete error.data.debug; - } - - // Hide error if already shown before ... - if ((!self.get('failed') || options.show_error) && !options.to_invoice) { - self.gui.show_popup('error-traceback',{ - 'title': error.data.message, - 'body': error.data.debug - }); - } - self.set('failed',error); - } - console.error('Failed to send transactions:', transactions); - }); - }, - - // returns the header text from config - get_name_header: function(){ - if (this.config.explication_header) { - return this.config.explication_header; - } - }, - - // returns the id of caisse from config - get_balance_id: function(){ - if (this.config.balance_id) { - return this.config.balance_id; - } - }, - - // returns the id of balance from config - get_caisse_id: function(){ - if (this.config.caisse_id) { - return this.config.caisse_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; - } - }, - - }); - - - PosDB.include({ - init: function(parent, options) { - this._super(parent, options); - - this.transaction_sorted = []; - this.transaction_by_barcode = {}; - this.transaction_by_id = {}; - this.transaction_write_date = null; - - this.header_text = ""; - }, - - // returns the header text from config - get_name_header: function(){ - return this.db.get_name_header(); - }, - - add_transactions: function(transactions) { - var updated_count = 0; - var new_write_date = ''; - for(var i = 0, len = transactions.length; i < len; i++) { - var transaction = transactions[i]; - - if (this.transaction_write_date && - new Date(this.transaction_write_date).getTime() + 1000 >= - new Date(transaction.write_date).getTime() ) { - continue; - } else if ( new_write_date < transaction.write_date ) { - new_write_date = transaction.write_date; - } - - if (!this.transaction_by_barcode[transaction.container_ean13]) { - this.transaction_sorted.push(transaction.container_ean13); - } - this.transaction_by_barcode[transaction.container_ean13] = transaction; - - updated_count += 1; - } - - this.transaction_write_date = new_write_date || this.transaction_write_date; - - if (updated_count) { - // If there were updates, we need to completely - // rebuild the search string and the id indexing - - // this.container_search_string = ""; - this.transaction_by_id = {}; - - for (var barcode in this.transaction_by_barcode) { - var transaction = this.transaction_by_barcode[barcode]; - - if(transaction.id){ - this.transaction_by_id[transaction.id] = transaction; - } - // this.container_search_string += this._container_search_string(container); - } - } - - return updated_count; - }, - - get_transaction_by_id: function(id){ - return this.transaction_by_id[id]; - }, - - get_transactions_sorted: function(max_count){ - max_count = max_count ? Math.min(this.transaction_sorted.length, max_count) : this.transaction_sorted.length; - var transactions = []; - for (var i = 0; i < max_count; i++) { - transactions.push(this.transaction_by_barcode[this.transaction_sorted[i]]); - } - - return transactions; - }, - - remove_transactions: function(barcodes){ - for(var i = 0; i < barcodes.length; i++) { - var transaction = this.transaction_by_barcode[barcodes[i]]; - if (transaction){ - var index_s = this.transaction_sorted.indexOf(transaction.container_ean13); - this.transaction_sorted.splice(index_s, 1); - delete this.transaction_by_id[transaction.id]; - delete this.transaction_by_barcode[transaction.container_ean13]; - } - } - }, - - transaction_by_barcode: function(barcode){ - return this.transaction_by_barcode[barcode]; - }, - - get_product_name: function(transaction){ - return transaction.name; - }, - - get_today_date: function(){ - var today = new Date(); - var date = today.getFullYear() + '-' + (today.getMonth()+1) + '-' + today.getDate(); - return date; - }, - - }); - - // 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.caisse_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'], - domain: function(self){ return [['write_date','>',self.db.get_today_date()]]; }, - loaded: function(self, transactions){ - self.db.add_transactions(transactions); - }, - }); - -}); \ No newline at end of file diff --git a/views/pos_transaction.xml b/views/pos_transaction.xml deleted file mode 100755 index 032fd37ea0a69d260959e170fe92407358e98858..0000000000000000000000000000000000000000 --- a/views/pos_transaction.xml +++ /dev/null @@ -1,61 +0,0 @@ -<odoo> - <record id="pos_transaction_tree_view" model="ir.ui.view"> - <field name="name">pos.transaction.tree</field> - <field name="model">pos.transaction</field> - <field name="arch" type="xml"> - <tree> - <field name="balance_id"/> - <field name="name"/> - <field name="qrcode"/> - <field name="ean13"/> - <field name="ean13_verif"/> - <field name="write_date"/> - <field name="date_iso"/> - <!-- <field name="weight"/> --> - </tree> - </field> - </record> - - <record id="pos_transaction_form_view" model="ir.ui.view"> - <field name="name">pos.transaction.form</field> - <field name="model">pos.transaction</field> - <field name="arch" type="xml"> - <form> - <sheet> - <group> - <group> - <field name="balance_id" readonly="1"/> - <field name="name" readonly="1"/> - <field name="product_id" readonly="1"/> - <field name="write_date" readonly="1"/> - <field name="date_iso" readonly="1"/> - </group> - <group> - <field name="ean13" readonly="1"/> - <field name="ean13_verif" readonly="1"/> - <field name="qrcode" readonly="1"/> - <field name="weight_net" readonly="1"/> - <field name="weight_tare" readonly="1"/> - <field name="price_product" readonly="1"/> - <field name="price_net" readonly="1"/> - </group> - </group> - </sheet> - </form> - </field> - </record> - - <record id="pos_transaction_action_window" model="ir.actions.act_window" > - <field name="name">transactions</field> - <field name="res_model">pos.transaction</field> - <field name="view_mode">tree,form</field> - </record> - - <menuitem id="pos_transaction_menu" - name="transactions" - parent="point_of_sale.pos_config_menu_catalog" - sequence="13" - action="pos_transaction_action_window" - groups="point_of_sale.group_pos_manager,point_of_sale.group_pos_user" - /> -</odoo>