From 09428d83533d7e7e0102aca4f950d99fc1747a39 Mon Sep 17 00:00:00 2001 From: Matteo Boscolo Date: Sat, 21 Dec 2024 08:17:06 +0100 Subject: [PATCH] FIX: issues on adding document --- plm_box/models/ir_attachment.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plm_box/models/ir_attachment.py b/plm_box/models/ir_attachment.py index 571170e4..e4ca4a05 100755 --- a/plm_box/models/ir_attachment.py +++ b/plm_box/models/ir_attachment.py @@ -144,16 +144,14 @@ def checkOutOrFalse(self, docDict): return False @api.model - def saveBoxDocRel(self, docDict,doc_id): - docName = docDict.get("docName", "") - boxName = docDict.get("boxName", "") + def saveBoxDocRel(self, + box_id, + doc_id): boxObj = self.env.get("plm.box") - boxBrwsList = boxObj.search([("name", "=", boxName)]) - for boxBrws in boxBrwsList: - docId = self.search([("name", "=", docName)]).ids - if docId: - res = boxBrws.write({"document_rel": [(4, docId[0])]}) - return res + for boxBrws in boxObj.search([("id", "=", box_id)]): + if doc_id: + res = boxBrws.write({"document_rel": [(4, doc_id)]}) + return True return False @api.model