Skip to content

Commit

Permalink
connector_importer: invalidate cache and flush pending computations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardoalso authored and thienvh332 committed Oct 21, 2024
1 parent 409bff3 commit cf0b05a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions connector_importer/models/recordset.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ def _set_serialized(self, fname, values, reset=False):
json_report_data = json.dumps(_values)
_values = base64.b64encode(bytes(json_report_data, "utf-8"))
setattr(self, fname, _values)
# We need to invalidate the cache because the context dict
# bin_size=False triggers the _compute_datas(self) method
# which has the @api.depends_context('bin_size') decorator.
# Flush all pending computations and updates to the database.
domain = [
("res_model", "=", self._name),
("res_field", "=", fname),
("res_id", "in", self.ids),
]
attachments = self.env["ir.attachment"].sudo().search(domain)
if attachments:
attachments.invalidate_recordset(("datas", "raw"))

# Without invalidating cache we will have a bug because of Serialized
# field in odoo. It uses json.loads on convert_to_cache, which leads
# to all of our int dict keys converted to strings. Except for the
Expand Down

0 comments on commit cf0b05a

Please sign in to comment.