Skip to content

Commit

Permalink
Merge pull request #82 from OmniaGit/ADD_3mf_treejs_support
Browse files Browse the repository at this point in the history
Add 3mf treejs support
  • Loading branch information
OmniaGit authored Sep 16, 2024
2 parents 2a9b594 + c331775 commit 4539b72
Show file tree
Hide file tree
Showing 12 changed files with 580 additions and 77 deletions.
2 changes: 2 additions & 0 deletions plm/models/mrp_bom_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def _related_doc_ids(self):
('server', 'Server')],
_('Cutted Compute Type'),
default='none')

product_tag_ids = fields.Many2many(related='product_tmpl_id.product_tag_ids')

product_tag_ids = fields.Many2many(related='product_tmpl_id.product_tag_ids')

Expand Down
8 changes: 2 additions & 6 deletions plm/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -1800,17 +1800,13 @@ def name_get(self):

@api.model
def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):
if not domain:
domain=[('engineering_code', 'ilike', name)]
else:
domain = expression.OR([domain,
[('engineering_code', 'ilike', name)]])
engineering_code_products = self.search([('engineering_code', 'ilike', name)])
product_ids = list(super(ProductProduct, self)._name_search(name,
domain,
operator,
limit,
order=None))
return list(set(product_ids))
return list(set(product_ids + engineering_code_products.ids))

@api.model
def getExpodedBom(self, ids):
Expand Down
2 changes: 1 addition & 1 deletion plm/views/ir_attachment_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
icon="fa-bars"/>
<button name="open_related_document_revisions"
type="object"
string="BOM Rev."
string="N.Rev."
class="oe_stat_button"
icon="fa-tasks"
invisible="engineering_revision_count &lt;=1">
Expand Down
2 changes: 2 additions & 0 deletions plm/views/mrp_extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<field name="engineering_revision" readonly="True"/>
<field name="engineering_state"/>
<field name="description" select="True"/>
<field name="product_tag_ids" widget="many2many_tags" options="{'color_field': 'color'}" />
<field name="source_id" string="Source Relation" widget="many2one"
context="{'kanban_view_ref':'plm.document_kanban_view',
'tree_view_ref':'plm.ir_attachment_tree',
Expand Down Expand Up @@ -290,6 +291,7 @@
<field name="product_id" string="Component Name"/>
<field name="engineering_revision" string="Revision"/>
<field name="description"/>
<field string="Tags" name="product_tag_ids"/>
<field name="source_id" string="Source Relation" widget="many2one"
context="{'kanban_view_ref':'plm.document_kanban_view',
'tree_view_ref':'plm.ir_attachment_tree',
Expand Down
2 changes: 1 addition & 1 deletion plm_web_3d/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################
{
"name": "PLM Web 3d Support",
"version": "17.0.0.1",
"version": "17.0.0.3",
"author": "OmniaSolutions",
"website": "https://odooplm.omniasolutions.website",
"category": "Manufacturing/Product Lifecycle Management (PLM)",
Expand Down
13 changes: 12 additions & 1 deletion plm_web_3d/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def download_treejs_model(self, document_id):
response = request.make_response(content_base64, headers)
return response
return Response(response="Document Not Found %r " % document_id, status=500)

def document_extra(self, document):
"""
this function id for customising the documents attributes
Expand Down Expand Up @@ -79,4 +79,15 @@ def getProductInfo(self, document_id):
components = self.component_extra(components)
out['component']=components
return json.dumps(out)

@route('/plm/get_3d_web_document_info', type='http', auth="user")
@webservice
def get_3d_web_document_info(self, src_name):
src_name = src_name.split("(")[0] # this split is needed for solidwoks file the put the configuration on the name filename(<configuration name>)description
out = f"""<span>{src_name}</span>"""
for ir_attachment in request.env['ir.attachment'].sudo().search(['|',('name','ilike', src_name),('engineering_code','ilike', src_name)]):
for product_product_id in ir_attachment.linkedcomponents:
out = f"""<span title={product_product_id.name}>{product_product_id.engineering_code} Rev. {product_product_id.engineering_revision}</span>"""
break
return out

18 changes: 14 additions & 4 deletions plm_web_3d/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@author: mboscolo
'''
import os
import json
import logging
import datetime
from odoo import models
Expand All @@ -34,7 +35,7 @@
from datetime import timedelta
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
import urllib.parse
SUPPORTED_WEBGL_EXTENTION = ['.gltf','.glb','.fbx','.obj','.wrl','.json', '.stl','.svg', '.dxf']
SUPPORTED_WEBGL_EXTENTION = ['.3mf','.gltf','.glb','.fbx','.obj','.wrl','.json', '.stl','.svg', '.dxf']
#
#
class IrAttachment(models.Model):
Expand Down Expand Up @@ -77,7 +78,7 @@ def get_url_for_3dWebModel(self):
url_params = urllib.parse.urlencode({'document_id': rel.child_id.id,
'document_name': rel.child_id.name})
if url_params:
return "%s/plm/show_treejs_model?%s" % (base_url, url_params)
return f"{base_url}/plm/show_treejs_model?{url_params}"

def show_releted_3d(self):
for ir_attachment in self:
Expand All @@ -88,5 +89,14 @@ def show_releted_3d(self):
'type': 'ir.actions.act_url',
'target': self,
'url': url
}

}

def get_all_relation(self, document_id, exte):
out={}
if exte in document_id.name:
out[document_id.id] = document_id.name
for child_attachment_id in self.getRelatedHiTree(document_id.id):
if exte in self.browse(child_attachment_id).name:
out[child_attachment_id.id]=child_attachment_id.name
return out

104 changes: 100 additions & 4 deletions plm_web_3d/static/src/css/OdooCADApplication.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

}
.main_command_slide {
height: 20px;
height: 26px;
box-shadow:2px 2px 5px 1px grey;
width: auto;
opacity: .5;
Expand All @@ -65,7 +65,7 @@
transform-origin: bottom;
}
.main_command_slide:hover{
height: 20%;
height: 210px;
background-color: transparent;
opacity: 1;

Expand Down Expand Up @@ -138,6 +138,33 @@
cursor: row-resize;
}

#object_explosion {
margin: 10px;
background: #997992;
-webkit-appearance: none;
background-color: white;
border-radius: 5px;
}

#object_explosion::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 10px;
height: 10px;
background: #997992;
cursor: pointer;
}

#object_explosion::-moz-range-thumb {
width: 10px;
height: 10px;
background: #997992;
cursor: pointer;
}
#object_explosion:hover {
opacity: 1.0;
}

#object_transparency {
margin: 10px;

Expand All @@ -146,6 +173,9 @@
background-color: white;
border-radius: 5px;
}



#object_transparency::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
Expand Down Expand Up @@ -217,6 +247,10 @@ label{
width: 300px;
visibility: hidden;
opacity:0;
resize: horizontal;
overflow: auto;
direction: rtl;
min-width: 300px;
}

#main_div_hidden{
Expand Down Expand Up @@ -256,7 +290,14 @@ div.info_header{
#click_show:hover{
background-color:gray;
}

#tree_structure{
margin-left: auto;
margin-right: auto;
overflow-y: scroll;
overflow-x: hidden;
width: 100%;
height: 500px;
}
li.attribute_info{
text-align: left;
}
Expand Down Expand Up @@ -339,4 +380,59 @@ li.attribute_info{

.cube__face--bottom {
transform: rotateX(90deg) rotateX(180deg) translateZ(-40px);
}
}
/* Remove default bullets */
ul, #myUL {
list-style-type: none;
}

/* Remove margins and padding from the parent ul */
#myUL {
margin: 0;
padding: 0;
}

/* Style the caret/arrow */
.caret {
cursor: pointer;
user-select: none; /* Prevent text selection */
}

/* Create the caret/arrow with a unicode, and style it */
.caret::before {
content: "\25B6";
color: black;
display: inline-block;
margin-right: 6px;
}

/* Rotate the caret/arrow icon when clicked on (using JavaScript) */
.caret-down::before {
transform: rotate(90deg);
}

/* Hide the nested list */
.nested {
display: none;
}

/* Show the nested list when the user clicks on the caret/arrow (with JavaScript) */
.active {
display: block;
}
#document_tree{
direction: ltr;
text-align: left;
}
.document_tree_line>span:hover {
background-color: #eda3da;
}
.document_tree_line>i{
padding: 8px;
}
.document_tree_line>i:hover{
background-color: #eda3da;
}



Loading

0 comments on commit 4539b72

Please sign in to comment.