Skip to content

Commit a751ffb

Browse files
committed
[ADD] app product_barcode
1 parent da5bfb5 commit a751ffb

12 files changed

Lines changed: 280 additions & 0 deletions

File tree

product_barcode/README.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Product Barcode Generator v10
2+
=============================
3+
4+
Generates EAN13 Standard Barcode for Product.
5+
Also, introduces a new feature to print product variant price and name on the product label.
6+
7+
Depends
8+
=======
9+
[stock] addon Odoo
10+
11+
Tech
12+
====
13+
* [Python] - Models
14+
* [XML] - Odoo views
15+
16+
Installation
17+
============
18+
- www.odoo.com/documentation/10.0/setup/install.html
19+
- Install our custom addon
20+
21+
License
22+
=======
23+
GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (LGPLv3)
24+
(http://www.gnu.org/licenses/agpl.html)
25+
26+
Bug Tracker
27+
===========
28+
29+
Contact odoo@cybrosys.com
30+
31+
Authors
32+
-------
33+
* Sreejith P <sreejith@cybrosys.in>
34+
35+
Maintainer
36+
----------
37+
38+
This module is maintained by Cybrosys Technologies.
39+
40+
For support and more information, please visit https://www.cybrosys.com.

product_barcode/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# -*- coding: utf-8 -*-
2+
from . import models

product_barcode/__manifest__.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -*- coding: utf-8 -*-
2+
###################################################################################
3+
#
4+
# Cybrosys Technologies Pvt. Ltd.
5+
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
6+
# Author: Sreejith P(<https://www.cybrosys.com>)
7+
#
8+
# This program is free software: you can modify
9+
# it under the terms of the GNU Affero General Public License (AGPL) as
10+
# published by the Free Software Foundation, either version 3 of the
11+
# License, or (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU Affero General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU Affero General Public License
19+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
#
21+
###################################################################################
22+
23+
{
24+
'name': 'Product Barcode Generator',
25+
'version': '10.0.1.0.0',
26+
'summary': 'Generates EAN13 Standard Barcode for Product.',
27+
'category': 'Inventory',
28+
'author': 'Cybrosys Techno solutions',
29+
'maintainer': 'Cybrosys Techno Solutions',
30+
'company': 'Cybrosys Techno Solutions',
31+
'website': 'https://www.cybrosys.com',
32+
'depends': ['stock'],
33+
'data': [
34+
'views/product_label.xml',
35+
],
36+
'images': ['static/description/banner.jpg'],
37+
'license': 'AGPL-3',
38+
'installable': True,
39+
'application': False,
40+
'auto_install': False,
41+
}

product_barcode/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# -*- coding: utf-8 -*-
2+
from . import product_form
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding: utf-8 -*-
2+
from odoo import api, models
3+
import math
4+
import re
5+
6+
7+
class ProductAutoBarcode(models.Model):
8+
_inherit = "product.product"
9+
10+
@api.model
11+
def create(self, vals):
12+
res = super(ProductAutoBarcode, self).create(vals)
13+
ean = generate_ean(str(res.id))
14+
res.barcode = ean
15+
return res
16+
17+
18+
def ean_checksum(eancode):
19+
"""returns the checksum of an ean string of length 13, returns -1 if the string has the wrong length"""
20+
if len(eancode) != 13:
21+
return -1
22+
oddsum = 0
23+
evensum = 0
24+
eanvalue = eancode
25+
reversevalue = eanvalue[::-1]
26+
finalean = reversevalue[1:]
27+
28+
for i in range(len(finalean)):
29+
if i % 2 == 0:
30+
oddsum += int(finalean[i])
31+
else:
32+
evensum += int(finalean[i])
33+
total = (oddsum * 3) + evensum
34+
35+
check = int(10 - math.ceil(total % 10.0)) % 10
36+
return check
37+
38+
39+
def check_ean(eancode):
40+
"""returns True if eancode is a valid ean13 string, or null"""
41+
if not eancode:
42+
return True
43+
if len(eancode) != 13:
44+
return False
45+
try:
46+
int(eancode)
47+
except:
48+
return False
49+
return ean_checksum(eancode) == int(eancode[-1])
50+
51+
52+
def generate_ean(ean):
53+
"""Creates and returns a valid ean13 from an invalid one"""
54+
if not ean:
55+
return "0000000000000"
56+
ean = re.sub("[A-Za-z]", "0", ean)
57+
ean = re.sub("[^0-9]", "", ean)
58+
ean = ean[:13]
59+
if len(ean) < 13:
60+
ean = ean + '0' * (13 - len(ean))
61+
return ean[:-1] + str(ean_checksum(ean))
62+
63+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
104 KB
Loading
130 KB
Loading
49.6 KB
Loading
33.2 KB
Loading
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<section class="oe_container">
2+
<div class="oe_spaced">
3+
<h2 class="oe_slogan">Product Barcode Generator</h2>
4+
<h3 class="oe_slogan">Generates EAN13 Standard Barcode for Product </h3>
5+
6+
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a> </h4>
7+
<div style="padding-left:66px;">
8+
<h4>Features:</h4>
9+
<ul>
10+
<li style="list-style:none !important;"><span style="color:green;"> &#8594;</span>&nbsp;&nbsp; Generates Barcode Automatically.</li>
11+
<li style="list-style:none !important;"><span style="color:green;"> &#8594;</span>&nbsp;&nbsp; Print Variant Price on Product Labels. </li>
12+
<li style="list-style:none !important;"><span style="color:green;"> &#8594;</span>&nbsp;&nbsp; Print Variant Name on Product Labels. </li>
13+
</ul>
14+
</div>
15+
</div>
16+
</section>
17+
18+
<section class="oe_container oe_dark">
19+
<div class="oe_spaced">
20+
<div class="oe_picture">
21+
<h3 class="oe_slogan">Overview</h3>
22+
<p class="oe_mt32">
23+
The module automatically generates EAN13 standard barcode for each product while you create it.
24+
The module also introduces a new feature to print product variant price on the product label.
25+
Presently Odoo doesn’t have these features.
26+
</p>
27+
</div>
28+
</div>
29+
</section>
30+
31+
<section class="oe_container">
32+
<div class="oe_row oe_spaced">
33+
<h4 class="oe_slogan">Product Master</h4>
34+
<div class="oe_span12">
35+
<p class='oe_mt32'>
36+
&#x261B; Create a Product.<br>
37+
</p>
38+
<div class="oe_row_img oe_centered">
39+
<img class="oe_picture oe_screenshot" src="barcode_generate_product.gif">
40+
</div>
41+
</div>
42+
</div>
43+
</section>
44+
<section class="oe_container oe_dark">
45+
<div class="oe_row oe_spaced">
46+
<h4 class="oe_slogan">Product Labels</h4>
47+
<div class="oe_span12">
48+
<p class='oe_mt32'>
49+
&#x261B; Variant name on label.<br>
50+
&#x261B; Variant sale price on label.<br>
51+
</p>
52+
<div class="oe_row_img oe_centered">
53+
<img class="oe_picture oe_screenshot" src="product_label.png">
54+
</div>
55+
</div>
56+
</div>
57+
</section>
58+
<section class="oe_container">
59+
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
60+
<div class="oe_slogan" style="margin-top:10px !important;">
61+
<div>
62+
<a class="btn btn-primary btn-lg mt8"
63+
style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i
64+
class="fa fa-envelope"></i> Email </a> <a
65+
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
66+
href="https://www.cybrosys.com/contact/"><i
67+
class="fa fa-phone"></i> Contact Us </a> <a
68+
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
69+
href="https://www.cybrosys.com/odoo-customization-and-installation/"><i
70+
class="fa fa-check-square"></i> Request Customization </a>
71+
</div>
72+
<br>
73+
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
74+
<div>
75+
<a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td>
76+
<a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td>
77+
<a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td>
78+
<a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td>
79+
<a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td>
80+
</div>
81+
</div>
82+
</section>

0 commit comments

Comments
 (0)