Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

error decoding value

Naroči se

Get notified when there's activity on this post

This question has been flagged
4415 Prikazi
Avatar
GiancaFTx

good night, I am testing a module to send the bbdd backup to google drive but this error appears to me. I think the error is in the json.dumps (for), but I don't identify why it might be happening. I would appreciate any help. release: odoo12

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 350, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
  File "", line 1, in <module>
  File "/mnt/extra-addons/auto_backup_upload/models/db_backup.py", line 174, in schedule_backup
    self.google_drive_upload(rec, file_path, bkp_file)
  File "/mnt/extra-addons/auto_backup_upload/models/db_backup.py", line 218, in google_drive_upload
    response = r.json()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 850, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 654, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 312, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 696, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 344, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 337, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 939, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 517, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 966, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 954, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 749, in call_kw
    return _call_kw_multi(method, model, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 736, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_cron.py", line 76, in method_direct_trigger
    self.sudo(user=cron.user_id.id).ir_actions_server_id.run()
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions.py", line 565, in run
    res = func(action, eval_context=eval_context)
  File "/usr/lib/python3/dist-packages/odoo/addons/website/models/ir_actions.py", line 57, in run_action_code_multi
    res = super(ServerAction, self).run_action_code_multi(action, eval_context)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions.py", line 441, in run_action_code_multi
    safe_eval(action.sudo().code.strip(), eval_context, mode="exec", nocopy=True)  # nocopy allows to return 'action'
  File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 373, in safe_eval
    pycompat.reraise(ValueError, ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr)), exc_info[2])
  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 86, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 350, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
  File "", line 1, in <module>
  File "/mnt/extra-addons/auto_backup_upload/models/db_backup.py", line 174, in schedule_backup
    self.google_drive_upload(rec, file_path, bkp_file)
  File "/mnt/extra-addons/auto_backup_upload/models/db_backup.py", line 218, in google_drive_upload
    response = r.json()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 850, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
ValueError: <class 'json.decoder.JSONDecodeError'>: "Expecting value: line 1 column 1 (char 0)" while evaluating
'model.schedule_backup()'

@api.model def schedule_backup(self): conf_ids = self.search([]) for rec in conf_ids: db_list = self.get_db_list(rec.host, rec.port) if rec.name in db_list: try: if not os.path.isdir(rec.folder): os.makedirs(rec.folder) except: raise # Create name for dumpfile. user_tz = pytz.timezone(self.env.context.get('tz') or self.env.user.tz) date_today = pytz.utc.localize(datetime.datetime.today()).astimezone(user_tz) bkp_file = '%s_%s.%s' % (rec.name,date_today.strftime('%Y-%m-%d_%H_%M_%S'), rec.backup_type) file_path = os.path.join(rec.folder, bkp_file) uri = 'http://' + rec.host + ':' + rec.port conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/db') bkp = '' try: # try to backup database and write it away fp = open(file_path, 'wb') odoo.service.db.dump_db(rec.name, fp, rec.backup_type) fp.close() except Exception as error: _logger.debug( "Couldn't backup database %s. Bad database administrator password for server running at http://%s:%s" % ( rec.name, rec.host, rec.port)) _logger.debug("Exact error from the exception: " + str(error)) continue else: _logger.debug("database %s doesn't exist on http://%s:%s" % (rec.name, rec.host, rec.port)) """ Remove all old files (on local server) in case this is configured.. """ if rec.autoremove: dir = rec.folder # Loop over all files in the directory. for f in os.listdir(dir): fullpath = os.path.join(dir, f) # Only delete the ones wich are from the current database # (Makes it possible to save different databases in the same folder) if rec.name in fullpath: timestamp = os.stat(fullpath).st_ctime createtime = datetime.datetime.fromtimestamp(timestamp) now = datetime.datetime.now() delta = now - createtime if delta.days >= rec.days_to_keep: # Only delete files (which are .dump and .zip), no directories. if os.path.isfile(fullpath) and (".dump" in f or '.zip' in f): _logger.info("Delete local out-of-date file: " + fullpath) os.remove(fullpath) self.google_drive_upload(rec, file_path, bkp_file)

@api.multi def google_drive_upload(self, rec, file_path, bkp_file): g_drive = self.env['google.drive.config'] access_token = GoogleDrive.get_access_token(g_drive) # GOOGLE DRIVE UPLOAP if rec.is_upload: headers = {"Authorization": "Bearer %s" % (access_token)} para = { "name": "%s" % (str(bkp_file)), "parents": ["%s" % (str(rec.drive_folder_id))] } files = { 'data': ('metadata', json.dumps(para), 'application/json; charset=UTF-8'), 'file': open("%s" % (str(file_path)), "rb") } r = requests.post( "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", headers=headers, files=files ) # SENDING EMAIL NOTIFICATION if r.status_code == 200: email_to = "" for record in rec.gdrive_email_notif_ids.mapped('login'): email_to += record + ',' notification_template = self.env['ir.model.data'].sudo().get_object('auto_backup_upload', 'email_google_drive_upload') values = notification_template.generate_email(self.id) values['email_from'] = self.env['res.users'].browse(self.env.uid).company_id.email values['email_to'] = email_to values['subject'] = "Google Drive Upload Successful" values['body_html'] = "<h3>Backup Successfully Uploaded!</h3>" \ "Please see below details. <br/> <br/> " \ "<b>Backup File: %s" % (str(bkp_file)) + \ " <a href='https://drive.google.com/drive/u/0/folders/%s'>Open</a></b>" % ( str(rec.drive_folder_id)) send_mail = self.env['mail.mail'].create(values) send_mail.send(True) else: response = r.json() code = response['error']['code'] message = response['error']['errors'][0]['message'] reason = response['error']['errors'][0]['reason'] email_to = "" for rec in rec.gdrive_email_notif_ids.mapped('login'): email_to += rec + ',' notification_template = self.env['ir.model.data'].sudo().get_object('auto_backup_upload', 'email_google_drive_upload') values = notification_template.generate_email(self.id) values['email_from'] = self.env['res.users'].browse(self.env.uid).company_id.email values['email_to'] = email_to values['subject'] = "Google Drive Upload Failed" values['body_html'] = "<h3>Backup Upload Failed!</h3>" \ "Please see below details. <br/> <br/> " \ "<table style='width:100%'>" \ "<tr> " \ "<th align='left'>Backup</th>" \ "<td>" + (str(bkp_file)) + "</td></tr>" \ "<tr> " \ "<th align='left'>Code</th>" \ "<td>" + str(code) + "</td>" \ "</tr>" \ "<tr>" \ "<th align='left'>Message</th>" \ "<td>" + str( message) + "</td>" \ "</tr>" \ "<tr>" \ "<th align='left'>Reason</th>" \ "<td>" + str(reason) + "</td>" \ "</tr> " \ "</table>" send_mail = self.env['mail.mail'].create(values) send_mail.send(True)
0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now