13 changed files with 368 additions and 0 deletions
			
			
		| @ -0,0 +1,45 @@ | |||||
|  | .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||||
|  |     :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||||
|  |     :alt: License: AGPL-3 | ||||
|  | 
 | ||||
|  | Product Barcode Generator | ||||
|  | ========================= | ||||
|  | 
 | ||||
|  | Generates EAN13 Standard Barcode for Product. | ||||
|  | Also, introduces a new feature to print product variant price and name on the product label. | ||||
|  | 
 | ||||
|  | Configuration | ||||
|  | ============= | ||||
|  | * No additional configurations needed | ||||
|  | 
 | ||||
|  | Company | ||||
|  | ------- | ||||
|  | * `Cybrosys Techno Solutions <https://cybrosys.com/>`__ | ||||
|  | 
 | ||||
|  | Credits | ||||
|  | ------- | ||||
|  | * Developer:	Sreejith P @ cybrosys, Contact: odoo@cybrosys.com | ||||
|  | 		Niyas Raphy @cybrosys, Contact: odoo@cybrosys.com | ||||
|  |     		Version 13: Nimisha Murali@cybrosys,Contact: odoo@cybrosys.com | ||||
|  |     		Version 14: Naveen V @cybrosys, Contact: odoo@cybrosys.com | ||||
|  | Contacts | ||||
|  | -------- | ||||
|  | * Mail Contact : odoo@cybrosys.com | ||||
|  | * Website : https://cybrosys.com | ||||
|  | 
 | ||||
|  | Bug Tracker | ||||
|  | ----------- | ||||
|  | Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. | ||||
|  | 
 | ||||
|  | Maintainer | ||||
|  | ========== | ||||
|  | .. image:: https://cybrosys.com/images/logo.png | ||||
|  |    :target: https://cybrosys.com | ||||
|  | 
 | ||||
|  | This module is maintained by Cybrosys Technologies. | ||||
|  | 
 | ||||
|  | For support and more information, please visit `Our Website <https://cybrosys.com/>`__ | ||||
|  | 
 | ||||
|  | Further information | ||||
|  | =================== | ||||
|  | HTML Description: `<static/description/index.html>`__ | ||||
| @ -0,0 +1,23 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2020-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | ||||
|  | #    Author: Niyas Raphy and Sreejith P (odoo@cybrosys.com) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    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 (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | 
 | ||||
|  | from . import models | ||||
| @ -0,0 +1,41 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2020-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | ||||
|  | #    Author: Niyas Raphy and Sreejith P (odoo@cybrosys.com) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    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 (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | 
 | ||||
|  | { | ||||
|  |     'name': 'Product Barcode Generator', | ||||
|  |     'version': '14.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.png'], | ||||
|  |     'license': 'AGPL-3', | ||||
|  |     'installable': True, | ||||
|  |     'application': False, | ||||
|  |     'auto_install': False, | ||||
|  | } | ||||
| @ -0,0 +1,6 @@ | |||||
|  | ## Module <product_barcode> | ||||
|  | 
 | ||||
|  | #### 10.08.2020 | ||||
|  | #### Version 14.0.1.0.0 | ||||
|  | ##### ADD | ||||
|  | - Initial Commit | ||||
| @ -0,0 +1,22 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2020-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | ||||
|  | #    Author: Niyas Raphy and Sreejith P (odoo@cybrosys.com) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    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 (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | from . import product_form | ||||
| @ -0,0 +1,97 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2020-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | ||||
|  | #    Author: Niyas Raphy and Sreejith P (odoo@cybrosys.com) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    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 (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | 
 | ||||
|  | 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)) | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | class ProductTemplateAutoBarcode(models.Model): | ||||
|  |     _inherit = 'product.template' | ||||
|  | 
 | ||||
|  |     @api.model | ||||
|  |     def create(self, vals_list): | ||||
|  |         templates = super(ProductTemplateAutoBarcode, self).create(vals_list) | ||||
|  |         ean = generate_ean(str(templates.id)) | ||||
|  |         templates.barcode = ean | ||||
|  |         return templates | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||||
| After Width: | Height: | Size: 72 KiB | 
| After Width: | Height: | Size: 130 KiB | 
| After Width: | Height: | Size: 50 KiB | 
| After Width: | Height: | Size: 20 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,52 @@ | |||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||
|  | <odoo> | ||||
|  | 
 | ||||
|  |     <data> | ||||
|  |         <template id="report_simple_label" inherit_id="product.report_simple_barcode"> | ||||
|  |             <xpath expr="//div" 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.product_template_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.responsible_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