Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造代码优化
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
<group>
|
||||
<field name="code" readonly="1"/>
|
||||
<field name="process_id" readonly="1"/>
|
||||
<field name="gain_way" />
|
||||
<field name="gain_way"/>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
@@ -231,6 +231,9 @@
|
||||
<field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>
|
||||
<field name="code" string="编码搜索" filter_domain="[('code','ilike',self)]"/>
|
||||
<filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>
|
||||
<searchpanel>
|
||||
<field name="category_id" icon="fa-building" enable_counters="1"/>
|
||||
</searchpanel>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -41,14 +41,15 @@
|
||||
context="{'default_cutting_tool_type': cutting_tool_type,'default_standard_library_id':cutting_tool_model_id}"
|
||||
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"
|
||||
domain="[('standard_library_id','=',cutting_tool_model_id)]"/>
|
||||
<field name="fixture_material_id" attrs="{'invisible': [('categ_type', '!=', '夹具')]}"
|
||||
<field name="fixture_material_id"
|
||||
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
||||
placeholder="请选择" options="{'no_create': True}"/>
|
||||
<field name="fixture_model_id" string="型号" placeholder="请选择" options="{'no_create': True}"
|
||||
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
||||
domain="[('fixture_material_id','=',fixture_material_id)]"/>
|
||||
<field name="specification_fixture_id" string="规格" placeholder="请选择"
|
||||
options="{'no_create': True}"
|
||||
attrs="{'invisible': [('categ_type', '!=', '夹具')]}"
|
||||
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
||||
domain="[('fixture_model_id','=',fixture_model_id)]"/>
|
||||
</field>
|
||||
<xpath expr="//label[@for='volume']" position="before">
|
||||
|
||||
@@ -736,7 +736,7 @@ class CNCprocessing(models.Model):
|
||||
# cnc_workorder.time_ids.date_end = datetime.now()
|
||||
# cnc_workorder.button_finish()
|
||||
|
||||
# 根据程序名和加工面匹配到ftp里对应的Nc程序名
|
||||
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
|
||||
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
|
||||
logging.info('serverdir:%s' % serverdir)
|
||||
for root, dirs, files in os.walk(serverdir):
|
||||
@@ -778,7 +778,7 @@ class CNCprocessing(models.Model):
|
||||
# 将nc文件存到attach的datas里
|
||||
def write_file(self, nc_file_path, cnc):
|
||||
nc_file_name = nc_file_path.split('/')
|
||||
logging.info('nc_file_name:%s' % nc_file_name[-1])
|
||||
logging.info('file_name:%s' % nc_file_name[-1])
|
||||
if os.path.exists(nc_file_path):
|
||||
with open(nc_file_path, 'rb') as file:
|
||||
data_bytes = file.read()
|
||||
@@ -910,7 +910,8 @@ class WorkPieceDelivery(models.Model):
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
res = {'reqCode': urllib.parse.quote(self.production_id.name), 'reqTime': '', 'clientCode': '', 'tokenCode': '',
|
||||
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': '006848AB006774', 'positionCodePath': [], 'podCode': '',
|
||||
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': '006848AB006774', 'positionCodePath': [],
|
||||
'podCode': '',
|
||||
'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '',
|
||||
'data': ''}
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
@@ -951,7 +952,77 @@ class CMMprogram(models.Model):
|
||||
_name = 'sf.cmm.program'
|
||||
_description = "CMM程序"
|
||||
|
||||
program_path = fields.Char('程序文件路径')
|
||||
post_processing_name = fields.Char('后处理名称')
|
||||
program_date = fields.Datetime('程序日期')
|
||||
cmm_id = fields.Many2one('ir.attachment')
|
||||
sequence_number = fields.Integer('序号')
|
||||
program_name = fields.Char('程序名')
|
||||
cutting_tool_name = fields.Char('刀具名称')
|
||||
cutting_tool_no = fields.Char('刀号')
|
||||
processing_type = fields.Char('加工类型')
|
||||
margin_x_y = fields.Char('余量_X/Y')
|
||||
margin_z = fields.Char('余量_Z')
|
||||
depth_of_processing_z = fields.Char('加工深度(Z)')
|
||||
cutting_tool_extension_length = fields.Char('刀具伸出长度')
|
||||
cutting_tool_handle_type = fields.Char('刀柄型号')
|
||||
estimated_processing_time = fields.Char('预计加工时间')
|
||||
remark = fields.Text('备注')
|
||||
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
||||
production_id = fields.Many2one('mrp.production', string="制造订单")
|
||||
program_path = fields.Char('程序文件路径')
|
||||
|
||||
def cmm_program_create(self, ret, program_path, program_path_tmp):
|
||||
for obj in ret['programming_list']:
|
||||
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', ret['production_order_no']),
|
||||
('processing_panel', '=', obj['processing_panel']),
|
||||
('routing_type', '=', 'CNC加工')])
|
||||
if obj['program_name'] in program_path:
|
||||
logging.info('obj:%s' % obj['program_name'])
|
||||
cmm_program = self.sudo().create({
|
||||
'workorder_id': workorder.id,
|
||||
'sequence_number': obj['sequence_number'],
|
||||
'program_name': obj['program_name'],
|
||||
'cutting_tool_name': obj['cutting_tool_name'],
|
||||
'cutting_tool_no': obj['cutting_tool_no'],
|
||||
'processing_type': obj['processing_type'],
|
||||
'margin_x_y': obj['margin_x_y'],
|
||||
'margin_z': obj['margin_z'],
|
||||
'depth_of_processing_z': obj['depth_of_processing_z'],
|
||||
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
||||
'estimated_processing_time': obj['estimated_processing_time'],
|
||||
'remark': obj['remark'],
|
||||
'program_path': program_path.replace('/tmp', '')
|
||||
})
|
||||
cmm_program.get_cmm_program_file(program_path_tmp, cmm_program, program_path)
|
||||
|
||||
# 根据程序名和加工面匹配到ftp里对应的cmm程序名
|
||||
def get_cmm_program_file(self, serverdir, cmm_program, program_path):
|
||||
logging.info('cmm-serverdir:%s' % serverdir)
|
||||
for root, dirs, files in os.walk(serverdir):
|
||||
for f in files:
|
||||
if f in program_path:
|
||||
cmm_program_file_path = os.path.join(serverdir, root, f)
|
||||
self.write_file_cmm(cmm_program_file_path, cmm_program)
|
||||
|
||||
# 创建附件(nc文件)
|
||||
def attachment_create(self, name, data):
|
||||
attachment = self.env['ir.attachment'].create({
|
||||
'datas': base64.b64encode(data),
|
||||
'type': 'binary',
|
||||
'public': True,
|
||||
'description': '程序文件',
|
||||
'name': name
|
||||
})
|
||||
return attachment
|
||||
|
||||
# 将cmm文件存到attach的datas里
|
||||
def write_file_cmm(self, cmm_file_path, cnc):
|
||||
cmm_file_name = cmm_file_path.split('/')
|
||||
logging.info('cmm_file_name:%s' % cmm_file_name[-1])
|
||||
if os.path.exists(cmm_file_path):
|
||||
with open(cmm_file_path, 'rb') as file:
|
||||
data_bytes = file.read()
|
||||
attachment = self.attachment_create(cnc.program_name + cmm_file_name[-1], data_bytes)
|
||||
cnc.write({'cmm_id': attachment.id})
|
||||
file.close()
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -366,10 +366,10 @@ class StockPicking(models.Model):
|
||||
# 设置外协出入单的名称
|
||||
def _get_name_Res(self, rescode):
|
||||
last_picking = self.sudo().search([('name', 'like', rescode)], order='create_date DESC', limit=1)
|
||||
logging.info('编号:' + last_picking.name)
|
||||
if not last_picking:
|
||||
num = "%04d" % 1
|
||||
else:
|
||||
logging.info('编号:' + last_picking.name)
|
||||
m = int(last_picking.name[-3:]) + 1
|
||||
num = "%04d" % m
|
||||
return '%s%s' % (rescode, num)
|
||||
@@ -419,7 +419,7 @@ class StockPicking(models.Model):
|
||||
location_id = self.env.ref(
|
||||
'sf_manufacturing.stock_location_locations_virtual_outcontract').id,
|
||||
location_dest_id = self.env['stock.location'].search(
|
||||
[('barcode', '=', 'WH-PREPRODUCTION')]).id,
|
||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id,
|
||||
outcontract_picking_type_in = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_in').id,
|
||||
outcontract_picking_type_out = self.env.ref(
|
||||
|
||||
@@ -476,9 +476,19 @@
|
||||
<page string="CMM程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<field name="cmm_ids" widget="one2many" string="CMM程序">
|
||||
<tree>
|
||||
<field name="program_path"/>
|
||||
<field name="program_date"/>
|
||||
<field name="post_processing_name"/>
|
||||
<field name="sequence_number"/>
|
||||
<field name="program_name"/>
|
||||
<field name="cmm_id" string="文件"/>
|
||||
<field name="cutting_tool_name"/>
|
||||
<field name="cutting_tool_no"/>
|
||||
<field name="processing_type"/>
|
||||
<field name="margin_x_y"/>
|
||||
<field name="margin_z"/>
|
||||
<field name="depth_of_processing_z"/>
|
||||
<field name="cutting_tool_extension_length"/>
|
||||
<field name="cutting_tool_handle_type"/>
|
||||
<field name="estimated_processing_time"/>
|
||||
<field name="remark"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
@@ -44,12 +44,18 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
return json.JSONEncoder().encode(res)
|
||||
logging.info('创建cnc工单')
|
||||
program_path_tmp = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||
# program_path_tmp = "C://Users//43484//Desktop//机企猫工作文档//其他//model_analysis"
|
||||
files = os.listdir(program_path_tmp)
|
||||
for f in files:
|
||||
program_path = os.path.join(program_path_tmp, f)
|
||||
logging.info('cnc程序路径 :%s' % program_path)
|
||||
if f.endswith(".doc"):
|
||||
# 插入cmm程序数据
|
||||
request.env['sf.cmm.program'].with_user(
|
||||
request.env.ref("base.user_admin")).cmm_program_create(ret, program_path, program_path_tmp)
|
||||
request.env['sf.cnc.processing'].with_user(
|
||||
request.env.ref("base.user_admin")).cnc_processing_create(cnc_production, ret, program_path,program_path_tmp)
|
||||
request.env.ref("base.user_admin")).cnc_processing_create(cnc_production, ret, program_path,
|
||||
program_path_tmp)
|
||||
return json.JSONEncoder().encode(res)
|
||||
else:
|
||||
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
||||
|
||||
@@ -471,14 +471,6 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||
records = super(RealTimeDistributionOfFunctionalTools, self).create(vals_list)
|
||||
return records
|
||||
|
||||
def write(self, vals):
|
||||
res = super().write(vals)
|
||||
for item in self:
|
||||
if item:
|
||||
if vals.get('min_stock_num') or vals.get('max_stock_num'):
|
||||
item.enroll_functional_tool_real_time_distribution()
|
||||
return res
|
||||
|
||||
|
||||
class MachineTableToolChangingApply(models.Model):
|
||||
_name = 'sf.machine.table.tool.changing.apply'
|
||||
@@ -830,7 +822,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
code = fields.Char('功能刀具编码', readonly=True)
|
||||
rfid = fields.Char('Rfid', readonly=True)
|
||||
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=True)
|
||||
name = fields.Char(string='名称', readonly=True, compute='_compute_name')
|
||||
name = fields.Char(string='名称', readonly=True, compute='_compute_name', store=True)
|
||||
assembly_order_code = fields.Char(string='组装单编码', readonly=True)
|
||||
|
||||
functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', readonly=True)
|
||||
|
||||
@@ -362,3 +362,9 @@ class RealTimeDistributionFunctionalTools(models.Model):
|
||||
if record:
|
||||
record.enroll_functional_tool_real_time_distribution()
|
||||
return records
|
||||
|
||||
def write(self, vals):
|
||||
res = super().write(vals)
|
||||
if vals.get('sf_functional_cutting_tool_entity_ids') or vals.get('min_stock_num') or vals.get('max_stock_num'):
|
||||
self.enroll_functional_tool_real_time_distribution()
|
||||
return res
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_functional_cutting_tool_entity_group_plan_dispatch,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_functional_tool_warning,sf.functional.tool.warning,model_sf_functional_tool_warning,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_functional_tool_warning_group_plan_dispatch,sf.functional.tool.warning,model_sf_functional_tool_warning,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_real_time_distribution_of_functional_tools,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_real_time_distribution_of_functional_tools_group_plan_dispatch,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_cam_work_order_program_knife_plan,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,sf_base.group_sf_tool_user,1,1,1,0
|
||||
|
||||
|
||||
access_sf_tool_change_requirement_information,sf.tool.change.requirement.information,model_sf_tool_change_requirement_information,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_tool_transfer_request_information,sf.tool.transfer.request.information,model_sf_tool_transfer_request_information,sf_base.group_sf_tool_user,1,1,1,0
|
||||
|
||||
access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_fixture_material_search,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_sf_tool_user,1,1,1,0
|
||||
|
||||
|
||||
access_sf_functional_cutting_tool_entity_group_plan_dispatch,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_functional_tool_warning_group_plan_dispatch,sf.functional.tool.warning,model_sf_functional_tool_warning,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_real_time_distribution_of_functional_tools_group_plan_dispatch,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,sf_base.group_plan_dispatch,1,1,0,0
|
||||
|
||||
access_sf_cam_work_order_program_knife_plan_group_plan_dispatch,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_machine_table_tool_changing_apply_group_plan_dispatch,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
|
||||
access_sf_tool_change_requirement_information,sf.tool.change.requirement.information,model_sf_tool_change_requirement_information,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_tool_change_requirement_information_group_plan_dispatch,sf.tool.change.requirement.information,model_sf_tool_change_requirement_information,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_tool_transfer_request_information,sf.tool.transfer.request.information,model_sf_tool_transfer_request_information,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_tool_transfer_request_information_group_plan_dispatch,sf.tool.transfer.request.information,model_sf_tool_transfer_request_information,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_functional_tool_assembly_group_plan_dispatch,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_functional_tool_assembly_order_group_plan_dispatch,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
access_sf_fixture_material_search,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_sf_order_user,1,0,0,0
|
||||
access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
@@ -100,6 +100,6 @@
|
||||
name="夹具物料查询"
|
||||
id="menu_sf_fixture_material_search"
|
||||
action="action_sf_fixture_material_search"
|
||||
parent="menu_sf_tool_manage"
|
||||
parent="menu_sf_fixture"
|
||||
/>
|
||||
</odoo>
|
||||
@@ -7,6 +7,13 @@
|
||||
groups="mrp.group_mrp_routings"
|
||||
parent="mrp.menu_mrp_root"
|
||||
sequence="20"/>
|
||||
|
||||
<menuitem id="menu_sf_fixture"
|
||||
name="夹具管理"
|
||||
groups="sf_base.group_sf_order_user"
|
||||
parent="mrp.menu_mrp_root"
|
||||
sequence="20"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_functional_cutting_tool"
|
||||
parent="menu_sf_tool_manage"
|
||||
|
||||
@@ -540,6 +540,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
return {
|
||||
'barcode_id': stock_lot.id,
|
||||
'code': self.tool_code,
|
||||
'name': self.after_assembly_functional_tool_name,
|
||||
'rfid': self.rfid,
|
||||
'tool_groups_id': self.tool_groups_id.id,
|
||||
'integral_code_id': self.integral_code_id.id,
|
||||
|
||||
Reference in New Issue
Block a user