sf修改设备table,品牌图片改成图片

This commit is contained in:
qihao.gong@jikimo.com
2023-08-29 15:47:58 +08:00
parent 5d30dae189
commit b7f2c4a000
3 changed files with 37 additions and 25 deletions

View File

@@ -35,7 +35,7 @@ class MachineBrand(models.Model):
code = fields.Char('编码')
name = fields.Char('名称')
tag_ids = fields.Many2many('sf.machine.brand.tags', 'rel_machine_brand_tags', string='类别')
image_brand = fields.Image("品牌图片")
image_brand = fields.Image("图片")
remark = fields.Text('备注')
active = fields.Boolean('有效', default=True)

View File

@@ -171,12 +171,7 @@
</page>
<page string="其他" attrs="{'invisible': [('type_id', '=', False)]}">
<group string="其他">
<field name="remark"/>
</group>
<button type="object" class="oe_highlight" name='enroll_machine_tool' string="机床注册"/>
</page>
</xpath>
@@ -206,6 +201,23 @@
<field name='equipment_maintenance_standards_ids' widget="many2many_tags" invisible="1"/>
</xpath>
<xpath expr="//page[@name='description']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//page[@name='product_information']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//page[@name='maintenance']" position="after">
<page string="其他" attrs="{'invisible': [('type_id', '=', False)]}">
<group string="其他">
<field name="remark"/>
</group>
<button type="object" class="oe_highlight" name='enroll_machine_tool' string="机床注册"/>
</page>
</xpath>
</data>
</field>
</record>
@@ -286,7 +298,7 @@
</xpath>
<xpath expr="//templates" position="inside">
<xpath expr="//templates" position="inside">
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record oe_kanban_card oe_kanban_global_click">
@@ -303,7 +315,7 @@
<div class="o_kanban_record_bottom state_zc">
<field name="state_zc"/>
</div>
<div class="o_kanban_record_bottom state_zc">
<div class="o_kanban_record_bottom state_zc">
<field name="technician_user_id"/>
</div>
<div class="o_kanban_record_bottom state_zc"

View File

@@ -1,8 +1,8 @@
from odoo import models, fields, api
from odoo.exceptions import ValidationError
from odoo.modules import get_resource_path
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
# from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file
import logging
import base64
import hashlib
@@ -500,20 +500,20 @@ class ResProductMo(models.Model):
item.model_file = self.transition_glb_file(report_path, model_code)
# 将attach的datas内容转为glb文件
def transition_glb_file(self, report_path, code):
shapes = read_step_file(report_path)
output_file = os.path.join('/tmp', str(code) + '.stl')
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
# 转化为glb
output_glb_file = os.path.join('/tmp', str(code) + '.glb')
util_path = get_resource_path('sf_dlm', 'static/util')
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
os.system(cmd)
# 转base64
with open(output_glb_file, 'rb') as fileObj:
image_data = fileObj.read()
base64_data = base64.b64encode(image_data)
return base64_data
# def transition_glb_file(self, report_path, code):
# shapes = read_step_file(report_path)
# output_file = os.path.join('/tmp', str(code) + '.stl')
# write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
# # 转化为glb
# output_glb_file = os.path.join('/tmp', str(code) + '.glb')
# util_path = get_resource_path('sf_dlm', 'static/util')
# cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
# os.system(cmd)
# # 转base64
# with open(output_glb_file, 'rb') as fileObj:
# image_data = fileObj.read()
# base64_data = base64.b64encode(image_data)
# return base64_data
class ResMrpBomMo(models.Model):