Skip to content

Commit

Permalink
FIX: problem on copy of non plm attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Nov 1, 2023
1 parent 00106f6 commit 38cdd32
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions plm/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,31 +619,31 @@ def copy(self, defaults={}):
"""
Overwrite the default copy method
"""
documentRelation = self.env['ir.attachment.relation']
docBrwsList = documentRelation.search([('parent_id', '=', self.id)])
previous_name = self.engineering_code
if 'engineering_code' not in defaults:
new_name = 'Copy of %s' % previous_name
documents = self.search([('engineering_code', '=', new_name)], order='engineering_revision')
if len(documents) > 0:
new_name = '%s (%s)' % (new_name, len(documents) + 1)
defaults['engineering_code'] = new_name
# TODO: verifie if document is renamed ??!!
# fname, filesize = self._manageFile()
# defaults['store_fname'] = fname
# defaults['file_size'] = filesize
defaults['engineering_state'] = START_STATUS
defaults['engineering_writable'] = True
newDocBrws = super(IrAttachment, self).copy(defaults)
if newDocBrws:
newDocBrws.message_post(body=_('Copied starting from : %s.' % previous_name))
for brwEnt in docBrwsList:
documentRelation.create({
'parent_id': newDocBrws.id,
'child_id': brwEnt.child_id.id,
'configuration': brwEnt.configuration,
'link_kind': brwEnt.link_kind,
})
if not self.is_plm:
defaults['engineering_code']=False
newDocBrws = super(IrAttachment, self).copy(defaults)
else:
documentRelation = self.env['ir.attachment.relation']
docBrwsList = documentRelation.search([('parent_id', '=', self.id)])
previous_name = self.engineering_code
if 'engineering_code' not in defaults:
new_name = 'Copy of %s' % previous_name
documents = self.search([('engineering_code', '=', new_name)], order='engineering_revision')
if len(documents) > 0:
new_name = '%s (%s)' % (new_name, len(documents) + 1)
defaults['engineering_code'] = new_name
newDocBrws = super(IrAttachment, self).copy(defaults)
if newDocBrws:
newDocBrws.message_post(body=_('Copied starting from : %s.' % previous_name))
for brwEnt in docBrwsList:
documentRelation.create({
'parent_id': newDocBrws.id,
'child_id': brwEnt.child_id.id,
'configuration': brwEnt.configuration,
'link_kind': brwEnt.link_kind,
})
return newDocBrws

@api.model
Expand Down

0 comments on commit 38cdd32

Please sign in to comment.