注释OCC代码

This commit is contained in:
jinling.yang
2024-09-18 10:23:42 +08:00
parent 5a7ba7f87e
commit 92037f3f04
17 changed files with 116 additions and 123 deletions

View File

@@ -33,13 +33,12 @@ class SfMaintenanceEquipmentAGVLog(models.Model):
class SfMaintenanceEquipment(models.Model):
_inherit = 'maintenance.equipment'
_inherit = ['maintenance.equipment', 'sf.message.template']
_description = '设备'
crea_url = "/api/machine_tool/create"
#AGV运行日志
# AGV运行日志
agv_logs = fields.One2many('maintenance.equipment.agv.log', 'equipment_id', string='AGV运行日志')
# 1212修改后的字段
number_of_axles = fields.Selection(
@@ -117,7 +116,6 @@ class SfMaintenanceEquipment(models.Model):
# num = "%04d" % m
# return num
equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards',
'sf_maintenance_equipment_ids', string='设备维保标准')
eq_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备保养标准',
@@ -179,7 +177,8 @@ class SfMaintenanceEquipment(models.Model):
type_id = fields.Many2one('sf.machine_tool.type', '型号')
state = fields.Selection(
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"), ("封存(报废)", "封存(报废)")],
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"),
("封存(报废)", "封存(报废)")],
default='正常', string="机床状态")
run_time = fields.Char('总运行时长')
# 0606新增字段
@@ -328,7 +327,7 @@ class SfMaintenanceEquipment(models.Model):
item.tool_diameter_min = item.type_id.tool_diameter_min
item.machine_tool_category = item.type_id.machine_tool_category.id
item.brand_id = item.type_id.brand_id.id
#新增修改字段
# 新增修改字段
item.taper_type_id = item.type_id.taper_type_id.id
item.function_type = item.type_id.function_type
item.a_axis = item.type_id.a_axis
@@ -370,7 +369,6 @@ class SfMaintenanceEquipment(models.Model):
item.image_id = item.type_id.jg_image_id.ids
item.image_lq_id = item.type_id.lq_image_id.ids
# AGV小车设备参数
AGV_L = fields.Char('AGV尺寸(长)')
AGV_W = fields.Char('AGV尺寸(宽)')
@@ -461,18 +459,6 @@ class SfMaintenanceEquipment(models.Model):
original_value = fields.Char('原值')
incomplete_value = fields.Char('残值')
# 注册同步机床
def enroll_machine_tool(self):
sf_sync_config = self.env['res.config.settings'].get_values()
@@ -763,7 +749,7 @@ class SfMaintenanceEquipment(models.Model):
image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id',
domain="[('type', '=', '加工能力')]")
image_lq_id = fields.Many2many('maintenance.equipment.image', 'equipment_lq_id', string='冷却方式',
domain="[('type', '=', '冷却方式')]")
domain="[('type', '=', '冷却方式')]")
class SfRobotAxisNum(models.Model):
@@ -777,4 +763,5 @@ class SfRobotAxisNum(models.Model):
weight = fields.Char('最大负载(kg)')
permissible_load_torque = fields.Char('允许负载扭矩(N-m)')
permissible_inertial_torque = fields.Char('允许惯性扭矩(kg-m²)')
equipment_id = fields.Many2one('maintenance.equipment', string='机器人', domain="[('equipment_type', '=', '机器人')]")
equipment_id = fields.Many2one('maintenance.equipment', string='机器人',
domain="[('equipment_type', '=', '机器人')]")

View File

@@ -10,7 +10,7 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse'],
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse','sf_message'],
'data': [
'data/stock_data.xml',
'data/empty_racks_data.xml',

View File

@@ -89,8 +89,8 @@ class AgvScheduling(models.Model):
workorders: 工单
"""
_logger.info('创建AGV调度任务\r\n起点为【%s】,任务类型为【%s】,工单为【%s' % (agv_start_site_name, agv_route_type, workorders))
if not workorders:
raise UserError(_('工单不能为空'))
# if not workorders:
# raise UserError(_('工单不能为空'))
agv_start_site = self.env['sf.agv.site'].sudo().search([('name', '=', agv_start_site_name)], limit=1)
if not agv_start_site:
raise UserError(_('不存在名称为【%s】的接驳站,请先创建!' % agv_start_site_name))

View File

@@ -804,6 +804,10 @@ class MrpProduction(models.Model):
backorders = backorders - productions_to_backorder
productions_not_to_backorder._post_inventory(cancel_backorder=True)
if self.workorder_ids.filtered(lambda w: w.routing_type in ['表面工艺']):
move_finish = self.env['stock.move'].search([('created_production_id', '=', self.id)])
if move_finish:
move_finish._action_assign()
productions_to_backorder._post_inventory(cancel_backorder=True)
# if completed products make other confirmed/partially_available moves available, assign them

View File

@@ -18,7 +18,7 @@ from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
class ResMrpWorkOrder(models.Model):
_inherit = 'mrp.workorder'
_inherit = ['mrp.workorder', 'sf.message.template']
_order = 'sequence asc'
product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name')

View File

@@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError
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
class ResProductMo(models.Model):

View File

@@ -539,7 +539,7 @@ class ProductionLot(models.Model):
class StockPicking(models.Model):
_inherit = 'stock.picking'
_inherit = ['stock.picking', 'sf.message.template']
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")

View File

@@ -221,7 +221,7 @@
<xpath expr="//label[1]" position="before">
<field name='routing_type' readonly="1"/>
<field name='process_state' attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="rfid_code" force_save="1" readonly="1" cache="True"
<field name="rfid_code" force_save="1" readonly="0" cache="True"
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
</xpath>

View File

@@ -7,30 +7,30 @@ class SfMessageTemplate(models.Model):
_description = u'消息模板'
name = fields.Char(string=u"名称", required=True)
type = fields.Selection([
('待接单', '待接单'),
('待排程', '待排程'),
('坯料采购', '坯料采购'),
('坯料发料', '坯料发料'),
('待编程', '待编程'),
('调拨入库', '调拨入库'),
('功能刀具组装', '功能刀具组装'),
('功能刀具寿命到期', '功能刀具寿命到期'),
('程序用刀计划异常', '程序用刀计划异常'),
('工单无CNC程序', '工单无CNC程序'),
('生产线无功能刀具', '生产线无功能刀具'),
('工单无定位数据', '工单无定位数据'),
('工单FTP无文件', '工单FTP无文件'),
('工单加工失败', '工单加工失败'),
('设备故障及异常', '设备故障及异常'),
('工单逾期预警', '工单逾期预警'),
('工单已逾期', '工单已逾期'),
('销售订单逾期', '销售订单逾期'),
('销售订单已逾期', '销售订单已逾期'),
('待质量判定', '待质量判定'),
('生产完工待入库', '生产完工待入库'),
('订单发货', '订单发货')
], string='类型', required=True)
# type = fields.Selection([
# ('待接单', '待接单'),
# ('待排程', '待排程'),
# ('坯料采购', '坯料采购'),
# ('坯料发料', '坯料发料'),
# ('待编程', '待编程'),
# ('调拨入库', '调拨入库'),
# ('功能刀具组装', '功能刀具组装'),
# ('功能刀具寿命到期', '功能刀具寿命到期'),
# ('程序用刀计划异常', '程序用刀计划异常'),
# ('工单无CNC程序', '工单无CNC程序'),
# ('生产线无功能刀具', '生产线无功能刀具'),
# ('工单无定位数据', '工单无定位数据'),
# ('工单FTP无文件', '工单FTP无文件'),
# ('工单加工失败', '工单加工失败'),
# ('设备故障及异常', '设备故障及异常'),
# ('工单逾期预警', '工单逾期预警'),
# ('工单已逾期', '工单已逾期'),
# ('销售订单逾期', '销售订单逾期'),
# ('销售订单已逾期', '销售订单已逾期'),
# ('待质量判定', '待质量判定'),
# ('生产完工待入库', '生产完工待入库'),
# ('订单发货', '订单发货')
# ], string='类型', required=True)
description = fields.Char(string=u"描述")
content = fields.Html(string=u"内容", render_engine='qweb', translate=True, prefetch=True, sanitize=False)
msgtype = fields.Selection(
@@ -46,3 +46,4 @@ class SfMessageTemplate(models.Model):
def _clear_employee_ids(self):
if self.notification_department_id:
self.notification_employee_ids = False

View File

@@ -18,7 +18,7 @@
</h1>
</div>
<group>
<field name="type"/>
<!-- <field name="type"/>-->
<field name="content" widget="html" class="oe-bordered-editor"
options="{'style-inline': true, 'codeview': true, 'dynamic_placeholder': true}"/>
<field name="description"/>
@@ -38,7 +38,7 @@
<field name="arch" type="xml">
<tree string="消息模板">
<field name="name"/>
<field name="type"/>
<!-- <field name="type"/>-->
<field name="content"/>
<field name="msgtype"/>
<field name="type"/>
@@ -55,7 +55,7 @@
<field name="arch" type="xml">
<search>
<field name="name" string="模糊搜索"
filter_domain="['|','|',('name','like',self),('type','like',self),('description','like',self)]"/>
filter_domain="['|','|',('name','like',self),('description','like',self)]"/>
<field name="name"/>
<filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>
</search>

View File

@@ -31,67 +31,67 @@ class Sf_Mrs_Connect(http.Controller):
request.env.ref("base.user_admin")).search(domain)
if productions:
# 拉取所有加工面的程序文件
for r in ret['processing_panel'].split(','):
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
if os.path.exists(program_path_tmp_r):
files_r = os.listdir(program_path_tmp_r)
if files_r:
for file_name in files_r:
file_path = os.path.join(program_path_tmp_r, file_name)
os.remove(file_path)
download_state = request.env['sf.cnc.processing'].with_user(
request.env.ref("base.user_admin")).download_file_tmp(
ret['folder_name'], r)
if download_state is False:
res['status'] = -2
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
return json.JSONEncoder().encode(res)
# for r in ret['processing_panel'].split(','):
# program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
# if os.path.exists(program_path_tmp_r):
# files_r = os.listdir(program_path_tmp_r)
# if files_r:
# for file_name in files_r:
# file_path = os.path.join(program_path_tmp_r, file_name)
# os.remove(file_path)
# download_state = request.env['sf.cnc.processing'].with_user(
# request.env.ref("base.user_admin")).download_file_tmp(
# ret['folder_name'], r)
# if download_state is False:
# res['status'] = -2
# res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
# return json.JSONEncoder().encode(res)
for production in productions:
if not production.workorder_ids:
production.product_id.model_processing_panel = ret['processing_panel']
production._create_workorder(ret)
productions.process_range_time()
else:
for panel in ret['processing_panel'].split(','):
# 查询状态为进行中且工序类型为CNC加工的工单
cnc_workorder_has = production.workorder_ids.filtered(
lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done',
'rework',
'cancel'] and ach.processing_panel == panel)
if cnc_workorder_has:
if cnc_workorder_has.cnc_ids:
cnc_workorder_has.cmm_ids.sudo().unlink()
cnc_workorder_has.cnc_ids.sudo().unlink()
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
production)
cnc_workorder_has.write(
{'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
for panel in ret['processing_panel'].split(','):
# 查询状态为进行中且工序类型为CNC加工的工单
cnc_workorder = productions.workorder_ids.filtered(
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
'cancel'] and ac.processing_panel == panel)
if cnc_workorder:
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
# panel)
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
files_panel = os.listdir(program_path_tmp_panel)
if files_panel:
for file in files_panel:
file_extension = os.path.splitext(file)[1]
logging.info('file_extension:%s' % file_extension)
if file_extension.lower() == '.pdf':
panel_file_path = os.path.join(program_path_tmp_panel, file)
logging.info('panel_file_path:%s' % panel_file_path)
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
pre_workorder = productions.workorder_ids.filtered(
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
'cancel'] and ap.processing_panel == panel)
if pre_workorder:
pre_workorder.write(
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
# else:
# for panel in ret['processing_panel'].split(','):
# # 查询状态为进行中且工序类型为CNC加工的工单
# cnc_workorder_has = production.workorder_ids.filtered(
# lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done',
# 'rework',
# 'cancel'] and ach.processing_panel == panel)
# if cnc_workorder_has:
# if cnc_workorder_has.cnc_ids:
# cnc_workorder_has.cmm_ids.sudo().unlink()
# cnc_workorder_has.cnc_ids.sudo().unlink()
# request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
# production)
# cnc_workorder_has.write(
# {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
# 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
# for panel in ret['processing_panel'].split(','):
# # 查询状态为进行中且工序类型为CNC加工的工单
# cnc_workorder = productions.workorder_ids.filtered(
# lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
# 'cancel'] and ac.processing_panel == panel)
# if cnc_workorder:
# # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
# # panel)
# program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
# logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
# files_panel = os.listdir(program_path_tmp_panel)
# if files_panel:
# for file in files_panel:
# file_extension = os.path.splitext(file)[1]
# logging.info('file_extension:%s' % file_extension)
# if file_extension.lower() == '.pdf':
# panel_file_path = os.path.join(program_path_tmp_panel, file)
# logging.info('panel_file_path:%s' % panel_file_path)
# cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
# pre_workorder = productions.workorder_ids.filtered(
# lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
# 'cancel'] and ap.processing_panel == panel)
# if pre_workorder:
# pre_workorder.write(
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
return json.JSONEncoder().encode(res)
else:

View File

@@ -11,7 +11,7 @@ from odoo.exceptions import UserError, ValidationError
class sf_production_plan(models.Model):
_name = 'sf.production.plan'
_description = 'sf_production_plan'
_inherit = ['mail.thread']
_inherit = ['mail.thread', 'sf.message.template']
# _order = 'state desc, write_date desc'
state = fields.Selection([

View File

@@ -10,7 +10,8 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
'depends': ['sale', 'sale_management', 'web_widget_model_viewer', 'sf_base', 'account', 'purchase', 'delivery'],
'depends': ['sale', 'sale_management', 'web_widget_model_viewer', 'sf_base', 'account', 'purchase', 'delivery',
'sf_message'],
'data': [
'security/group_security.xml',
'security/ir.model.access.csv',

View File

@@ -8,8 +8,8 @@ from datetime import datetime
import requests
from odoo import http
from odoo.http import request
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
from odoo import models, fields, api
from odoo.modules import get_resource_path
from odoo.exceptions import ValidationError, UserError

View File

@@ -6,8 +6,8 @@ import os
from datetime import datetime
from stl import mesh
# from OCC.Core.GProp import GProp_GProps
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
from odoo.addons.sf_base.commons.common import Common
from odoo import models, fields, api
from odoo.modules import get_resource_path

View File

@@ -11,7 +11,7 @@ READONLY_FIELD_STATES = {
class ReSaleOrder(models.Model):
_inherit = 'sale.order'
_inherit = ['sale.order', 'sf.message.template']
mrp_production_count = fields.Integer(
"Count of MO generated",
@@ -183,7 +183,7 @@ class ProductTemplate(models.Model):
class RePurchaseOrder(models.Model):
_inherit = 'purchase.order'
_inherit = ['purchase.order','sf.message.template']
mrp_production_count = fields.Integer(
"Count of MO Source",

View File

@@ -181,7 +181,7 @@ class MachineTableToolChangingApply(models.Model):
class CAMWorkOrderProgramKnifePlan(models.Model):
_name = 'sf.cam.work.order.program.knife.plan'
_inherit = ['mail.thread']
_inherit = ['mail.thread', 'sf.message.template']
_description = 'CAM工单程序用刀计划'
name = fields.Char('工单任务编号')
@@ -349,7 +349,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
class FunctionalToolAssembly(models.Model):
_name = 'sf.functional.tool.assembly'
_inherit = ['mail.thread']
_inherit = ['mail.thread', 'sf.message.template']
_description = '功能刀具组装'
_order = 'assemble_status, use_tool_time asc'
@@ -679,7 +679,7 @@ class FunctionalToolAssembly(models.Model):
class FunctionalToolDismantle(models.Model):
_name = 'sf.functional.tool.dismantle'
_inherit = ["barcodes.barcode_events_mixin", 'mail.thread']
_inherit = ["barcodes.barcode_events_mixin", 'mail.thread', 'sf.message.template']
_description = '功能刀具拆解'
def on_barcode_scanned(self, barcode):