Skip to content

Commit

Permalink
Merge PR #26 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed May 10, 2024
2 parents 2eaec7c + 63be257 commit 16b7c8c
Showing 1 changed file with 18 additions and 9 deletions.
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 @@ def get_spreadsheet_data(self):
"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 @@ def send_spreadsheet_message(self, message):
"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

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

0 comments on commit 16b7c8c

Please sign in to comment.