Skip to content

Commit

Permalink
IMP: fix plm box client error
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Jan 15, 2025
1 parent 57899fd commit eb73131
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 35 deletions.
33 changes: 14 additions & 19 deletions plm_box/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,27 +169,22 @@ def updateDocValues(self, valuesDict):
def returnDocsOfFilesChanged(self, valuesDict):
outDocs = []
for docName, (docContent, _writeDateClient) in valuesDict.items():
if self.getDocumentState({"docName": docName}) == "check-out-by-me":
docBrowseList = self.search([("name", "=", docName)])
for docBrowse in docBrowseList:
if docBrowse.datas != docContent:
outDocs.append(docName)
for ir_attachment_id in self.search([("name", "=", docName)]):
if ir_attachment_id.datas != docContent \
and ir_attachment_id.getDocumentState() == "check-out-by-me":
outDocs.append(docName)
return outDocs

@api.model
def getDocumentState(self, vals):
docName = vals.get("docName", "")
docBrwsList = self.search([("name", "=", docName)])
for docBrws in docBrwsList:
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"
def getDocumentState(self):
self.ensure_one()
checkedOutByMe = self._is_checkedout_for_me()
checkedIn = self.ischecked_in()
if checkedOutByMe:
return 'check-out-by-me'
if checkedIn:
return 'check-in'
else:
return 'check-out'

@api.model
def checkDocumentPresent(self, doc_dict={}):
Expand Down
28 changes: 13 additions & 15 deletions plm_box/models/plm_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,26 +809,24 @@ def setupTooltipFields(self, vals, tooltip_fields):
return out

@api.model
def getDocDictValues(self, docBrws):
def getDocDictValues(self, ir_attachment_id):
getCheckOutUser = ""
plmDocObj = self.env.get("ir.attachment")

docState = plmDocObj.getDocumentState()
docState = ir_attachment_id.getDocumentState()
if docState in ["check-out", "check-out-by-me"]:
getCheckOutUser = docBrws.getCheckOutUser()
writeVal = docBrws.write_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
getCheckOutUser = ir_attachment_id.getCheckOutUser()
writeVal = ir_attachment_id.write_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)

return {
"id": docBrws.id,
"name": docBrws.engineering_code,
"engineering_revision": docBrws.engineering_revision,
"datas_fname": docBrws.name,
"create_date": docBrws.create_date,
"id": ir_attachment_id.id,
"name": ir_attachment_id.engineering_code,
"engineering_revision": ir_attachment_id.engineering_revision,
"datas_fname": ir_attachment_id.name,
"create_date": ir_attachment_id.create_date,
"write_date": correctDate(writeVal, self.env.context),
"description": docBrws.description,
"fileName": docBrws.name,
"state": docBrws.engineering_state,
"readonly": self.docReadonlyCompute(docBrws.id),
"description": ir_attachment_id.description,
"fileName": ir_attachment_id.name,
"state": ir_attachment_id.engineering_state,
"readonly": self.docReadonlyCompute(ir_attachment_id.id),
"checkoutUser": getCheckOutUser,
}

Expand Down
2 changes: 1 addition & 1 deletion plm_box/views/ir_attachment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<field name="create_date"/>
<field name="write_uid"/>
<field name="write_date"/>

<field name="is_checkout" invisible="True"/>
</list>
</field>
</record>
Expand Down

0 comments on commit eb73131

Please sign in to comment.