处理coding报错
This commit is contained in:
@@ -38,9 +38,9 @@
|
|||||||
<xpath expr="//field[@name='state']" position="after">
|
<xpath expr="//field[@name='state']" position="after">
|
||||||
<field name="production_state" invisible="1"/>
|
<field name="production_state" invisible="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//button[@name='action_open_wizard']" position="after">
|
<!-- <xpath expr="//button[@name='action_open_wizard']" position="after">-->
|
||||||
<button name="open_tablet_view" type="object" icon="fa-tablet" title="Open Tablet View" context="{'from_production_order': True}" attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'cancel', 'done')), ('state', '=', 'done')]}"/>
|
<!-- <button name="open_tablet_view" type="object" icon="fa-tablet" title="Open Tablet View" context="{'from_production_order': True}" attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'cancel', 'done')), ('state', '=', 'done')]}"/>-->
|
||||||
</xpath>
|
<!-- </xpath>-->
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -40,212 +40,212 @@ class MachineBrand(models.Model):
|
|||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
# 机床
|
#机床
|
||||||
# class MachineTool(models.Model):
|
class MachineTool(models.Model):
|
||||||
# _name = 'sf.machine_tool'
|
_name = 'sf.machine_tool'
|
||||||
# _description = '机床'
|
_description = '机床'
|
||||||
#
|
|
||||||
# def get_no(self):
|
def get_no(self):
|
||||||
# partner = self.env['sf.machine_tool'].sudo().search(
|
partner = self.env['sf.machine_tool'].sudo().search(
|
||||||
# [('MTcode', '!=', '')],
|
[('MTcode', '!=', '')],
|
||||||
# limit=1,
|
limit=1,
|
||||||
# order="id desc")
|
order="id desc")
|
||||||
# if not partner:
|
if not partner:
|
||||||
# num = "%04d" % 1
|
num = "%04d" % 1
|
||||||
#
|
|
||||||
# else:
|
else:
|
||||||
# m = int(partner.MTcode) + 1
|
m = int(partner.MTcode) + 1
|
||||||
# num = "%04d" % m
|
num = "%04d" % m
|
||||||
# return num
|
return num
|
||||||
#
|
|
||||||
# MTcode = fields.Char("编码", default=get_no)
|
MTcode = fields.Char("编码", default=get_no)
|
||||||
# code = fields.Char('行业编码')
|
code = fields.Char('行业编码')
|
||||||
# name = fields.Char('名称')
|
name = fields.Char('名称')
|
||||||
# knife_type = fields.Selection(
|
knife_type = fields.Selection(
|
||||||
# [("BT40", "BT40"), ("BT30", "BT30")],
|
[("BT40", "BT40"), ("BT30", "BT30")],
|
||||||
# default="", string="刀把类型")
|
default="", string="刀把类型")
|
||||||
# number_of_knife_library = fields.Integer('刀库数量(把)')
|
number_of_knife_library = fields.Integer('刀库数量(把)')
|
||||||
# rotate_speed = fields.Integer('转速')
|
rotate_speed = fields.Integer('转速')
|
||||||
# number_of_axles = fields.Selection(
|
number_of_axles = fields.Selection(
|
||||||
# [("三轴", "三轴"), ("四轴", "四轴"), ("五轴", "五轴")],
|
[("三轴", "三轴"), ("四轴", "四轴"), ("五轴", "五轴")],
|
||||||
# default="", string="轴数")
|
default="", string="轴数")
|
||||||
# # 加工进程
|
# 加工进程
|
||||||
# x_axis = fields.Integer('X轴')
|
x_axis = fields.Integer('X轴')
|
||||||
# y_axis = fields.Integer('Y轴')
|
y_axis = fields.Integer('Y轴')
|
||||||
# z_axis = fields.Integer('Z轴')
|
z_axis = fields.Integer('Z轴')
|
||||||
# b_axis = fields.Integer('B轴')
|
b_axis = fields.Integer('B轴')
|
||||||
# c_axis = fields.Integer('C轴')
|
c_axis = fields.Integer('C轴')
|
||||||
# remark = fields.Char('备注')
|
remark = fields.Char('备注')
|
||||||
# is_binding = fields.Boolean('是否绑定机床', default=False)
|
is_binding = fields.Boolean('是否绑定机床', default=False)
|
||||||
# precision = fields.Float('加工精度')
|
precision = fields.Float('加工精度')
|
||||||
# control_system_id = fields.Many2one('sf.machine.control_system',
|
control_system_id = fields.Many2one('sf.machine.control_system',
|
||||||
# string="控制系统")
|
string="控制系统")
|
||||||
# # 多个机床型号对应一个机床
|
# 多个机床型号对应一个机床
|
||||||
# type_id = fields.Many2one('sf.machine_tool.type', '型号')
|
type_id = fields.Many2one('sf.machine_tool.type', '型号')
|
||||||
# brand_id = fields.Many2one('sf.machine.brand', string='品牌')
|
brand_id = fields.Many2one('sf.machine.brand', string='品牌')
|
||||||
# state = fields.Selection(
|
state = fields.Selection(
|
||||||
# [("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
|
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
|
||||||
# default='正常', string="机床状态")
|
default='正常', string="机床状态")
|
||||||
# # 0606新增字段
|
# 0606新增字段
|
||||||
# machine_tool_picture = fields.Binary('图片')
|
machine_tool_picture = fields.Binary('图片')
|
||||||
# heightened_way = fields.Selection([
|
heightened_way = fields.Selection([
|
||||||
# ('sifudianji', '伺服电机驱动'),
|
('sifudianji', '伺服电机驱动'),
|
||||||
# ('youyagang', '油压缸驱动'),
|
('youyagang', '油压缸驱动'),
|
||||||
# ('chilunjia', '齿轮架驱动')
|
('chilunjia', '齿轮架驱动')
|
||||||
# ], string="主轴加高方式", default='sifudianji')
|
], string="主轴加高方式", default='sifudianji')
|
||||||
# workpiece_load = fields.Char('工件负载')
|
workpiece_load = fields.Char('工件负载')
|
||||||
# lead_screw = fields.Char('丝杆')
|
lead_screw = fields.Char('丝杆')
|
||||||
# workbench_L = fields.Char('工作台长度(mm)')
|
workbench_L = fields.Char('工作台长度(mm)')
|
||||||
# workbench_W = fields.Char('工作台宽度(mm)')
|
workbench_W = fields.Char('工作台宽度(mm)')
|
||||||
# guide_rail = fields.Char('导轨')
|
guide_rail = fields.Char('导轨')
|
||||||
# machine_tool_L = fields.Char('机床长度(mm)')
|
machine_tool_L = fields.Char('机床长度(mm)')
|
||||||
# machine_tool_W = fields.Char('机床宽度(mm)')
|
machine_tool_W = fields.Char('机床宽度(mm)')
|
||||||
# machine_tool_H = fields.Char('机床高度(mm)')
|
machine_tool_H = fields.Char('机床高度(mm)')
|
||||||
# feed_speed = fields.Char('进给速度(mm/min)')
|
feed_speed = fields.Char('进给速度(mm/min)')
|
||||||
# tool_speed = fields.Char('刀具速度')
|
tool_speed = fields.Char('刀具速度')
|
||||||
# distance = fields.Char('主轴端面至工作台面距离(mm)')
|
distance = fields.Char('主轴端面至工作台面距离(mm)')
|
||||||
# taper = fields.Char('主轴锥度(°)')
|
taper = fields.Char('主轴锥度(°)')
|
||||||
# torque = fields.Char('主轴点击扭矩(n/m)')
|
torque = fields.Char('主轴点击扭矩(n/m)')
|
||||||
# motor_power = fields.Char('主轴电机功率(kw)')
|
motor_power = fields.Char('主轴电机功率(kw)')
|
||||||
# tool_quality_max = fields.Char('刀具最大质量')
|
tool_quality_max = fields.Char('刀具最大质量')
|
||||||
# tool_long_max = fields.Char('刀具最大长度')
|
tool_long_max = fields.Char('刀具最大长度')
|
||||||
# tool_diameter_max = fields.Char('刀具最大刀径')
|
tool_diameter_max = fields.Char('刀具最大刀径')
|
||||||
# machine_tool_category = fields.Many2one('sf.machine_tool.category', string='机床类型')
|
machine_tool_category = fields.Many2one('sf.machine_tool.category', string='机床类型')
|
||||||
# # 一个机床对应一個加工工厂,一个加工工厂对应多个机床
|
# 一个机床对应一個加工工厂,一个加工工厂对应多个机床
|
||||||
# factory_id = fields.Many2one('res.partner', string='所属工厂',
|
factory_id = fields.Many2one('res.partner', string='所属工厂',
|
||||||
# domain="[('is_factory', '=', True)]")
|
domain="[('is_factory', '=', True)]")
|
||||||
# # 一个机床对应一个供应商,一个供应商对应多个机床
|
# 一个机床对应一个供应商,一个供应商对应多个机床
|
||||||
# supplier_id = fields.Many2one('res.partner', string='制造商',
|
supplier_id = fields.Many2one('res.partner', string='制造商',
|
||||||
# domain="[('is_vendor', '=', True)]")
|
domain="[('is_vendor', '=', True)]")
|
||||||
# registration_date = fields.Date('注册日期')
|
registration_date = fields.Date('注册日期')
|
||||||
# state_zc = fields.Selection([("已注册", "已注册"), ("未注册", "未注册")], string="注册状态", default='未注册')
|
state_zc = fields.Selection([("已注册", "已注册"), ("未注册", "未注册")], string="注册状态", default='未注册')
|
||||||
# active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
#
|
|
||||||
# @api.constrains('rotate_speed')
|
@api.constrains('rotate_speed')
|
||||||
# def _check_rotate_speed(self):
|
def _check_rotate_speed(self):
|
||||||
# if self.rotate_speed <= 0:
|
if self.rotate_speed <= 0:
|
||||||
# raise ValidationError("转速不能为0")
|
raise ValidationError("转速不能为0")
|
||||||
#
|
|
||||||
# @api.constrains('precision')
|
@api.constrains('precision')
|
||||||
# def _check_precision(self):
|
def _check_precision(self):
|
||||||
# if self.precision <= 0.00:
|
if self.precision <= 0.00:
|
||||||
# raise ValidationError("加工精度不能为0")
|
raise ValidationError("加工精度不能为0")
|
||||||
#
|
|
||||||
# @api.constrains('number_of_knife_library')
|
@api.constrains('number_of_knife_library')
|
||||||
# def _check_number_of_knife_library(self):
|
def _check_number_of_knife_library(self):
|
||||||
# if self.number_of_knife_library <= 0:
|
if self.number_of_knife_library <= 0:
|
||||||
# raise ValidationError("刀库数量不能为0")
|
raise ValidationError("刀库数量不能为0")
|
||||||
#
|
|
||||||
# @api.constrains('x_axis')
|
@api.constrains('x_axis')
|
||||||
# def _check_x_axis(self):
|
def _check_x_axis(self):
|
||||||
# if self.x_axis <= 0:
|
if self.x_axis <= 0:
|
||||||
# raise ValidationError("加工行程里x轴不能为0")
|
raise ValidationError("加工行程里x轴不能为0")
|
||||||
#
|
|
||||||
# @api.constrains('y_axis')
|
@api.constrains('y_axis')
|
||||||
# def _check_y_axis(self):
|
def _check_y_axis(self):
|
||||||
# if self.y_axis <= 0:
|
if self.y_axis <= 0:
|
||||||
# raise ValidationError("加工行程里y轴不能为0")
|
raise ValidationError("加工行程里y轴不能为0")
|
||||||
#
|
|
||||||
# @api.constrains('z_axis')
|
@api.constrains('z_axis')
|
||||||
# def _check_z_axis(self):
|
def _check_z_axis(self):
|
||||||
# if self.z_axis <= 0:
|
if self.z_axis <= 0:
|
||||||
# raise ValidationError("加工行程里z轴不能为0")
|
raise ValidationError("加工行程里z轴不能为0")
|
||||||
#
|
|
||||||
# @api.constrains('b_axis')
|
@api.constrains('b_axis')
|
||||||
# def _check_b_axis(self):
|
def _check_b_axis(self):
|
||||||
# if self.number_of_axles == '四轴':
|
if self.number_of_axles == '四轴':
|
||||||
# print(self.number_of_axles)
|
print(self.number_of_axles)
|
||||||
# if self.b_axis <= 0:
|
if self.b_axis <= 0:
|
||||||
# raise ValidationError("加工行程里b轴不能为0")
|
raise ValidationError("加工行程里b轴不能为0")
|
||||||
#
|
|
||||||
# @api.constrains('c_axis')
|
@api.constrains('c_axis')
|
||||||
# def _check_c_axis(self):
|
def _check_c_axis(self):
|
||||||
# if self.number_of_axles == '五轴':
|
if self.number_of_axles == '五轴':
|
||||||
# if self.c_axis <= 0:
|
if self.c_axis <= 0:
|
||||||
# raise ValidationError("加工行程里c轴不能为0")
|
raise ValidationError("加工行程里c轴不能为0")
|
||||||
#
|
|
||||||
# @api.onchange('type_id')
|
@api.onchange('type_id')
|
||||||
# def get_type_info(self):
|
def get_type_info(self):
|
||||||
# for item in self:
|
for item in self:
|
||||||
# item.knife_type = item.type_id.knife_type
|
item.knife_type = item.type_id.knife_type
|
||||||
# item.number_of_knife_library = item.type_id.number_of_knife_library
|
item.number_of_knife_library = item.type_id.number_of_knife_library
|
||||||
# item.number_of_axles = item.type_id.number_of_axles
|
item.number_of_axles = item.type_id.number_of_axles
|
||||||
# item.rotate_speed = item.type_id.rotate_speed
|
item.rotate_speed = item.type_id.rotate_speed
|
||||||
# item.precision = item.type_id.precision
|
item.precision = item.type_id.precision
|
||||||
# item.control_system_id = item.type_id.control_system_id
|
item.control_system_id = item.type_id.control_system_id
|
||||||
# item.x_axis = item.type_id.x_axis
|
item.x_axis = item.type_id.x_axis
|
||||||
# item.y_axis = item.type_id.y_axis
|
item.y_axis = item.type_id.y_axis
|
||||||
# item.z_axis = item.type_id.z_axis
|
item.z_axis = item.type_id.z_axis
|
||||||
# item.b_axis = item.type_id.b_axis
|
item.b_axis = item.type_id.b_axis
|
||||||
# item.c_axis = item.type_id.c_axis
|
item.c_axis = item.type_id.c_axis
|
||||||
# item.machine_tool_picture = item.type_id.machine_tool_picture
|
item.machine_tool_picture = item.type_id.machine_tool_picture
|
||||||
# item.heightened_way = item.type_id.heightened_way
|
item.heightened_way = item.type_id.heightened_way
|
||||||
# item.workpiece_load = item.type_id.workpiece_load
|
item.workpiece_load = item.type_id.workpiece_load
|
||||||
# item.lead_screw = item.type_id.lead_screw
|
item.lead_screw = item.type_id.lead_screw
|
||||||
# item.workbench_L = item.type_id.workbench_L
|
item.workbench_L = item.type_id.workbench_L
|
||||||
# item.workbench_W = item.type_id.workbench_W
|
item.workbench_W = item.type_id.workbench_W
|
||||||
# item.guide_rail = item.type_id.guide_rail
|
item.guide_rail = item.type_id.guide_rail
|
||||||
# item.machine_tool_L = item.type_id.machine_tool_L
|
item.machine_tool_L = item.type_id.machine_tool_L
|
||||||
# item.machine_tool_W = item.type_id.machine_tool_W
|
item.machine_tool_W = item.type_id.machine_tool_W
|
||||||
# item.machine_tool_H = item.type_id.machine_tool_H
|
item.machine_tool_H = item.type_id.machine_tool_H
|
||||||
# item.feed_speed = item.type_id.feed_speed
|
item.feed_speed = item.type_id.feed_speed
|
||||||
# item.tool_speed = item.type_id.tool_speed
|
item.tool_speed = item.type_id.tool_speed
|
||||||
# item.distance = item.type_id.distance
|
item.distance = item.type_id.distance
|
||||||
# item.taper = item.type_id.taper
|
item.taper = item.type_id.taper
|
||||||
# item.torque = item.type_id.torque
|
item.torque = item.type_id.torque
|
||||||
# item.motor_power = item.type_id.motor_power
|
item.motor_power = item.type_id.motor_power
|
||||||
# item.tool_quality_max = item.type_id.tool_quality_max
|
item.tool_quality_max = item.type_id.tool_quality_max
|
||||||
# item.tool_long_max = item.type_id.tool_long_max
|
item.tool_long_max = item.type_id.tool_long_max
|
||||||
# item.tool_diameter_max = item.type_id.tool_diameter_max
|
item.tool_diameter_max = item.type_id.tool_diameter_max
|
||||||
# item.machine_tool_category = item.type_id.machine_tool_category.id
|
item.machine_tool_category = item.type_id.machine_tool_category.id
|
||||||
#
|
|
||||||
# # 注册同步机床
|
# 注册同步机床
|
||||||
# def enroll_machine_tool(self):
|
def enroll_machine_tool(self):
|
||||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
# token = sf_sync_config['token']
|
token = sf_sync_config['token']
|
||||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
# strurl = sf_sync_config['sf_url'] + self.crea_url
|
strurl = sf_sync_config['sf_url'] + self.crea_url
|
||||||
# objs_all = self.env['sf.machine_tool'].search([('MTcode', '=', self.MTcode)])
|
objs_all = self.env['sf.machine_tool'].search([('MTcode', '=', self.MTcode)])
|
||||||
# machine_tool_list = []
|
machine_tool_list = []
|
||||||
# if objs_all:
|
if objs_all:
|
||||||
# for item in objs_all:
|
for item in objs_all:
|
||||||
# val = {
|
val = {
|
||||||
# 'MTcode': item.MTcode,
|
'MTcode': item.MTcode,
|
||||||
# 'factory_token': token,
|
'factory_token': token,
|
||||||
# 'id': item.id,
|
'id': item.id,
|
||||||
# 'name': item.name,
|
'name': item.name,
|
||||||
# 'code': item.code,
|
'code': item.code,
|
||||||
# 'precision': item.precision,
|
'precision': item.precision,
|
||||||
# 'knife_type': item.knife_type,
|
'knife_type': item.knife_type,
|
||||||
# 'number_of_knife_library': item.number_of_knife_library,
|
'number_of_knife_library': item.number_of_knife_library,
|
||||||
# 'rotate_speed': item.rotate_speed,
|
'rotate_speed': item.rotate_speed,
|
||||||
# 'number_of_axles': item.number_of_axles,
|
'number_of_axles': item.number_of_axles,
|
||||||
# 'control_system_id': self.env['sf.machine.control_system'].search(
|
'control_system_id': self.env['sf.machine.control_system'].search(
|
||||||
# [('id', '=', item.control_system_id.id)]).code,
|
[('id', '=', item.control_system_id.id)]).code,
|
||||||
# 'type_id': self.env['sf.machine_tool.type'].search([('id', '=', item.type_id.id)]).code,
|
'type_id': self.env['sf.machine_tool.type'].search([('id', '=', item.type_id.id)]).code,
|
||||||
# 'brand_id': self.env['sf.machine.brand'].search([('id', '=', item.brand_id.id)]).code,
|
'brand_id': self.env['sf.machine.brand'].search([('id', '=', item.brand_id.id)]).code,
|
||||||
# 'supplier_id': item.supplier_id.id,
|
'supplier_id': item.supplier_id.id,
|
||||||
# 'x_axis': item.x_axis,
|
'x_axis': item.x_axis,
|
||||||
# 'y_axis': item.y_axis,
|
'y_axis': item.y_axis,
|
||||||
# 'z_axis': item.z_axis,
|
'z_axis': item.z_axis,
|
||||||
# 'b_axis': item.b_axis,
|
'b_axis': item.b_axis,
|
||||||
# 'c_axis': item.c_axis,
|
'c_axis': item.c_axis,
|
||||||
# 'state': item.state,
|
'state': item.state,
|
||||||
# 'active': item.active,
|
'active': item.active,
|
||||||
#
|
|
||||||
# }
|
}
|
||||||
# machine_tool_list.append(val)
|
machine_tool_list.append(val)
|
||||||
# # kw = machine_tool_list
|
# kw = machine_tool_list
|
||||||
# kw = json.dumps(machine_tool_list, ensure_ascii=False)
|
kw = json.dumps(machine_tool_list, ensure_ascii=False)
|
||||||
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
# ret = r.json()
|
ret = r.json()
|
||||||
# self.code = ret['message']
|
self.code = ret['message']
|
||||||
# self.state_zc = "已注册"
|
self.state_zc = "已注册"
|
||||||
# if r == 200:
|
if r == 200:
|
||||||
# return "机床注册成功"
|
return "机床注册成功"
|
||||||
# else:
|
else:
|
||||||
# raise ValidationError("没有注册机床信息")
|
raise ValidationError("没有注册机床信息")
|
||||||
|
|
||||||
|
|
||||||
class MachineToolType(models.Model):
|
class MachineToolType(models.Model):
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
# 重写工单开始按钮方法
|
# 重写工单开始按钮方法
|
||||||
def button_start(self):
|
def button_start(self):
|
||||||
if self.routing_type == '装夹':
|
if self.routing_type == '装夹' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name:
|
||||||
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
|
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
|
||||||
# 外协出库单,从“正在等待”变为“就绪”状态
|
# 外协出库单,从“正在等待”变为“就绪”状态
|
||||||
if self.is_subcontract is True:
|
if self.is_subcontract is True:
|
||||||
|
|||||||
Reference in New Issue
Block a user