diff options
| author | Ivan Yelizariev <iel@odoo.com> | 2020-12-07 10:22:27 +0000 |
|---|---|---|
| committer | Ivan Yelizariev <iel@odoo.com> | 2020-12-07 10:22:27 +0000 |
| commit | fd477f3f6d331355b5667a12b43d1c4a110b7e21 (patch) | |
| tree | d9c46bedd64f4660e60103ffbf2aa2ef0bf6b2ac /addons/pos_cache | |
| parent | 7e9d052beabe15d932e5d403f8ca2f4837c7d24f (diff) | |
[FIX] pos_cache: fix error on opening POS
STEP:
* install pos_cache
* create some products (this step is not needed in demo database)
* open POS
BEFORE: error "TypeError: Object of type 'datetime' is not JSON serializable"
AFTER: no errors
WHY:
* Since Odoo 12 date fields are not strings: https://github.com/odoo/odoo/commit/960360afe478a8f7b9c456721b5591154952a37d
* Since Odoo 14 fields lists to read contains write_date:
https://github.com/odoo/odoo/commit/c6397ab3b3654da336a4269a81d5d91016baf520 --
see models.js
---
opw-2410334
closes odoo/odoo#62952
Signed-off-by: Ivan Yelizariev // IEL <yelizariev@users.noreply.github.com>
Diffstat (limited to 'addons/pos_cache')
| -rw-r--r-- | addons/pos_cache/models/pos_cache.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/pos_cache/models/pos_cache.py b/addons/pos_cache/models/pos_cache.py index 74e2a99019b..b0a1252f71e 100644 --- a/addons/pos_cache/models/pos_cache.py +++ b/addons/pos_cache/models/pos_cache.py @@ -5,6 +5,7 @@ import json from ast import literal_eval from odoo import models, fields, api +from odoo.tools import date_utils class pos_cache(models.Model): @@ -30,7 +31,7 @@ class pos_cache(models.Model): display_default_code=False, lang=cache.compute_user_id.lang) res = prod_ctx.read(cache.get_product_fields()) cache.write({ - 'cache': base64.encodebytes(json.dumps(res).encode('utf-8')), + 'cache': base64.encodebytes(json.dumps(res, default=date_utils.json_default).encode('utf-8')), }) @api.model |
