去掉警告及开发表面工艺相关需求

This commit is contained in:
jinling.yang
2023-03-27 21:04:33 +08:00
parent 446bd04a9d
commit bf010e2cca
18 changed files with 89 additions and 72 deletions

View File

@@ -10,9 +10,11 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
'depends': ['mrp', 'base', 'sf_manufacturing', 'web_widget_model_viewer', 'mrp_subcontracting'],
'depends': ['mrp', 'base', 'sf_manufacturing', 'web_widget_model_viewer', 'mrp_subcontracting', 'purchase_stock',
'uom'],
'data': [
'data/product_data.xml',
'data/uom_data.xml',
'views/product_template_view.xml',
'views/product_workorder.xml'
],
@@ -20,6 +22,7 @@
],
'qweb': [
],
'license': 'LGPL-3',
'installable': True,
'application': False,
'auto_install': False,

View File

@@ -15,6 +15,11 @@
<field name="type">原材料</field>
</record>
<!-- <record id="product_category_server_sf" model="product.category">-->
<!-- <field name="name">服务</field>-->
<!-- <field name="type">服务</field>-->
<!-- </record>-->
<record id="product_template_sf" model="product.product">
<field name="name">CNC加工产品模板</field>
<field name="active" eval="False"/>
@@ -29,7 +34,7 @@
<field name="company_id" ref="base.main_company"/>
<field name="single_manufacturing">true</field>
<field name="tracking">serial</field>
<field name="is_bfm">false</field>
</record>
<record id="product_embryo_sf_self_machining" model="product.product">
<field name="name">胚料自加工模板</field>
@@ -45,6 +50,7 @@
<field name="company_id" ref="base.main_company"/>
<field name="single_manufacturing">true</field>
<field name="tracking">serial</field>
<field name="is_bfm">false</field>
</record>
<record id="product_embryo_sf_outsource" model="product.product">
@@ -60,6 +66,7 @@
<field name="uom_po_id" ref="uom.product_uom_unit"/>
<field name="company_id" ref="base.main_company"/>
<field name="tracking">serial</field>
<field name="is_bfm">false</field>
</record>
<record id="product_embryo_sf_purchase" model="product.product">
<field name="name">胚料采购模板</field>
@@ -74,6 +81,7 @@
<field name="uom_po_id" ref="uom.product_uom_unit"/>
<field name="company_id" ref="base.main_company"/>
<field name="tracking">serial</field>
<field name="is_bfm">false</field>
</record>
</data>
</odoo>

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
@@ -30,8 +30,9 @@ class ResProductTemplate(models.Model):
product_model_type_id = fields.Many2one('sf.model.type', string='产品模型类型')
embryo_model_type_id = fields.Many2one('sf.model.type', string='胚料模型类型')
model_processing_panel = fields.Char('模型加工面板')
model_surface_process_id = fields.Many2one('sf.production.process', string='表面工艺')
model_process_parameters_id = fields.Many2one('sf.processing.technology', string='工艺参数')
# model_surface_process_category_id = fields.Many2one('sf.production.process.category', string='表面工艺类别')
model_surface_process_id = fields.Many2many('sf.production.process', 'rel_product_process', string='表面工艺')
model_process_parameters_id = fields.Many2many('sf.processing.technology', 'rel_product_technology', string='工艺参数')
# model_price = fields.Float('模型单价', digits=(16, 3))
model_remark = fields.Char('模型备注说明')
length = fields.Float('长[mm]', digits=(16, 3))
@@ -108,8 +109,8 @@ class ResProductTemplate(models.Model):
[('materials_no', '=', item['texture_type_code'])]).id,
'model_surface_process_id': self.env['sf.production.process'].search(
[('process_encode', '=', item['surface_process_code'])]).id,
# 'model_process_parameters_id': self.env['sf.processing.technology'].search(
# [('process_encode', '=', item['process_parameters_code'])]).id,
'model_process_parameters_id': self.env['sf.processing.technology'].search(
[('process_encode', '=', item['process_parameters_code'])]).id,
'model_remark': item['remark'],
'default_code': '%s-%s' % (order_number, i),
# 'barcode': item['barcode'],
@@ -182,14 +183,15 @@ class ResProductTemplate(models.Model):
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals['upload_model_file']:
for item in vals['upload_model_file']:
attachment = self.env['ir.attachment'].sudo().search([('id', '=', int(item[2][0]))])
base64_data = base64.b64encode(attachment.datas)
base64_datas = base64_data.decode('utf-8')
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
report_path = attachment._full_path(attachment.store_fname)
vals['model_file'] = self.transition_glb_file(report_path, model_code)
if vals.get('upload_model_file'):
if vals.get('is_bfm') is False and vals.get('categ_type') == '成品':
for item in vals['upload_model_file']:
attachment = self.env['ir.attachment'].sudo().search([('id', '=', int(item[2][0]))])
base64_data = base64.b64encode(attachment.datas)
base64_datas = base64_data.decode('utf-8')
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
report_path = attachment._full_path(attachment.store_fname)
vals['model_file'] = self.transition_glb_file(report_path, model_code)
self._sanitize_vals(vals)
templates = super(ResProductTemplate, self).create(vals_list)
if "create_product_product" not in self._context:

View File

@@ -14,7 +14,8 @@
<field name="detailed_type" position="before">
<field name='categ_type' invisible="1"/>
<field name="upload_model_file"
widget="many2many_binary"/>
widget="many2many_binary"
attrs="{'invisible': ['|', ('categ_type', '!=', '成品'),('categ_type', '=', False)]}"/>
<field name="model_file" widget="Viewer3D" string="模型" readonly="1" force_save="1"
attrs="{'invisible': ['|', ('categ_type', '!=', '成品'),('categ_type', '=', False)]}"/>
</field>
@@ -24,6 +25,8 @@
<field name="materials_id" string="材料"/>
<field name="materials_type_id" string="型号"
domain="[('materials_id', '=', materials_id)]"/>
<field name="model_surface_process_id" string="表面工艺" widget="many2many_tags"/>
<field name="model_process_parameters_id" string="工艺参数" widget="many2many_tags"/>
</field>
<xpath expr="//label[@for='volume']" position="before">