Skip to content

Commit

Permalink
[ADD] getDocumentState Method
Browse files Browse the repository at this point in the history
  • Loading branch information
jayraj-omnia committed Dec 19, 2024
1 parent 431b319 commit d729645
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions plm_box/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,16 @@ def checkDocumentPresent(self, doc_dict={}):
logging.info('Box sincronize res %r' % (doc_dict))
return doc_dict

def getDocumentState(self):
for docBrws in self:
checkedOutByMe = docBrws._is_checkedout_for_me()
checkedIn = docBrws.ischecked_in()
if checkedOutByMe:
return 'check-out-by-me'
if not checkedIn:
return 'check-out'
else:
return 'check-in'
return 'check-out-by-me'

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4 changes: 2 additions & 2 deletions plm_box/models/plm_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def checkIfDocChanged(self, values):
docBrwsList = ir_attachment.search([("name", "=", name)])
for docBrws in docBrwsList:
docId = docBrws.id
if ir_attachment.getDocumentState({"docName": name}) != "check-in":
if ir_attachment.getDocumentState() != "check-in":
return [], docId
wr_date = docBrws.write_date
if wr_date != "n/a":
Expand Down Expand Up @@ -714,7 +714,7 @@ def getDocDictValues(self, docBrws):
getCheckOutUser = ""
plmDocObj = self.env.get("ir.attachment")

docState = plmDocObj.getDocumentState({"docName": docBrws.name})
docState = plmDocObj.getDocumentState()
if docState in ["check-out", "check-out-by-me"]:
getCheckOutUser = docBrws.getCheckOutUser()
writeVal = docBrws.write_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
Expand Down

0 comments on commit d729645

Please sign in to comment.