Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] spreadsheet_oca: Cannot open spreadsheet when using undo / redo commands #26

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions spreadsheet_oca/models/spreadsheet_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import json

from odoo import fields, models
from odoo import api, fields, models
from odoo.exceptions import AccessError


Expand Down Expand Up @@ -31,13 +31,11 @@
"name": self.name,
"spreadsheet_raw": self.spreadsheet_raw,
"revisions": [
{
"type": revision.type,
"clientId": revision.client_id,
"nextRevisionId": revision.next_revision_id,
"serverRevisionId": revision.server_revision_id,
"commands": json.loads(revision.commands),
}
dict(
json.loads(revision.commands),
nextRevisionId=revision.next_revision_id,
serverRevisionId=revision.server_revision_id,
)
for revision in self.spreadsheet_revision_ids
],
"mode": mode,
Expand All @@ -64,12 +62,23 @@
"client_id": message.get("clientId"),
"next_revision_id": message["nextRevisionId"],
"server_revision_id": message["serverRevisionId"],
"commands": json.dumps(message.get("commands", [])),
"commands": json.dumps(
self._build_spreadsheet_revision_commands_data(message)
),
}
)
self.env["bus.bus"]._sendone(channel, "spreadsheet_oca", message)
return True

@api.model
def _build_spreadsheet_revision_commands_data(self, message):
"""Prepare spreadsheet revision commands data from the message"""
commands = dict(message)
commands.pop("serverRevisionId", None)
commands.pop("nextRevisionId", None)
commands.pop("clientId", None)
return commands

Check warning on line 80 in spreadsheet_oca/models/spreadsheet_abstract.py

View check run for this annotation

Codecov / codecov/patch

spreadsheet_oca/models/spreadsheet_abstract.py#L76-L80

Added lines #L76 - L80 were not covered by tests

def write(self, vals):
if "spreadsheet_raw" in vals:
self.spreadsheet_revision_ids.unlink()
Expand Down
Loading