12 changed files with 280 additions and 0 deletions
			
			
		@ -0,0 +1,40 @@ | 
				
			|||||
 | 
					Product Barcode Generator v10 | 
				
			||||
 | 
					============================= | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					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 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Tech | 
				
			||||
 | 
					==== | 
				
			||||
 | 
					* [Python] - Models | 
				
			||||
 | 
					* [XML] - Odoo views | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Installation | 
				
			||||
 | 
					============ | 
				
			||||
 | 
					- www.odoo.com/documentation/10.0/setup/install.html | 
				
			||||
 | 
					- Install our custom addon | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					License | 
				
			||||
 | 
					======= | 
				
			||||
 | 
					GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (LGPLv3) | 
				
			||||
 | 
					(http://www.gnu.org/licenses/agpl.html) | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Bug Tracker | 
				
			||||
 | 
					=========== | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Contact odoo@cybrosys.com | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Authors | 
				
			||||
 | 
					------- | 
				
			||||
 | 
					* Sreejith P <sreejith@cybrosys.in> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Maintainer | 
				
			||||
 | 
					---------- | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					This module is maintained by Cybrosys Technologies. | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					For support and more information, please visit https://www.cybrosys.com. | 
				
			||||
@ -0,0 +1,2 @@ | 
				
			|||||
 | 
					# -*- coding: utf-8 -*- | 
				
			||||
 | 
					from . import models | 
				
			||||
@ -0,0 +1,41 @@ | 
				
			|||||
 | 
					# -*- coding: utf-8 -*- | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    Cybrosys Technologies Pvt. Ltd. | 
				
			||||
 | 
					#    Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | 
				
			||||
 | 
					#    Author: Sreejith P(<https://www.cybrosys.com>) | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    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 <https://www.gnu.org/licenses/>. | 
				
			||||
 | 
					# | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					{ | 
				
			||||
 | 
					    'name': 'Product Barcode Generator', | 
				
			||||
 | 
					    'version': '10.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'], | 
				
			||||
 | 
					    'data': [ | 
				
			||||
 | 
					        'views/product_label.xml', | 
				
			||||
 | 
					    ], | 
				
			||||
 | 
					    'images': ['static/description/banner.jpg'], | 
				
			||||
 | 
					    'license': 'AGPL-3', | 
				
			||||
 | 
					    'installable': True, | 
				
			||||
 | 
					    'application': False, | 
				
			||||
 | 
					    'auto_install': False, | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,2 @@ | 
				
			|||||
 | 
					# -*- coding: utf-8 -*- | 
				
			||||
 | 
					from . import product_form | 
				
			||||
@ -0,0 +1,63 @@ | 
				
			|||||
 | 
					# -*- coding: utf-8 -*- | 
				
			||||
 | 
					from odoo import api, models | 
				
			||||
 | 
					import math | 
				
			||||
 | 
					import re | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					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: | 
				
			||||
| 
		 After Width: | Height: | Size: 104 KiB  | 
| 
		 After Width: | Height: | Size: 130 KiB  | 
| 
		 After Width: | Height: | Size: 50 KiB  | 
| 
		 After Width: | Height: | Size: 33 KiB  | 
@ -0,0 +1,82 @@ | 
				
			|||||
 | 
					<section class="oe_container"> | 
				
			||||
 | 
					    <div class="oe_spaced"> | 
				
			||||
 | 
					        <h2 class="oe_slogan">Product Barcode Generator</h2> | 
				
			||||
 | 
					        <h3 class="oe_slogan">Generates EAN13 Standard Barcode for Product </h3> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        <h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a> </h4> | 
				
			||||
 | 
					        <div style="padding-left:66px;"> | 
				
			||||
 | 
					        <h4>Features:</h4> | 
				
			||||
 | 
					        <ul> | 
				
			||||
 | 
					            <li style="list-style:none !important;"><span style="color:green;"> →</span>   Generates Barcode Automatically.</li> | 
				
			||||
 | 
					            <li style="list-style:none !important;"><span style="color:green;"> →</span>   Print Variant Price on Product Labels. </li> | 
				
			||||
 | 
					            <li style="list-style:none !important;"><span style="color:green;"> →</span>   Print Variant Name on Product Labels. </li> | 
				
			||||
 | 
					        </ul> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					<section class="oe_container oe_dark"> | 
				
			||||
 | 
					    <div class="oe_spaced"> | 
				
			||||
 | 
					        <div class="oe_picture"> | 
				
			||||
 | 
					            <h3 class="oe_slogan">Overview</h3> | 
				
			||||
 | 
					            <p class="oe_mt32"> | 
				
			||||
 | 
					                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. | 
				
			||||
 | 
					            </p> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					<section class="oe_container"> | 
				
			||||
 | 
					    <div class="oe_row oe_spaced"> | 
				
			||||
 | 
					        <h4 class="oe_slogan">Product Master</h4> | 
				
			||||
 | 
					        <div class="oe_span12"> | 
				
			||||
 | 
					            <p class='oe_mt32'> | 
				
			||||
 | 
					                ☛ Create a Product.<br> | 
				
			||||
 | 
					            </p> | 
				
			||||
 | 
					            <div class="oe_row_img oe_centered"> | 
				
			||||
 | 
					                <img class="oe_picture oe_screenshot" src="barcode_generate_product.gif"> | 
				
			||||
 | 
					            </div> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					<section class="oe_container oe_dark"> | 
				
			||||
 | 
					    <div class="oe_row oe_spaced"> | 
				
			||||
 | 
					        <h4 class="oe_slogan">Product Labels</h4> | 
				
			||||
 | 
					        <div class="oe_span12"> | 
				
			||||
 | 
					            <p class='oe_mt32'> | 
				
			||||
 | 
					                ☛ Variant name on label.<br> | 
				
			||||
 | 
					                ☛ Variant sale price on label.<br> | 
				
			||||
 | 
					            </p> | 
				
			||||
 | 
					            <div class="oe_row_img oe_centered"> | 
				
			||||
 | 
					                <img class="oe_picture oe_screenshot" src="product_label.png"> | 
				
			||||
 | 
					            </div> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					<section class="oe_container"> | 
				
			||||
 | 
					    <h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2> | 
				
			||||
 | 
					    <div class="oe_slogan" style="margin-top:10px !important;"> | 
				
			||||
 | 
					        <div> | 
				
			||||
 | 
					            <a  class="btn btn-primary btn-lg mt8" | 
				
			||||
 | 
					            style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i | 
				
			||||
 | 
					            class="fa fa-envelope"></i> Email </a> <a | 
				
			||||
 | 
					            class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" | 
				
			||||
 | 
					            href="https://www.cybrosys.com/contact/"><i | 
				
			||||
 | 
					            class="fa fa-phone"></i> Contact Us </a> <a | 
				
			||||
 | 
					            class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" | 
				
			||||
 | 
					            href="https://www.cybrosys.com/odoo-customization-and-installation/"><i | 
				
			||||
 | 
					            class="fa fa-check-square"></i> Request Customization </a> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					        <br> | 
				
			||||
 | 
					        <img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block"> | 
				
			||||
 | 
					        <div> | 
				
			||||
 | 
					          <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> | 
				
			||||
 | 
					          <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> | 
				
			||||
 | 
					          <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> | 
				
			||||
 | 
					          <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> | 
				
			||||
 | 
					          <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> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
| 
		 After Width: | Height: | Size: 4.5 KiB  | 
@ -0,0 +1,50 @@ | 
				
			|||||
 | 
					<?xml version="1.0" encoding="utf-8"?> | 
				
			||||
 | 
					<odoo> | 
				
			||||
 | 
					    <data> | 
				
			||||
 | 
					        <template id="report_simple_label" inherit_id="product.report_simple_label"> | 
				
			||||
 | 
					            <xpath expr="//table[@class='table']" position="replace"> | 
				
			||||
 | 
					                <div class="col-xs-4" style="padding:0;"> | 
				
			||||
 | 
					                    <table style="border-spacing:0;margin-bottom:0;height:122px;" class="table"> | 
				
			||||
 | 
					                        <thead> | 
				
			||||
 | 
					                            <tr style="width: 3in;"> | 
				
			||||
 | 
					                                <td style="border: 2px solid black;width: 2.63in;" colspan="2" class="col-xs-8 danger"> | 
				
			||||
 | 
					                                    <t t-if="product.default_code"> | 
				
			||||
 | 
					                                        [<strong t-field="product.default_code"/>] | 
				
			||||
 | 
					                                    </t> | 
				
			||||
 | 
					                                    <strong t-field="product.name"/> | 
				
			||||
 | 
					                                    <strong><span t-esc="', '.join(map(lambda x: x.name, product.attribute_value_ids))"/></strong> | 
				
			||||
 | 
					                                </td> | 
				
			||||
 | 
					                            </tr> | 
				
			||||
 | 
					                        </thead> | 
				
			||||
 | 
					                        <tbody> | 
				
			||||
 | 
					                            <tr style="width: 1in;"> | 
				
			||||
 | 
					                                <td style="border: 2px solid black;text-align: center; vertical-align: middle;" class="col-xs-5"> | 
				
			||||
 | 
					                                    <img t-if="product.barcode" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('EAN13', product.barcode, 600, 150)" style="width:100%;height:20%;"/> | 
				
			||||
 | 
					                                    <span t-field="product.barcode"/> | 
				
			||||
 | 
					                                </td> | 
				
			||||
 | 
					                                <td style="border: 2px solid black; text-align: center;" class="col-xs-7"> | 
				
			||||
 | 
					                                    <h4> | 
				
			||||
 | 
					                                        <strong t-field="product.company_id.currency_id.symbol"/> | 
				
			||||
 | 
					                                        <strong t-field="product.lst_price"/> | 
				
			||||
 | 
					                                    </h4> | 
				
			||||
 | 
					                                </td> | 
				
			||||
 | 
					                            </tr> | 
				
			||||
 | 
					                        </tbody> | 
				
			||||
 | 
					                    </table> | 
				
			||||
 | 
					                </div> | 
				
			||||
 | 
					            </xpath> | 
				
			||||
 | 
					        </template> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        <template id="report_productlabel"> | 
				
			||||
 | 
					            <t t-call="report.html_container"> | 
				
			||||
 | 
					                <div class="page"> | 
				
			||||
 | 
					                    <t t-foreach="docs" t-as="product"> | 
				
			||||
 | 
					                        <t t-call="product.report_simple_label"> | 
				
			||||
 | 
					                            <t t-set="product" t-value="product"/> | 
				
			||||
 | 
					                        </t> | 
				
			||||
 | 
					                    </t> | 
				
			||||
 | 
					                </div> | 
				
			||||
 | 
					            </t> | 
				
			||||
 | 
					        </template> | 
				
			||||
 | 
					    </data> | 
				
			||||
 | 
					</odoo> | 
				
			||||
					Loading…
					
					
				
		Reference in new issue