diff --git a/product_barcode/README.rst b/product_barcode/README.rst new file mode 100644 index 000000000..fcee1768b --- /dev/null +++ b/product_barcode/README.rst @@ -0,0 +1,42 @@ +Product Barcode Generator v12 +============================= + +Generates EAN13 Standard Barcode for Product. +Also, introduces a new feature to print product variant price and name on the product label. + +Depends +======= +[stock] addon Odoo +[product] addon Odoo + +Tech +==== +* [Python] - Models +* [XML] - Odoo views + +Installation +============ +- www.odoo.com/documentation/12.0/setup/install.html +- Install our custom addon + +License +======= +GNU AGPL, Version 3 (AGPLv3) +(http://www.gnu.org/licenses/agpl.html) + +Bug Tracker +=========== + +Contact odoo@cybrosys.com + +Authors +------- +* Sreejith P +* Niyas Raphy + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. \ No newline at end of file diff --git a/product_barcode/__init__.py b/product_barcode/__init__.py new file mode 100644 index 000000000..cde864bae --- /dev/null +++ b/product_barcode/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/product_barcode/__manifest__.py b/product_barcode/__manifest__.py new file mode 100644 index 000000000..1727e6f11 --- /dev/null +++ b/product_barcode/__manifest__.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies(). +# Author: Sreejith P() +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +{ + 'name': 'Product Barcode Generator', + 'version': '12.0.1.0.0', + 'summary': 'Generates EAN13 Standard Barcode for Product.', + 'category': 'Inventory', + 'author': 'Cybrosys Techno solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['stock', 'product'], + 'data': [ + 'views/product_label.xml', + ], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/product_barcode/models/__init__.py b/product_barcode/models/__init__.py new file mode 100644 index 000000000..d5a59f518 --- /dev/null +++ b/product_barcode/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import product_form diff --git a/product_barcode/models/product_form.py b/product_barcode/models/product_form.py new file mode 100644 index 000000000..0d0283723 --- /dev/null +++ b/product_barcode/models/product_form.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- + +import math +import re + +from odoo import api, models + + +class ProductAutoBarcode(models.Model): + _inherit = "product.product" + + @api.model + def create(self, vals): + res = super(ProductAutoBarcode, self).create(vals) + ean = generate_ean(str(res.id)) + res.barcode = ean + return res + + +def ean_checksum(eancode): + """returns the checksum of an ean string of length 13, returns -1 if + the string has the wrong length""" + if len(eancode) != 13: + return -1 + oddsum = 0 + evensum = 0 + eanvalue = eancode + reversevalue = eanvalue[::-1] + finalean = reversevalue[1:] + + for i in range(len(finalean)): + if i % 2 == 0: + oddsum += int(finalean[i]) + else: + evensum += int(finalean[i]) + total = (oddsum * 3) + evensum + + check = int(10 - math.ceil(total % 10.0)) % 10 + return check + + +def check_ean(eancode): + """returns True if eancode is a valid ean13 string, or null""" + if not eancode: + return True + if len(eancode) != 13: + return False + try: + int(eancode) + except: + return False + return ean_checksum(eancode) == int(eancode[-1]) + + +def generate_ean(ean): + """Creates and returns a valid ean13 from an invalid one""" + if not ean: + return "0000000000000" + ean = re.sub("[A-Za-z]", "0", ean) + ean = re.sub("[^0-9]", "", ean) + ean = ean[:13] + if len(ean) < 13: + ean = ean + '0' * (13 - len(ean)) + return ean[:-1] + str(ean_checksum(ean)) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/product_barcode/static/description/banner.jpg b/product_barcode/static/description/banner.jpg new file mode 100644 index 000000000..2489f0aac Binary files /dev/null and b/product_barcode/static/description/banner.jpg differ diff --git a/product_barcode/static/description/barcode_generate_product.gif b/product_barcode/static/description/barcode_generate_product.gif new file mode 100644 index 000000000..6ad77ddae Binary files /dev/null and b/product_barcode/static/description/barcode_generate_product.gif differ diff --git a/product_barcode/static/description/cybro_logo.png b/product_barcode/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/product_barcode/static/description/cybro_logo.png differ diff --git a/product_barcode/static/description/icon.png b/product_barcode/static/description/icon.png new file mode 100644 index 000000000..bcd92a70d Binary files /dev/null and b/product_barcode/static/description/icon.png differ diff --git a/product_barcode/static/description/index.html b/product_barcode/static/description/index.html new file mode 100644 index 000000000..a84708efb --- /dev/null +++ b/product_barcode/static/description/index.html @@ -0,0 +1,82 @@ +
+
+

Product Barcode Generator

+

Generates EAN13 Standard Barcode for Product

+ +

Cybrosys Technologies

+
+

Features:

+
    +
  •    Generates Barcode Automatically.
  • +
  •    Print Variant Price on Product Labels.
  • +
  •    Print Variant Name on Product Labels.
  • +
+
+
+
+ +
+
+
+

Overview

+

+ The module automatically generates EAN13 standard barcode for each product while you create it. + The module also introduces a new feature to print product variant price on the product label. + Presently Odoo doesn’t have these features. +

+
+
+
+ +
+
+

Product Master

+
+

+ ☛ Create a Product.
+

+
+ +
+
+
+
+
+
+

Product Labels

+
+

+ ☛ Variant name on label.
+ ☛ Variant sale price on label.
+

+
+ +
+
+
+
+
+

Need Any Help?

+ +
diff --git a/product_barcode/static/description/product_label.png b/product_barcode/static/description/product_label.png new file mode 100644 index 000000000..8a27d6916 Binary files /dev/null and b/product_barcode/static/description/product_label.png differ diff --git a/product_barcode/views/product_label.xml b/product_barcode/views/product_label.xml new file mode 100644 index 000000000..db8ed59b0 --- /dev/null +++ b/product_barcode/views/product_label.xml @@ -0,0 +1,52 @@ + + + + + + + + + +