Skip to content

Commit

Permalink
Merge branch '17.0' of https://github.com/OmniaGit/odooplm.git into 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Feb 10, 2025
1 parent c10d06c commit 00d5f64
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 23 deletions.
8 changes: 8 additions & 0 deletions activity_validation/models/mail_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,11 @@ def name_get(self):
activity.summary or activity.activity_type_id.display_name, activity.user_id.display_name or '')
out.append((activity.id, name))
return out

def unlink(self):
for activity in self:
if activity.activity_type_id.id in [self.env.ref('plm.mail_activity_plm_activity').id]:
return
return super(MailActivity, self).unlink()


20 changes: 20 additions & 0 deletions plm/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,26 @@ def _file_delete(self, fname):
def GetNextDocumentName(self, documentName):
"""
Return a new name due to sequence next number.
NEW client set in the contex this informations
{
#
#
#
'document_attrs': {} # dictionary like of attribute changed for products
'product_attrs': {} # dictionary like of attribute changed for documents
'ori_document_attrs': {} # dictionary like of attribute from cad application for products
'orig_product_attrs': {} # dictionary like of attribute from cad application for documents
'mode':'ir.attachment' or 'product.product'
#
# those other value are for compatibylity with the old version
#
'active_file_doc_attrs': {},
'all_attributes': {'product': self.attributes,
'document':self._documentAttrs
},
#
'mode':'ir.attachment'
"""
ctx = self.env.context
eng_code = ctx.get('product_attrs', {}).get("engineering_code") or ctx.get('engineering_code', '')
Expand Down
33 changes: 14 additions & 19 deletions plm_box/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,21 @@ 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'

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
5 changes: 2 additions & 3 deletions plm_box/models/plm_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ def getBoxes(self, boxes={}):
@api.model
def getDocDictValues(self, docBrws):
getCheckOutUser = ''
plmDocObj = self.env.get('ir.attachment')
docState = plmDocObj.getDocumentState({'docName': docBrws.name})
docState = docBrws.getDocumentState()
if docState in ['check-out', 'check-out-by-me']:
getCheckOutUser = docBrws.getCheckOutUser()
writeVal = datetime.datetime.strptime(docBrws.write_date, DEFAULT_SERVER_DATETIME_FORMAT)
Expand Down Expand Up @@ -539,7 +538,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 docBrws.getDocumentState() != 'check-in':
return [], docId
wr_date = docBrws.write_date
if wr_date != 'n/a':
Expand Down
3 changes: 2 additions & 1 deletion plm_project/models/mail_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def _action_done(self, feedback=False, attachment_ids=False):
return messages, activities

def checkProdConfirmedType(self, activity):
if activity.activity_type_id == self.env.ref('plm_project.mail_activity_product_confirmed'):
if activity.activity_type_id.id in [self.env.ref('plm_project.mail_activity_product_confirmed').id]:
return True

return False

def checkSameUser(self, activity):
Expand Down

0 comments on commit 00d5f64

Please sign in to comment.