恢复代码
This commit is contained in:
@@ -26,4 +26,3 @@ class ResPartner(models.Model):
|
||||
|
||||
sf_token = fields.Char(u'Token', default=get_token)
|
||||
sf_secret_key = fields.Char(u'密钥', default=get_secret)
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="single_manufacturing">true</field>
|
||||
<field name="tracking">serial</field>
|
||||
<!-- <field name="active" eval="False"/>-->
|
||||
</record>
|
||||
|
||||
<record id="product_embryo_sf_outsource" model="product.product">
|
||||
@@ -61,7 +60,6 @@
|
||||
<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="active" eval="False"/>-->
|
||||
</record>
|
||||
<record id="product_embryo_sf_purchase" model="product.product">
|
||||
<field name="name">胚料采购模板</field>
|
||||
@@ -76,7 +74,6 @@
|
||||
<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="active" eval="False"/>-->
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,3 +1,5 @@
|
||||
from. import product_template
|
||||
from. import product_supplierinfo
|
||||
|
||||
|
||||
|
||||
|
||||
11
sf_dlm/models/product_supplierinfo.py
Normal file
11
sf_dlm/models/product_supplierinfo.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ResSupplierInfo(models.Model):
|
||||
_inherit = 'product.supplierinfo'
|
||||
|
||||
def _compute_is_subcontractor(self):
|
||||
for supplier in self:
|
||||
boms = supplier.product_id.variant_bom_ids
|
||||
boms |= supplier.product_tmpl_id.bom_ids.filtered(lambda b: not b.product_id or b.product_id in (supplier.product_id or supplier.product_tmpl_id.product_variant_ids))
|
||||
supplier.is_subcontractor = supplier.partner_id in boms.subcontractor_id
|
||||
@@ -82,7 +82,7 @@ class ResProductTemplate(models.Model):
|
||||
item['model_height'] + model_type.embryo_tolerance),
|
||||
'model_type_id': model_type.id,
|
||||
'model_processing_panel': 'R',
|
||||
'model_machining_precision': item['model_machining_precision'],
|
||||
'model_machining_precision': item['model_machining_precision'],
|
||||
'model_code': item['barcode'],
|
||||
'length': item['model_long'],
|
||||
'width': item['model_width'],
|
||||
@@ -92,7 +92,7 @@ class ResProductTemplate(models.Model):
|
||||
'model_name': attachment.name,
|
||||
'upload_model_file': [(6, 0, [attachment.id])],
|
||||
# 'single_manufacturing': True,
|
||||
'tracking': 'serial',
|
||||
# 'tracking': 'serial',
|
||||
'list_price': item['price'],
|
||||
# 'categ_id': self.env.ref('sf_dlm.product_category_finished_sf').id,
|
||||
'materials_id': self.env['sf.production.materials'].search(
|
||||
@@ -158,14 +158,13 @@ class ResProductTemplate(models.Model):
|
||||
'active': True
|
||||
}
|
||||
# 外协和采购生成的胚料需要根据材料型号绑定供应商
|
||||
if route_type == 'subcontract':
|
||||
no_bom_copy_product_id.purchase_ok = True
|
||||
no_bom_copy_product_id.seller_ids = [
|
||||
(0, 0, {'partner_id': supplier.partner_id.id, 'delay': 1.0, 'is_subcontractor': True})]
|
||||
elif route_type == 'purchase':
|
||||
if route_type == 'subcontract' or route_type == 'purchase':
|
||||
no_bom_copy_product_id.purchase_ok = True
|
||||
no_bom_copy_product_id.seller_ids = [
|
||||
(0, 0, {'partner_id': supplier.partner_id.id, 'delay': 1.0})]
|
||||
if route_type == 'subcontract':
|
||||
partner = self.env['res.partner'].search([('id', '=', supplier.partner_id.id)])
|
||||
partner.is_subcontractor = True
|
||||
no_bom_copy_product_id.write(vals)
|
||||
logging.info('no_bom_copy_product_id-vals:%s' % vals)
|
||||
# product_id.product_tmpl_id.active = False
|
||||
@@ -249,7 +248,6 @@ class ResMrpBom(models.Model):
|
||||
[('materials_model_id', '=', materials_type.id)],
|
||||
limit=1,
|
||||
order='sequence asc')
|
||||
logging.info('get_supplier-vals:%s' % seller_id)
|
||||
return seller_id
|
||||
|
||||
# 匹配bom
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_only_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<!-- <field name="image_1920" position="replace">-->
|
||||
<!-- <field name="upload_model_file" required="True"-->
|
||||
<!-- widget='many2many_binary'/>-->
|
||||
<!-- </field>-->
|
||||
<!-- <field name="image_1920" position="replace">-->
|
||||
<!-- <field name="upload_model_file" required="True"-->
|
||||
<!-- widget='many2many_binary'/>-->
|
||||
<!-- </field>-->
|
||||
|
||||
<field name="invoice_policy" position="after">
|
||||
<field name="model_file" required="True" widget="model_viewer"/>
|
||||
<field name="model_file" widget="model_viewer" />
|
||||
<field name="materials_id" string="材料"/>
|
||||
<field name="materials_type_id" string="型号"
|
||||
domain="[('materials_id', '=', materials_id)]"/>
|
||||
@@ -36,18 +36,31 @@
|
||||
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="加工参数">
|
||||
<group string="模型">
|
||||
<field name="model_long" string="长[mm]"/>
|
||||
<field name="model_width" string="宽[mm]"/>
|
||||
<field name="model_height" string="高[mm]"/>
|
||||
<field name="model_volume" string="体积[m³]"/>
|
||||
<field name="model_type_id" string="模型类型"/>
|
||||
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板"/>
|
||||
<field name="model_machining_precision"/>
|
||||
<field name="model_surface_process_id" string="表面工艺"/>
|
||||
<field name="model_process_parameters_id" string="工艺参数"
|
||||
domain="[('processing_order_ids', '=', model_surface_process_id)]"/>
|
||||
<field name="model_remark" string="备注说明"/>
|
||||
<group>
|
||||
<group string="模型">
|
||||
<label for="model_long" string="尺寸[mm]"/>
|
||||
<div class="o_address_format">
|
||||
<label for="model_long" string="长"/>
|
||||
<field name="model_long" class="o_address_zip"/>
|
||||
<!-- <span>&nbsp;</span>-->
|
||||
<label for="model_width" string="宽"/>
|
||||
<field name="model_width" class="o_address_zip"/>
|
||||
<!-- <span>&nbsp;</span>-->
|
||||
<label for="model_height" string="高"/>
|
||||
<field name="model_height" class="o_address_zip"/>
|
||||
</div>
|
||||
<!-- <field name="model_long" string="长[mm]"/>-->
|
||||
<!-- <field name="model_width" string="宽[mm]"/>-->
|
||||
<!-- <field name="model_height" string="高[mm]"/>-->
|
||||
<field name="model_volume" string="体积[mm³]"/>
|
||||
<field name="model_type_id" string="模型类型"/>
|
||||
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板"/>
|
||||
<field name="model_machining_precision"/>
|
||||
<field name="model_surface_process_id" string="表面工艺"/>
|
||||
<field name="model_process_parameters_id" string="工艺参数"
|
||||
domain="[('processing_order_ids', '=', model_surface_process_id)]"/>
|
||||
<field name="model_remark" string="备注说明"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': '机企猫智能工厂 对接机床',
|
||||
'version': '2.0',
|
||||
'summary': 'sf_machine_connect',
|
||||
'name': 'sf_machine_connect',
|
||||
'version': '1.0',
|
||||
'summary': '智能工厂机床连接模块',
|
||||
'sequence': 10,
|
||||
'description': """
|
||||
这是一个模块
|
||||
@@ -20,7 +20,6 @@
|
||||
'views/WorkCenterBarcodes.xml',
|
||||
'views/Stock_picking_Barcodes.xml',
|
||||
'views/machine_monitor.xml',
|
||||
# 'views/machine_info_present.xml',
|
||||
],
|
||||
|
||||
'assets': {
|
||||
|
||||
@@ -24,23 +24,6 @@ class FtpButton(models.Model):
|
||||
_inherit = 'sf.cnc.processing'
|
||||
|
||||
button_state = fields.Boolean(string='是否已经下发')
|
||||
user_permissions = fields.Boolean(string='权限', related='workorder_id.user_permissions')
|
||||
state = fields.Selection(string='状态', related='workorder_id.state')
|
||||
|
||||
@api.onchange('users_ids')
|
||||
def get_user_permissions(self):
|
||||
uid = self.env.uid
|
||||
for workorder in self:
|
||||
if workorder.users_ids:
|
||||
list_user_id = []
|
||||
for item in workorder.users_ids:
|
||||
list_user_id.append(item.id)
|
||||
if uid in list_user_id:
|
||||
workorder.user_permissions = True
|
||||
else:
|
||||
workorder.user_permissions = False
|
||||
else:
|
||||
workorder.user_permissions = False
|
||||
|
||||
def pri(self):
|
||||
"""
|
||||
@@ -70,13 +53,7 @@ class FtpButton(models.Model):
|
||||
except Exception:
|
||||
raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态")
|
||||
|
||||
# host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
||||
host = self.workorder_id.workcenter_id.machine_tool_id.ftp_host
|
||||
port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port
|
||||
username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num
|
||||
pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd
|
||||
|
||||
ftp = ftp_operate.FtpController(host, port, username, pwd)
|
||||
ftp = ftp_operate.FtpController()
|
||||
# ftp.delAllfile('C://Users//马广威//Desktop//ftp')
|
||||
a = self.cnc_id
|
||||
_logger.info(a.public)
|
||||
@@ -85,14 +62,12 @@ class FtpButton(models.Model):
|
||||
|
||||
# file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name)
|
||||
file_path_local = '{}/{}'.format('/nc2machine', a.display_name)
|
||||
file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name)
|
||||
file_path_remote = '{}\{}'.format('//(192,168,2,141)//DS', a.display_name)
|
||||
|
||||
with open(file_path_local, mode='wb+') as file:
|
||||
file.write(datas)
|
||||
# 存在本地的文件下发到机床
|
||||
_logger.info("=====================11================")
|
||||
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||
_logger.info("=====================22================")
|
||||
except Exception as e:
|
||||
_logger.info("=====================================", e)
|
||||
raise UserError('NC下发执行超时, 请检查下发状态')
|
||||
@@ -109,41 +84,6 @@ class FtpButton(models.Model):
|
||||
# 'type': 'ir.actions.act_window',
|
||||
# 'target': 'new'
|
||||
# }
|
||||
# def up_all(self):
|
||||
# """
|
||||
# 此函数用于将NC代码全部下发到机床
|
||||
# :return:
|
||||
# """
|
||||
# # host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
||||
# host = self.workorder_id.workcenter_id.machine_tool_id.ftp_host
|
||||
# port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port
|
||||
# username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num
|
||||
# pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd
|
||||
#
|
||||
# ftp = ftp_operate.FtpController(host, port, username, pwd)
|
||||
# # ftp.delAllfile('C://Users//马广威//Desktop//ftp')
|
||||
# for item in self.cnc_ids:
|
||||
# a = item.cnc_id
|
||||
# print(a.display_name)
|
||||
# # _logger.info(a.public)
|
||||
# # _logger.info(a.display_name)
|
||||
# # datas = base64.standard_b64decode(a.datas)
|
||||
# #
|
||||
# # # file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name)
|
||||
# # # file_path_local = '{}/{}'.format('/nc2machine', a.display_name)
|
||||
# # file_path_local = '{}/{}'.format('D:\\jikimo', a.display_name)
|
||||
# # # file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name)
|
||||
# #
|
||||
# # with open(file_path_local, mode='wb+') as file:
|
||||
# # file.write(datas)
|
||||
# # 存在本地的文件下发到机床
|
||||
# # _logger.info("=====================11================")
|
||||
# # ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||
# # _logger.info("=====================22================")
|
||||
# # except Exception as e:
|
||||
# # _logger.info("=====================================", e)
|
||||
# # raise UserError('NC下发执行超时, 请检查下发状态')
|
||||
|
||||
|
||||
def check_compensation_before_up(self):
|
||||
"""
|
||||
@@ -153,9 +93,9 @@ class FtpButton(models.Model):
|
||||
try:
|
||||
temp_dict = {}
|
||||
temp_dict[
|
||||
'ns=1;s=Project_Default.Group1.Mitsubishi_NC.hongbianliang550'] = self.workorder_id.compensation_value_x
|
||||
'ns=1;s=Project_Default.Group1.Mitsubishi_NC2.hongbianliang550'] = self.workorder_id.compensation_value_x
|
||||
temp_dict[
|
||||
'ns=1;s=Project_Default.Group1.Mitsubishi_NC.hongbianliang551'] = self.workorder_id.compensation_value_y
|
||||
'ns=1;s=Project_Default.Group1.Mitsubishi_NC2.hongbianliang551'] = self.workorder_id.compensation_value_y
|
||||
temp = py2opcua.Py2opcua()
|
||||
# temp.connect()
|
||||
temp.write(temp_dict)
|
||||
@@ -171,21 +111,6 @@ class Machine_ftp(models.Model):
|
||||
"""
|
||||
_inherit = 'sf.machine_tool'
|
||||
|
||||
workorder_ids = fields.One2many('mrp.workorder', 'machine_tool_id', string='工单')
|
||||
|
||||
# 机床配置项目
|
||||
# ftp相关
|
||||
ftp_num = fields.Char('ftp账号')
|
||||
ftp_pwd = fields.Char('ftp密码')
|
||||
ftp_host = fields.Char('ftp地址')
|
||||
ftp_port = fields.Integer('ftp端口')
|
||||
# 补偿值写入相关
|
||||
x_compensation_node = fields.Char('x补偿值节点')
|
||||
y_compensation_node = fields.Char('y补偿值节点')
|
||||
# 数采配置相关
|
||||
machine_ip = fields.Char('机床IP')
|
||||
|
||||
# 机床采集项目
|
||||
timestamp = fields.Datetime('时间戳', readonly=True)
|
||||
signed = fields.Integer('刷新间隔', readonly=True)
|
||||
status = fields.Boolean('在线状态', readonly=True)
|
||||
@@ -235,63 +160,25 @@ class WorkCenterBarcode(models.Model):
|
||||
compensation_value_x = fields.Float(string='X轴补偿值')
|
||||
compensation_value_y = fields.Float(string='Y轴补偿值')
|
||||
button_compensation_state = fields.Boolean(string='是否已经补偿')
|
||||
machine_tool_id = fields.Many2one('sf.machine_tool', string='机床')
|
||||
|
||||
def compensation(self):
|
||||
|
||||
hongbianliang550 = self.workcenter_id.machine_tool_id.x_compensation_node
|
||||
hongbianliang551 = self.workcenter_id.machine_tool_id.y_compensation_node
|
||||
|
||||
"""
|
||||
将节点与其值放入字典,字典作为参数传入
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
temp_dict = {}
|
||||
temp_dict[hongbianliang550] = self.compensation_value_x
|
||||
temp_dict[hongbianliang551] = self.compensation_value_y
|
||||
print("=================================")
|
||||
print(temp_dict)
|
||||
# temp = py2opcua.Py2opcua()
|
||||
# # temp.connect()
|
||||
# temp.write(temp_dict)
|
||||
# self.button_compensation_state = True
|
||||
temp_dict['ns=1;s=Project_Default.Group1.Mitsubishi_NC2.hongbianliang550'] = self.compensation_value_x
|
||||
temp_dict['ns=1;s=Project_Default.Group1.Mitsubishi_NC2.hongbianliang551'] = self.compensation_value_y
|
||||
temp = py2opcua.Py2opcua()
|
||||
# temp.connect()
|
||||
temp.write(temp_dict)
|
||||
self.button_compensation_state = True
|
||||
# temp.disconnect()
|
||||
except Exception as e:
|
||||
_logger.info("=====================================", e)
|
||||
raise UserError('补偿值获取失败,或机床未连接,请检查')
|
||||
|
||||
def up_all(self):
|
||||
"""
|
||||
此函数用于将NC代码全部下发到机床
|
||||
:return:
|
||||
"""
|
||||
# host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
||||
host = self.workcenter_id.machine_tool_id.ftp_host
|
||||
port = self.workcenter_id.machine_tool_id.ftp_port
|
||||
username = self.workcenter_id.machine_tool_id.ftp_num
|
||||
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
|
||||
print(host, port, username, pwd)
|
||||
# ftp = ftp_operate.FtpController(host, port, username, pwd)
|
||||
# ftp.delAllfile('C://Users//马广威//Desktop//ftp')
|
||||
for item in self.cnc_ids:
|
||||
a = item.cnc_id
|
||||
print(a.display_name)
|
||||
_logger.info(a.public)
|
||||
_logger.info(a.display_name)
|
||||
datas = base64.standard_b64decode(a.datas)
|
||||
|
||||
# file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name)
|
||||
# file_path_local = '{}/{}'.format('/nc2machine', a.display_name)
|
||||
file_path_local = '{}/{}'.format('D:\\jikimo', a.display_name)
|
||||
# file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name)
|
||||
|
||||
with open(file_path_local, mode='wb+') as file:
|
||||
file.write(datas)
|
||||
# 存在本地的文件下发到机床
|
||||
# _logger.info("=====================11================")
|
||||
# ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||
# _logger.info("=====================22================")
|
||||
# except Exception as e:
|
||||
# _logger.info("=====================================", e)
|
||||
# raise UserError('NC下发执行超时, 请检查下发状态')
|
||||
|
||||
def get__state(self):
|
||||
pay_time = str(datetime.now())
|
||||
json = {
|
||||
|
||||
@@ -45,9 +45,6 @@ class FtpController:
|
||||
self.port = port
|
||||
self.username = username
|
||||
self.password = password
|
||||
# 测试
|
||||
print("==============================================")
|
||||
print(self.username, self.port, self.host, self.password)
|
||||
ftp = FTP_P()
|
||||
# self.ftp.set_debuglevel(2) #打开调试级别2,显示详细信息
|
||||
ftp.set_pasv(0) # 0主动模式 1 #被动模式
|
||||
@@ -71,7 +68,7 @@ class FtpController:
|
||||
:param localpath:
|
||||
:return:
|
||||
"""
|
||||
bufsize = 8192
|
||||
bufsize = 1024
|
||||
# fp = open(localpath, 'rb')
|
||||
# self.ftp.storbinary('STOR ' + remotepath, fp, bufsize)
|
||||
# fp.close()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
<record id="sf_install_the_tray_workorder_form_view__scan_barcode" model="ir.ui.view">
|
||||
<field name="name">sf.install.the.tray.workorder.form.scan.barcode</field>
|
||||
@@ -8,6 +8,7 @@
|
||||
<xpath expr="//page//field[@name='tray_code']" position="before">
|
||||
<!-- invisible="1" -->
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
<field name="tray_code" widget="code"/>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
|
||||
@@ -11,26 +11,12 @@
|
||||
<field name="compensation_value_y"/>
|
||||
</group>
|
||||
<div>
|
||||
<div>
|
||||
<field name="button_compensation_state"/>
|
||||
<button string="一键补偿" name="compensation" type="object" confirm="是否确认下发补偿"
|
||||
class="btn-primary" attrs='{"invisible": ["|",
|
||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
||||
<button string="一键下发" name="up_all" type="object" style="text-align: right;" confirm="是否确认一键下发"
|
||||
class="btn-primary" attrs='{"invisible": ["|",
|
||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
||||
</div>
|
||||
|
||||
|
||||
<field name="button_compensation_state"/>
|
||||
<button string="一键补偿" name="compensation" type="object" confirm="是否确认下发补偿" class="btn-primary"/>
|
||||
<!-- <button string="显示补偿" name="compensation1" type="object" confirm="是否确认下发补偿" class="btn-primary"/>-->
|
||||
<!-- <button string="修改状态" name="get__state" type="object" class="btn-primary"/>-->
|
||||
|
||||
</div>
|
||||
<!-- <div>-->
|
||||
<!-- <button string="一键下发" name="up_all" type="object" confirm="是否确认一键下发"-->
|
||||
<!-- class="btn-primary" attrs='{"invisible": ["|",-->
|
||||
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->
|
||||
<!-- </div>-->
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
|
||||
@@ -10,17 +10,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='remark']" position="after">
|
||||
<!-- <button string="测试按钮" name="pri" type="object" class="btn-primary"/>-->
|
||||
<!-- <field name="workorder_id" invisible="1"/>-->
|
||||
<field name="button_state"/>
|
||||
<field name="user_permissions" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"
|
||||
attrs='{"invisible": ["|",("state","!=","progress"),
|
||||
("user_permissions","!=",True)]}'/>
|
||||
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"/>-->
|
||||
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"-->
|
||||
<!-- />-->
|
||||
|
||||
<button string="下发按钮" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"/>
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -9,10 +9,7 @@
|
||||
<!-- <xpath expr="//field[@name='knife_type']" position="before">-->
|
||||
<xpath expr="//form//notebook//page[1]" position="inside">
|
||||
<!-- <xpath expr="//page[@name='other']" position="before">-->
|
||||
<notebook>
|
||||
<page string="机床监控">
|
||||
<!-- <group string="监控">-->
|
||||
<group>
|
||||
<group string="监控">
|
||||
<field name="timestamp"/>
|
||||
<field name="signed"/>
|
||||
<field name="status"/>
|
||||
@@ -98,29 +95,6 @@
|
||||
<!-- <field name="tool_num_process_time24" class="o_form_label"/>-->
|
||||
<!-- </div>-->
|
||||
</group>
|
||||
</page>
|
||||
<page string="机床配置">
|
||||
<!-- <group string="机床配置">-->
|
||||
<group>
|
||||
<group string="ftp相关">
|
||||
<field name="ftp_num"/>
|
||||
<field name="ftp_pwd"/>
|
||||
<field name="ftp_host"/>
|
||||
<field name="ftp_port"/>
|
||||
</group>
|
||||
<group string="补偿值相关">
|
||||
<field name="x_compensation_node"/>
|
||||
<field name="y_compensation_node"/>
|
||||
</group>
|
||||
<group string="数采相关">
|
||||
<field name="machine_ip"/>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -13,6 +13,24 @@ class ResWorkcenter(models.Model):
|
||||
'maintenance.equipment', 'workcenter_id', string="Maintenance Equipment",
|
||||
check_company=True)
|
||||
|
||||
@api.onchange('machine_tool_id')
|
||||
def update_machine_tool_is_binding(self):
|
||||
machine_tool = self.env["sf.machine_tool"].search([('is_binding', '=', True)])
|
||||
if machine_tool:
|
||||
for item in machine_tool:
|
||||
workcenter_machine_tool = self.env["mrp.workcenter"].search([('machine_tool_id', '=', item.id)])
|
||||
if workcenter_machine_tool:
|
||||
if self.machine_tool_id.id:
|
||||
if workcenter_machine_tool.id != self.machine_tool_id.id:
|
||||
self.machine_tool_id.is_binding = True
|
||||
else:
|
||||
self.machine_tool_id.is_binding = True
|
||||
else:
|
||||
self.machine_tool_id.is_binding = True
|
||||
item.is_binding = False
|
||||
else:
|
||||
self.machine_tool_id.is_binding = True
|
||||
|
||||
def action_work_order(self):
|
||||
if not self.env.context.get('desktop_list_view', False):
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("sf_manufacturing.mrp_workorder_action_tablet")
|
||||
|
||||
@@ -24,19 +24,19 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- <record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">-->
|
||||
<!-- <field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>-->
|
||||
<!-- <field name="model">mrp.workcenter</field>-->
|
||||
<!-- <field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <!– Desktop view –>-->
|
||||
<!-- <xpath expr="//div[@name='o_wo']" position="inside">-->
|
||||
<!-- <button class="btn btn-secondary fa fa-desktop" name="action_work_order" type="object"-->
|
||||
<!-- context="{'search_default_ready': 1, 'search_default_progress': 1, 'search_default_pending': 1, 'desktop_list_view': 1, 'search_default_workcenter_id': active_id}"-->
|
||||
<!-- title="Work orders" aria-label="Work orders"/>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
<record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">
|
||||
<field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>
|
||||
<field name="model">mrp.workcenter</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>
|
||||
<field name="arch" type="xml">
|
||||
<!-- Desktop view -->
|
||||
<xpath expr="//div[@name='o_wo']" position="inside">
|
||||
<button class="btn btn-secondary fa fa-desktop" name="action_work_order" type="object"
|
||||
context="{'search_default_ready': 1, 'search_default_progress': 1, 'search_default_pending': 1, 'desktop_list_view': 1, 'search_default_workcenter_id': active_id}"
|
||||
title="Work orders" aria-label="Work orders"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- override to change the no content image -->
|
||||
<record id="mrp.action_work_orders" model="ir.actions.act_window">
|
||||
@@ -56,10 +56,10 @@
|
||||
</field>
|
||||
</record>
|
||||
<record id="mrp_workcenter_kanban_action1" model="ir.actions.act_window">
|
||||
<field name="name">工作中心看板</field>
|
||||
<field name="name">Work Centers Overview</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">mrp.workcenter</field>
|
||||
<field name="view_mode">kanban,form,tree</field>
|
||||
<field name="view_mode">kanban,form</field>
|
||||
<field name="view_id" ref="mrp.mrp_workcenter_kanban"/>
|
||||
<field name="search_view_id" ref="mrp.view_mrp_workcenter_search"/>
|
||||
<field name="domain">[('users_ids','in',uid)]</field>
|
||||
@@ -107,7 +107,7 @@
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='alternative_workcenter_ids']" position="after">
|
||||
<field name="machine_tool_id"/>
|
||||
<field name="machine_tool_id" domain="[('is_binding','=',False)]"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<field name="name" position="after">
|
||||
<field name="processing_panel"/>
|
||||
</field>
|
||||
<field name="state" position="after">
|
||||
<field name="state" position="after">
|
||||
<field name="work_state"/>
|
||||
</field>
|
||||
<xpath expr="//button[@name='button_start']" position="attributes">
|
||||
@@ -91,24 +91,12 @@
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<sheet position="before">
|
||||
<xpath expr="field[@name='is_user_working']" position="before">
|
||||
<field name='user_permissions' invisible="1"/>
|
||||
<button name="button_start" type="object" string="开始" class="btn-success"
|
||||
attrs="{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done',
|
||||
'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')),
|
||||
('is_user_working', '!=', False),('user_permissions','=',False)]}"/>
|
||||
<button name="button_pending" type="object" string="暂停" class="btn-warning"
|
||||
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
|
||||
<button name="button_finish" type="object" string="完成" class="btn-success"
|
||||
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
|
||||
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
|
||||
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'),('user_permissions','=',False)]}"/>
|
||||
<button name="button_unblock" type="object" string="Unblock" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
|
||||
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>
|
||||
</sheet>
|
||||
</xpath>
|
||||
|
||||
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}'>
|
||||
<group>
|
||||
<field name="programming_no" readonly="1"
|
||||
@@ -127,8 +115,7 @@
|
||||
</page>
|
||||
|
||||
</xpath>
|
||||
<!-- <page string="Components" name="components">-->
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="装夹托盘" attrs='{"invisible": [("routing_type","!=","装夹")]}'>
|
||||
<group>
|
||||
<field name="routing_type" invisible="1"/>
|
||||
@@ -145,7 +132,7 @@
|
||||
</page>
|
||||
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="三元前置检测定位参数" attrs='{"invisible": [("routing_type","!=","前置三元定位检测")]}'>
|
||||
<group>
|
||||
<group>
|
||||
@@ -261,7 +248,7 @@
|
||||
</page>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<group>
|
||||
<field name="cnc_ids" widget="one2many" string="工作程序">
|
||||
@@ -285,7 +272,7 @@
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
|
||||
<group>
|
||||
<field name="test_results" widget="selection"/>
|
||||
@@ -297,7 +284,7 @@
|
||||
</div>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
|
||||
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
|
||||
@@ -27,7 +27,8 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
# 查询状态为进行中且类型为获取CNC加工程序的工单
|
||||
cnc_workorder = request.env['mrp.workorder'].with_user(
|
||||
request.env.ref("base.user_admin")).search([('production_id.name', '=', ret['production_order_no']),
|
||||
('routing_type', '=', '获取CNC加工程序')])
|
||||
('routing_type', '=', '获取CNC加工程序'),
|
||||
('state', '=', 'progress')])
|
||||
if cnc_workorder:
|
||||
# 拉取所有加工面的程序文件
|
||||
# i = 1
|
||||
|
||||
@@ -111,7 +111,7 @@ class sfMaterialModel(models.Model):
|
||||
brand.active = item['active'],
|
||||
brand.mf_materia_post = item['mf_materia_post'],
|
||||
brand.materials_id = self.env['sf.production.materials'].search(
|
||||
[("materials_no", '=', item['materials_id.materials_no'])]).id,
|
||||
[("materials_no", '=', item['materials_id.materials_no'])]).id,
|
||||
brand.need_h = item['need_h'],
|
||||
brand.density = item['density']
|
||||
else:
|
||||
@@ -158,9 +158,9 @@ class sfMaterialModel(models.Model):
|
||||
"need_h": item['need_h'],
|
||||
"mf_materia_post": item['mf_materia_post'],
|
||||
"density": item['density'],
|
||||
# "tag_ids": item['tag_ids']
|
||||
# "tag_ids": item['tag_ids']
|
||||
|
||||
})
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
@@ -392,7 +392,7 @@ class MachineControlSystem(models.Model):
|
||||
brand.id = item['id'],
|
||||
brand.name = item['name'],
|
||||
brand.code = item['code'],
|
||||
brand.brand_id=self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
brand.active = item['active']
|
||||
else:
|
||||
self.env['sf.machine.control_system'].create({
|
||||
@@ -500,12 +500,9 @@ class MachineBrand(models.Model):
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
# "image_brand": item['image_brand'],
|
||||
"active": item['active'],
|
||||
"image_brand": '' if not item['image_brand'] else base64.b64encode(item.image_brand),
|
||||
"tag_ids": self.env['sf.machine.brand.tags'].search(
|
||||
[("name", 'in', item['tag_ids'])]).ids
|
||||
|
||||
|
||||
[("name", 'in', item['tag_ids'])]).ids
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
@@ -517,8 +514,6 @@ class MachineTool(models.Model):
|
||||
url = '/api/machine_tool/list'
|
||||
crea_url = '/api/machine_tool/create'
|
||||
|
||||
|
||||
|
||||
# 定时同步机床
|
||||
def sync_machine_tool(self):
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
@@ -657,7 +652,8 @@ class MachineToolType(models.Model):
|
||||
brand.number_of_knife_library = item['number_of_knife_library'],
|
||||
brand.rotate_speed = item['rotate_speed'],
|
||||
brand.number_of_axles = item['number_of_axles'],
|
||||
brand.control_system_id = self.env['sf.machine.control_system'].search([('code', '=', item['control_system_id'])]).id,
|
||||
brand.control_system_id = self.env['sf.machine.control_system'].search(
|
||||
[('code', '=', item['control_system_id'])]).id,
|
||||
|
||||
brand.x_axis = item['x_axis'],
|
||||
brand.y_axis = item['y_axis'],
|
||||
@@ -666,8 +662,9 @@ class MachineToolType(models.Model):
|
||||
brand.c_axis = item['c_axis'],
|
||||
brand.active = item['active'],
|
||||
brand.remark = item['remark'],
|
||||
brand.brand_id=self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
brand.machine_tool_id = self.env['sf.machine_tool'].search([('code', '=', item['machine_tool_id'])]).id
|
||||
brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
brand.machine_tool_id = self.env['sf.machine_tool'].search(
|
||||
[('code', '=', item['machine_tool_id'])]).id
|
||||
|
||||
else:
|
||||
self.env['sf.machine_tool.type'].create({
|
||||
@@ -677,7 +674,8 @@ class MachineToolType(models.Model):
|
||||
|
||||
"number_of_knife_library": item['number_of_knife_library'],
|
||||
"rotate_speed": item['rotate_speed'],
|
||||
'machine_tool_id' : self.env['sf.machine_tool'].search([('code', '=', item['machine_tool_id'])]).id,
|
||||
'machine_tool_id': self.env['sf.machine_tool'].search(
|
||||
[('code', '=', item['machine_tool_id'])]).id,
|
||||
"number_of_axles": item['number_of_axles'],
|
||||
"x_axis": item['x_axis'],
|
||||
"y_axis": item['y_axis'],
|
||||
@@ -686,7 +684,8 @@ class MachineToolType(models.Model):
|
||||
"c_axis": item['c_axis'],
|
||||
"remark": item['remark'],
|
||||
"precision": item['precision'],
|
||||
'control_system_id' : self.env['sf.machine.control_system'].search([('code', '=', item['control_system_id'])]).id,
|
||||
'control_system_id': self.env['sf.machine.control_system'].search(
|
||||
[('code', '=', item['control_system_id'])]).id,
|
||||
"active": item['active'],
|
||||
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
|
||||
@@ -716,7 +715,8 @@ class MachineToolType(models.Model):
|
||||
"code": item['code'],
|
||||
"number_of_knife_library": item['number_of_knife_library'],
|
||||
"rotate_speed": item['rotate_speed'],
|
||||
'machine_tool_id' : self.env['sf.machine_tool'].search([('code', '=', item['machine_tool_id'])]).id,
|
||||
'machine_tool_id': self.env['sf.machine_tool'].search(
|
||||
[('code', '=', item['machine_tool_id'])]).id,
|
||||
"number_of_axles": item['number_of_axles'],
|
||||
"x_axis": item['x_axis'],
|
||||
"y_axis": item['y_axis'],
|
||||
@@ -725,7 +725,8 @@ class MachineToolType(models.Model):
|
||||
"c_axis": item['c_axis'],
|
||||
"remark": item['remark'],
|
||||
"precision": item['precision'],
|
||||
'control_system_id' : self.env['sf.machine.control_system'].search([('code', '=', item['control_system_id'])]).id,
|
||||
'control_system_id': self.env['sf.machine.control_system'].search(
|
||||
[('code', '=', item['control_system_id'])]).id,
|
||||
"active": item['active'],
|
||||
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
|
||||
@@ -836,7 +837,8 @@ class CuttingToolType(models.Model):
|
||||
brand.tool_length = item['tool_length'],
|
||||
brand.blade_number = item['blade_number']
|
||||
brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
brand.category_id = self.env['sf.cutting_tool.category'].search([('code', '=', item['category_id'])]).id
|
||||
brand.category_id = self.env['sf.cutting_tool.category'].search(
|
||||
[('code', '=', item['category_id'])]).id
|
||||
else:
|
||||
self.env['sf.cutting_tool.type'].create({
|
||||
"id": item['id'],
|
||||
@@ -852,7 +854,8 @@ class CuttingToolType(models.Model):
|
||||
"tool_length": item['tool_length'],
|
||||
"blade_number": item['blade_number'],
|
||||
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
"category_id": self.env['sf.cutting_tool.category'].search([('code', '=', item['category_id'])]).id,
|
||||
"category_id": self.env['sf.cutting_tool.category'].search(
|
||||
[('code', '=', item['category_id'])]).id,
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
@@ -887,13 +890,13 @@ class CuttingToolType(models.Model):
|
||||
"tool_length": item['tool_length'],
|
||||
"blade_number": item['blade_number'],
|
||||
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
"category_id": self.env['sf.cutting_tool.category'].search([('code', '=', item['category_id'])]).id,
|
||||
"category_id": self.env['sf.cutting_tool.category'].search(
|
||||
[('code', '=', item['category_id'])]).id,
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
|
||||
|
||||
class sfProcessingOrder(models.Model):
|
||||
_inherit = 'sf.processing.order'
|
||||
_description = '工序'
|
||||
@@ -948,4 +951,3 @@ class sfProcessingOrder(models.Model):
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user