Skip to content

Commit

Permalink
[FIX] dms_version: let non-revision files be unarchived
Browse files Browse the repository at this point in the history
  • Loading branch information
len-foss committed Dec 16, 2023
1 parent 4488afc commit dfdfbbc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dms_version/models/dms_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,17 @@ def create(self, values):
res.origin_id = res
return res

def write(self, vals):
if (
not self.env.context.get("restore_old_revision", False)
and "active" in vals
and vals["active"]
def _check_cannot_unarchive_revision(self):
if not self.env.context.get("restore_old_revision") and any(
r.origin_id and r.origin_id != r for r in self
):
raise exceptions.UserError(
_("Please use the restore button to activate this revision.")
)

def write(self, vals):
if vals.get("active"):
self._check_cannot_unarchive_revision()
if vals.get("content"):
versions = self.filtered(lambda x: x.has_versioning)
versions = versions.with_context(
Expand Down

0 comments on commit dfdfbbc

Please sign in to comment.