Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to configure the Barcode through Python code in OpenERP(Odoo)?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 786
    Comment on it

    In below example I have written Python script to configure barcode. It will print one barcode on each page based on quantity available of selected products. Like below python code in .py file :

      import logging
    
    from openerp.osv import fields, orm
    
    _logger = logging.getLogger(__name__)
    try:
        from reportlab.graphics.barcode import getCodes
    except ImportError:
        _logger.warning('unable to import reportlab')
    
    
    def _get_code(self, cr, uid, context=None):
        """get availble code """
        return [(r, r) for r in getCodes()]
    
    
    class tr_barcode_config(orm.Model):
        _name = 'tr.barcode.config'
        _columns = {
            'res_model': fields.many2one('ir.model', 'Object',
                                         domain=[('barcode_model', '=', True)],
                                         required=True),
            'field': fields.many2one('ir.model.fields', 'Field',
                                     domain=[('ttype', '=', 'char')],
                                     required=True),
            'width': fields.integer("Width",
                         help="Leave Blank or 0(ZERO) for default size"),
            'height': fields.integer("Height",
                         help="Leave Blank or 0(ZERO) for default size"),
            'hr_form': fields.boolean("Human Readable",
                         help="To generate Barcode In Human readable form"),
            'barcode_type': fields.selection(_get_code, 'Type', required=True),
            }
        _sql_constraints = [
            ('res_model_uniq',
             'unique(res_model)',
             'You can have only one config by model !'),
            ]
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: