diff --git a/pos_traceability_validation/README.rst b/pos_traceability_validation/README.rst new file mode 100644 index 000000000..95a1cc500 --- /dev/null +++ b/pos_traceability_validation/README.rst @@ -0,0 +1,12 @@ +POS Serial Number Validator v11 +=============================== + +Validate Serial number of a product by checking availability in stock + +Credits +======= +Cybrosys Techno Solutions + +Author +------ +* Akhilesh N S diff --git a/pos_traceability_validation/__init__.py b/pos_traceability_validation/__init__.py new file mode 100644 index 000000000..e6ceb6eb9 --- /dev/null +++ b/pos_traceability_validation/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies(). +# Author: Akhilesh N S() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from . import models diff --git a/pos_traceability_validation/__manifest__.py b/pos_traceability_validation/__manifest__.py new file mode 100644 index 000000000..92d896633 --- /dev/null +++ b/pos_traceability_validation/__manifest__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies(). +# Author: Akhilesh N S() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': 'POS Serial Number Validator', + 'version': '11.0.1.0', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'http://www.cybrosys.com', + 'category': 'Point of Sale', + 'summary': """Validate Serial number of a product by checking availability in stock""", + 'description': """Validate Serial number of a product by checking availability in stock""", + 'depends': ['point_of_sale'], + 'data': [ + 'static/src/xml/pos_templates.xml', + ], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, +} + diff --git a/pos_traceability_validation/models/__init__.py b/pos_traceability_validation/models/__init__.py new file mode 100644 index 000000000..1b8acdb97 --- /dev/null +++ b/pos_traceability_validation/models/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies(). +# Author: Akhilesh N S() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +from . import traceability_validation diff --git a/pos_traceability_validation/models/traceability_validation.py b/pos_traceability_validation/models/traceability_validation.py new file mode 100644 index 000000000..704022301 --- /dev/null +++ b/pos_traceability_validation/models/traceability_validation.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies(). +# Author: Akhilesh N S() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from odoo import models, api + + +class ValidateLotNumber(models.Model): + _name = 'serial_no.validation' + + @api.model + def validate_lots(self, lots): + processed = [] + LotObj = self.env['stock.production.lot'] + for lot in lots: + lot_id = LotObj.search([('name', '=', lot)], limit=1) + try: + if lot_id.product_qty > 0 and lot not in processed: + processed.append(lot) + continue + else: + if lot in processed: + return ['duplicate', lot] + else: + return ['no_stock', lot] + except Exception: + return ['except', lot] + return True + diff --git a/pos_traceability_validation/static/description/banner.jpg b/pos_traceability_validation/static/description/banner.jpg new file mode 100644 index 000000000..31659f185 Binary files /dev/null and b/pos_traceability_validation/static/description/banner.jpg differ diff --git a/pos_traceability_validation/static/description/cybro_logo.png b/pos_traceability_validation/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/pos_traceability_validation/static/description/cybro_logo.png differ diff --git a/pos_traceability_validation/static/description/duplicate_entry.png b/pos_traceability_validation/static/description/duplicate_entry.png new file mode 100644 index 000000000..814de84db Binary files /dev/null and b/pos_traceability_validation/static/description/duplicate_entry.png differ diff --git a/pos_traceability_validation/static/description/icon.png b/pos_traceability_validation/static/description/icon.png new file mode 100644 index 000000000..74a174c7a Binary files /dev/null and b/pos_traceability_validation/static/description/icon.png differ diff --git a/pos_traceability_validation/static/description/index.html b/pos_traceability_validation/static/description/index.html new file mode 100644 index 000000000..f537f500d --- /dev/null +++ b/pos_traceability_validation/static/description/index.html @@ -0,0 +1,48 @@ +
+
+

POS Serial Number Validator

+

Validate the given Serial number of a product from stock

+

Cybrosys Technologies

+
+
+ +
+
+
+

Warnings

+
+ + +

+ Currently in Odoo, Serial number validation at POS not available. This module validates given serial number is available in stock and prevent duplicated entry for more than one quantity +

+
+ +
+ + +
+

Need Any Help?

+ +
diff --git a/pos_traceability_validation/static/description/invalid_serial_number.png b/pos_traceability_validation/static/description/invalid_serial_number.png new file mode 100644 index 000000000..8f89b3735 Binary files /dev/null and b/pos_traceability_validation/static/description/invalid_serial_number.png differ diff --git a/pos_traceability_validation/static/src/js/pos_models.js b/pos_traceability_validation/static/src/js/pos_models.js new file mode 100644 index 000000000..ad26203b6 --- /dev/null +++ b/pos_traceability_validation/static/src/js/pos_models.js @@ -0,0 +1,73 @@ +odoo.define('pos_traceability_validation.models', function (require) { +"use strict"; + + var PosModel = require('point_of_sale.models'); + var PosPopups = require('point_of_sale.popups'); + var gui = require('point_of_sale.gui'); + var rpc = require('web.rpc'); + var PackLotLinePopupWidget = PosPopups.extend({ + template: 'PackLotLinePopupWidget', + + /*making sure we didn't used same key already in the order*/ + duplicate_lot_name: function(id, lot_name, lot_lines){ + for(var i=0; i< lot_lines.length; i++){ + if(lot_lines[i].attributes && + lot_lines[i].attributes.lot_name != null + && lot_lines[i].attributes.lot_name == lot_name && + id != lot_lines[i].cid){ + return true; + } + } + return false; + }, + + click_confirm: function(){ + var self = this; + var lot_names = []; + var lot_cid = {}; + var pack_lot_lines = this.options.pack_lot_lines; + + this.$('.packlot-line-input').each(function(index, el){ + var cid = $(el).attr('cid'), + lot_name = $(el).val(); + var pack_line = pack_lot_lines.get({cid: cid}); + pack_line.set_lot_name(lot_name); + lot_names.push(lot_name); + lot_cid[lot_name] = cid; + }); + + rpc.query({ + model: 'serial_no.validation', + method: 'validate_lots', + args: [lot_names] + }).done(function(result){ + if(result != true){ + var current_id = lot_cid[result[1]]; + var pack_line = pack_lot_lines.get({cid: current_id}); + pack_line.set_lot_name(null); + if(result[0] == 'no_stock'){ + alert("Insufficient stock for " + result[1]) + } + else if(result[0] == 'duplicate'){ + alert("Duplicate entry for " + result[1]) + } + else if(result[0] == 'except'){ + alert("Exception occured with " + result[1]) + } + } + else{ + pack_lot_lines.remove_empty_model(); + pack_lot_lines.set_quantity_by_lot(); + self.options.order.save_to_db(); + self.options.order_line.trigger( + 'change', + self.options.order_line + ); + self.gui.close_popup(); + } + }); + } + }); + gui.define_popup({name:'packlotline', widget: PackLotLinePopupWidget}); + +}); diff --git a/pos_traceability_validation/static/src/xml/pos_templates.xml b/pos_traceability_validation/static/src/xml/pos_templates.xml new file mode 100644 index 000000000..8b572f230 --- /dev/null +++ b/pos_traceability_validation/static/src/xml/pos_templates.xml @@ -0,0 +1,8 @@ + + +