Skip to content

Commit

Permalink
IMP: First working version
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Nov 8, 2024
1 parent f588467 commit df18822
Show file tree
Hide file tree
Showing 116 changed files with 624 additions and 592 deletions.
2 changes: 1 addition & 1 deletion activity_validation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
"name": "Activity Validation",
"version": "17.0.0.1",
"version": "18.0.0.1",
"author": "OmniaSolutions",
"website": "https://github.com/OmniaGit/odooplm",
"category": "Custom",
Expand Down
24 changes: 12 additions & 12 deletions activity_validation/views/mail_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<odoo>
<data>

<record id="mail_activity_view_tree_activity_validation" model="ir.ui.view">
<field name="name">mail.activity.view.tree.activity.validation</field>
<record id="mail_activity_view_list_activity_validation" model="ir.ui.view">
<field name="name">mail.activity.view.list.activity.validation</field>
<field name="model">mail.activity</field>
<field name="inherit_id" ref="mail.mail_activity_view_tree"/>
<field name="inherit_id" ref="mail.mail_activity_view_list"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='activity_type_id']" position="after">
<field name="user_id"/>
Expand Down Expand Up @@ -80,12 +80,12 @@
nolabel="1"
invisible="change_activity_type != 'request'"
readonly="plm_state=='eco'">
<tree editable='bottom'>
<list editable='bottom'>
<field name="name"/>
<field name="user_id"/>
<field name="activity_user_id"/>
<field name="plm_state" />
</tree>
</list>
</field>
<field name="default_plm_activity" invisible="True"/>
<field name="res_model_id" invisible="True"/>
Expand All @@ -95,15 +95,15 @@
nolabel="1"
invisible="has_parent==True or has_parent_eco==True or plm_state not in ['eco', 'done']"
context="{'default_res_model_id': res_model_id, 'default_activity_type_id': default_plm_activity}">
<tree editable='bottom' >
<list editable='bottom' >
<field name="res_model" invisible="True"/>
<field name="activity_type_id" invisible="True"/>
<field name="summary"/>
<field name="date_deadline"/>
<field name="activity_user_id"/>
<field name="plm_state" readonly="True"/>
<field name="res_model_id" invisible="True"/>
</tree>
</list>
</field>
</xpath>

Expand Down Expand Up @@ -171,12 +171,12 @@
nolabel="1"
invisible="change_activity_type != 'request'"
readonly="plm_state=='eco'">
<tree editable='bottom'>
<list editable='bottom'>
<field name="name"/>
<field name="user_id"/>
<field name="activity_user_id"/>
<field name="plm_state" />
</tree>
</list>
</field>
<field name="default_plm_activity" invisible="True"/>
<label for="eco_child_ids"
Expand All @@ -185,7 +185,7 @@
nolabel="1"
invisible="has_parent==True or has_parent_eco==True or plm_state not in ['eco', 'done']"
context="{'default_res_model_id': res_model_id, 'default_activity_type_id': default_plm_activity, 'default_res_id': res_id}">
<tree editable='bottom' can_create="true" >
<list editable='bottom' can_create="true" >
<field name="res_name" invisible="True"/>
<field name="res_model" invisible="True"/>
<field name="activity_type_id" invisible="True"/>
Expand All @@ -194,7 +194,7 @@
<field name="user_id"/>
<field name="plm_state" readonly="True"/>
<field name="res_model_id" invisible="True"/>
</tree>
</list>
</field>
</xpath>

Expand Down Expand Up @@ -246,7 +246,7 @@
<record model="ir.actions.act_window" id="plm_action_view_activities">
<field name="name">Activities</field>
<field name="res_model">mail.activity</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>

<menuitem
Expand Down
9 changes: 4 additions & 5 deletions activity_validation/views/mail_activity_children_rel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
<odoo>
<data>

<record model="ir.ui.view" id="mail_activity_children_rel_tree">
<field name="name">mail.activity.children.rel.tree</field>
<record model="ir.ui.view" id="mail_activity_children_rel_list">
<field name="name">mail.activity.children.rel.list</field>
<field name="model">mail.activity.children.rel</field>
<field name="type">tree</field>
<field name="priority" eval="1"/>
<field name="arch" type="xml">
<tree string="Children activities">
<list string="Children activities">
<field name="name"/>
<field name="user_id" invisible ="'mail_children_activity_id', '!=', False"/>
<field name="activity_user_id" invisible="'mail_children_activity_id', '==', False"/>
<field name="mail_children_activity_id"/>
<field name="plm_state"/>
</tree>
</list>
</field>
</record>

Expand Down
6 changes: 6 additions & 0 deletions only_on_non_sh_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ezdxf
matplotlib
cadquery
numpy-stl
--pre cadquery
base64io
2 changes: 1 addition & 1 deletion plm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################
{
"name": "Product Lifecycle Management",
"version": "17.0.0.5",
"version": "18.0.0.1",
"author": "OmniaSolutions",
"website": "https://odooplm.omniasolutions.website",
"category": "Manufacturing/Product Lifecycle Management (PLM)",
Expand Down
138 changes: 124 additions & 14 deletions plm/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import random
import string
import os
import io
import binascii
from base64io import Base64IO
import time
import json
import copy
Expand Down Expand Up @@ -364,28 +367,28 @@ def getRelatedOneLevelLinks(self, doc_id, kinds):
return list(set(result))

@api.model
def getRelatedLyTree(self, doc_id):
def getRelatedLyTree(self, doc_id, optional_return_type=['3d']):
out = []
if not doc_id:
logging.warning('Cannot get links from %r document' % (doc_id))
return []
doc_brws = self.browse(doc_id)
doc_type = doc_brws.document_type
parent_doc_type = doc_brws.document_type
to_search = [('link_kind', 'in', ['LyTree']),
'|',
('parent_id', '=', doc_id),
('child_id', '=', doc_id)]
doc_rel_ids = self.env['ir.attachment.relation'].search(to_search)
for doc_rel_id in doc_rel_ids:
if doc_type=='3d':
if parent_doc_type=='3d':
if doc_rel_id.parent_id.id==doc_id and doc_rel_id.child_id.document_type =='2d':
out.append(doc_rel_id.child_id.id)
elif doc_rel_id.child_id.id==doc_id and doc_rel_id.parent_id.document_type =='2d':
out.append(doc_rel_id.parent_id.id)
elif doc_type=='2d':
if doc_rel_id.parent_id.id==doc_id and doc_rel_id.child_id.document_type =='3d':
elif parent_doc_type=='2d':
if doc_rel_id.parent_id.id==doc_id and doc_rel_id.child_id.document_type in optional_return_type:
out.append(doc_rel_id.child_id.id)
elif doc_rel_id.child_id.id==doc_id and doc_rel_id.parent_id.document_type =='3d':
elif doc_rel_id.child_id.id==doc_id and doc_rel_id.parent_id.document_type in optional_return_type:
out.append(doc_rel_id.parent_id.id)
return list(set(out))

Expand Down Expand Up @@ -427,7 +430,9 @@ def _getRelatedPrTree(doc_id):
return list(set(out))

@api.model
def getRelatedRfTree(self, doc_id, recursion=True, evaluated=[]):
def getRelatedRfTree(self, doc_id, recursion=True, evaluated=False):
if not evaluated:
evaluated=[]
out = []
if not doc_id:
logging.warning('Cannot get links from %r document' % (doc_id))
Expand Down Expand Up @@ -1213,9 +1218,9 @@ def _is_checkout(self):
for ir_attachment_id in self:
_docName, _docRev, chekOutUser, _hostName = self.env['ir.attachment'].getCheckedOut(ir_attachment_id.id, None)
if chekOutUser:
ir_attachment_id.is_checkout = True
ir_attachment_id.with_context(check=False).is_checkout = True
else:
ir_attachment_id.is_checkout = False
ir_attachment_id.with_context(check=False).is_checkout = False

def getFileExtension(self, docBrws):
fileExtension = ''
Expand Down Expand Up @@ -2299,7 +2304,7 @@ def open_related_document_revisions(self):
return {'name': _('Attachment Revs.'),
'res_model': 'ir.attachment',
'view_type': 'form',
'view_mode': 'tree,form',
'view_mode': 'list,form',
'type': 'ir.actions.act_window',
'domain': [('id', 'in', ir_attachment_ids.ids)],
'context': {}}
Expand Down Expand Up @@ -2447,6 +2452,11 @@ def isDownloadableFromServer(self, args):

@api.model
def GetProductDocumentId(self, clientArgs):
product_product_id, plm_document_id = self._GetproductDocumentID(clientArgs)
return (False if not product_product_id else product_product_id.id,
False if not plm_document_id else plm_document_id.id)

def _GetproductDocumentID(self, clientArgs):
componentAtts, documentAttrs = clientArgs
product_product_id = False
plm_document_id = False
Expand All @@ -2455,14 +2465,14 @@ def GetProductDocumentId(self, clientArgs):
if engineering_code:
for product_product in self.env['product.product'].search([('engineering_code', '=', engineering_code),
('engineering_revision', '=', engineering_revision)]):
product_product_id = product_product.id
product_product_id = product_product
break
document_name = documentAttrs.get('engineering_code')
document_revision = documentAttrs.get('engineering_revision', 0)
if document_name:
for plm_document in self.env['ir.attachment'].search([('engineering_code', '=', document_name),
('engineering_revision', '=', document_revision)]):
plm_document_id = plm_document.id
plm_document_id = plm_document
break
return product_product_id, plm_document_id

Expand Down Expand Up @@ -3110,7 +3120,7 @@ def related_not_update(self):
return {'name': _('Attachment Relations.'),
'res_model': 'ir.attachment.relation',
'view_type': 'form',
'view_mode': 'kanban,tree,form',
'view_mode': 'kanban,list,form',
'type': 'ir.actions.act_window',
'domain': [('id', 'in', relation_ids.ids)],
'context': {}}
Expand All @@ -3126,8 +3136,108 @@ def open_related_dbthread(self):
return {'name': _('Saving Error'),
'res_model': 'plm.dbthread',
'view_type': 'form',
'view_mode': 'tree',
'view_mode': 'list',
'type': 'ir.actions.act_window',
'domain': [('id', 'in', plm_dbthread_ids.ids)],
'context': {}}
@api.model
def getCloneStructure(self,
args):
#
SUPPORT_MAIN_PRODUCT_ATTRIBUTES = [
'CONFIGURATION_NAME',
'CONFIGURATIONS',
'INTEGRATION_FILE_TYPE',
]
#
def getProduct_dict(product_product_id):
return {
'engineering_code': product_product_id.engineering_code,
'engineering_revision': product_product_id.engineering_revision,
'name':product_product_id.name,
'id':product_product_id.id
}
json_main_root_attributes, cloneRelatedDocuments = args
#
def get_clone_info_attr(doc_id, product_product_id=None):
ir_attachment=self.browse(doc_id)
if product_product_id:
product_dict=getProduct_dict(product_product_id)
else:
product_dict={}
for product_product_id in ir_attachment.linkedcomponents:
product_dict=getProduct_dict(product_product_id)
break

return {'document':{
'engineering_code': ir_attachment.engineering_code,
'engineering_revision': ir_attachment.engineering_revision,
'name':ir_attachment.name,
'id':ir_attachment.id,
'document_type':ir_attachment.document_type
},
'product':product_dict
}
#
out = {'MAIN':{},
'RF':[],
'LF':[]}
main_root_attributes = json.loads(json_main_root_attributes)
product_product_id, attachment_id = self._GetproductDocumentID(tuple(main_root_attributes.values()))
#
if attachment_id:
#
doc_ids_2d=[]
#
main_parent_attrs = get_clone_info_attr(attachment_id.id, product_product_id)
out['MAIN']=main_parent_attrs
for k in SUPPORT_MAIN_PRODUCT_ATTRIBUTES:
out['MAIN']['product'][k]=main_root_attributes.get('product',{}).get(k,'')
#
for doc_id in self.getRelatedRfTree(attachment_id.id):
sub_attrs = get_clone_info_attr(doc_id)
out['RF'].append((main_parent_attrs,
sub_attrs))
for doc_id_2d in self.getRelatedLyTree(doc_id,
optional_return_type=['2d']):
doc_ids_2d.append((sub_attrs, doc_id_2d))
#
for doc_id_2d in self.getRelatedLyTree(attachment_id.id,
optional_return_type=['2d']):
doc_ids_2d.append((main_parent_attrs, doc_id_2d))
#
for parent_attrs, doc_id in doc_ids_2d:
out['LF'].append((parent_attrs,
get_clone_info_attr(doc_id)))
#

return json.dumps(out)

@api.model
def GetCloneDocumentValues(self, args):
"""
return the new attributes to be used for cloning the document
"""
old_product_attrs, old_attachment_attrs, new_product_attrs = args
out_attachment_value = json.loads(old_attachment_attrs)
new_product_attrs = json.loads(new_product_attrs)
if hasattr(self, "customGetCloneDocumentValues"):
#
# If you implement the customGetCloneDocumentValues this call will be used to customize the value of the new cloned document from the client clone action
#
out_attachment_value=self.customGetCloneDocumentValues(out_attachment_value,
json.loads(old_product_attrs),
new_product_attrs)
else:
#
out_attachment_value['engineering_code'] = f"{new_product_attrs['engineering_code']}-{self.env['ir.sequence'].next_by_code('ir.attachment.progress')}"
out_attachment_value['engineering_revision']=0
#
_, exte = os.path.splitext(out_attachment_value['name'])
out_attachment_value['name'] = f"{out_attachment_value['engineering_code']}{exte}"
#
del out_attachment_value['id']
#
return json.dumps(out_attachment_value)

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2 changes: 1 addition & 1 deletion plm/models/ir_attachment_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class PlmDocumentRelations(models.Model):
userid = fields.Many2one('res.users',
_('CheckOut User'),
default=False,
readonly="True")
readonly=True)
notes = fields.Char(string="Notes: ")

_sql_constraints = [
Expand Down
8 changes: 4 additions & 4 deletions plm/models/mail_activity_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
class MailActivityType(models.Model):
_inherit = 'mail.activity.type'

change_activity_type = fields.Selection(selection=[
('request', _('Request')),
('plm_activity', _('Order'))
], string=_('Change Activity Type'))
change_activity_type = fields.Selection(selection=[('request', 'Request'),
('plm_activity', 'Order')
],
string='Change Activity Type')

Loading

0 comments on commit df18822

Please sign in to comment.