Hi All,
I'm trying to generate qr code for employee name in my custom module but Iam unable to write the barcode url..and would like to share the code which i have written in my custom module.
class Employee_table(models.Model):
_inherit = 'hr.employee'
def get_image(self, value, width, hight, hr, code='QR'):
""" genrating image for barcode """
options = {}
if width:options['width'] = 150
if hight:options['hight'] = 150
if hr:options['humanReadable'] = True
try:
ret_val = createBarcodeDrawing(code, value=str(value), **options)
except Exception, e:
raise ValueError(e)
return base64.encodestring(ret_val.asString('jpg'))
@api.multi
def _compute_barcode_urll(self):
dom_name = self.env['base.config.settings'].search([], limit=1)
for record in self:
if record.name_related:
if dom_name.alias_domain:
domain_nm = dom_name.alias_domain
else:
domain_nm = 'localhost:8069'
record.barcode_urll = "%s/hr/%s?" % (domain_nm, slug(record.name_related))
image = self.get_image(record.barcode_urll,
code='QR',
width=150, hight=150,
hr=True)
record.write({'qr_image1': image})
barcode_urll = fields.Char(compute='_compute_barcode_urll', string='Related URL')
qr_image1 = fields.Binary('Barcode Image')
but iam getting following error.
Odoo Server Error
Traceback (most recent call last): File "/home/autochip/Music/odoo/9.0/openerp/http.py", line 643, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/autochip/Music/odoo/9.0/openerp/http.py", line 680, in dispatch result = self._call_function(**self.params) File "/home/autochip/Music/odoo/9.0/openerp/http.py", line 316, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/autochip/Music/odoo/9.0/openerp/service/model.py", line 118, in wrapper return f(dbname, *args, **kwargs) File "/home/autochip/Music/odoo/9.0/openerp/http.py", line 309, in checked_call result = self.endpoint(*a, **kw) File "/home/autochip/Music/odoo/9.0/openerp/http.py", line 959, in __call__ return self.method(*args, **kw) File "/home/autochip/Music/odoo/9.0/openerp/http.py", line 509, in response_wrap response = f(*args, **kw) File "/home/autochip/Music/odoo/9.0/addons/web/controllers/main.py", line 892, in call_kw return self._call_kw(model, method, args, kwargs) File "/home/autochip/Music/odoo/9.0/addons/web/controllers/main.py", line 884, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File "/home/autochip/Music/odoo/9.0/openerp/api.py", line 250, in wrapper return old_api(self, *args, **kwargs) File "/home/autochip/Music/odoo/9.0/openerp/models.py", line 3193, in read result = BaseModel.read(records, fields, load=load) File "/home/autochip/Music/odoo/9.0/openerp/api.py", line 248, in wrapper return new_api(self, *args, **kwargs) File "/home/autochip/Music/odoo/9.0/openerp/models.py", line 3239, in read values[name] = field.convert_to_read(record[name], use_name_get) File "/home/autochip/Music/odoo/9.0/openerp/models.py", line 5740, in __getitem__ return self._fields[key].__get__(self, type(self)) File "/home/autochip/Music/odoo/9.0/openerp/fields.py", line 828, in __get__ self.determine_value(record) File "/home/autochip/Music/odoo/9.0/openerp/fields.py", line 935, in determine_value self.compute_value(recs) File "/home/autochip/Music/odoo/9.0/openerp/fields.py", line 890, in compute_value self._compute_value(records) File "/home/autochip/Music/odoo/9.0/openerp/fields.py", line 880, in _compute_value getattr(records, self.compute)() File "/home/autochip/Music/odoo/9.0/openerp/api.py", line 248, in wrapper return new_api(self, *args, **kwargs) File "/home/autochip/Music/odoo/9.0/addons/wms/qrcode.py", line 69, in _compute_barcode_urll record.barcode_urll = "%s/hr/%s?" % (domain_nm, slug(record.name_related)) File "/home/autochip/Music/odoo/9.0/addons/website/models/website.py", line 113, in slug id, name = value ValueError: too many values to unpack
Kindly can anyone help me to correct my code?