1、产品模型的产品类别字段添加必填标记;2、制造订单的工单添加RFID码(已解除)字段,当工单解除装夹时保存RFID码到RFID码(已解除)字段进行展示;3、功能刀具列表的当前位置字段改为Selection类型,并优化自动计算功能刀具当前位置的方法;4、获取机床刀库信息时,对新装刀的功能刀具进行库存位移刀制造前(机内刀库);5、优化功能刀具组装时扫码自动录入RFID码功能;

This commit is contained in:
yuxianghui
2024-03-04 17:10:41 +08:00
parent 25e65b39bc
commit 9d2bad977c
6 changed files with 64 additions and 40 deletions

View File

@@ -7,7 +7,7 @@
<field name="inherit_id" ref="sf_sale.view_product_template_form_inherit_sf"/>
<field name="arch" type="xml">
<field name="invoice_policy" position="after">
<field name='categ_id' attrs="{'readonly': [('id', '!=', False)]}"/>
<field name='categ_id' class="custom_required" attrs="{'readonly': [('id', '!=', False)]}"/>
<field name='is_bfm' invisible="1"/>
<field name='categ_type' invisible="1"/>
<field name="upload_model_file"

View File

@@ -134,6 +134,7 @@ class ResMrpWorkOrder(models.Model):
workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送')
is_delivery = fields.Boolean('是否配送完成', default=False)
rfid_code = fields.Char('RFID码')
rfid_code_old = fields.Char('RFID码(已解除)')
production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id',
string='生产线', store=True)
production_line_state = fields.Selection(related='production_id.production_line_state',
@@ -622,6 +623,7 @@ class ResMrpWorkOrder(models.Model):
is_production_id = False
if is_production_id == True and self.name == '解除装夹':
for workorder in self.production_id.workorder_ids:
workorder.rfid_code_old = workorder.rfid_code
workorder.rfid_code = None
for move_raw_id in self.production_id.move_raw_ids:
move_raw_id.quantity_done = move_raw_id.product_uom_qty

View File

@@ -183,7 +183,9 @@
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="functional_fixture_type_id"
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="rfid_code" force_save="1" readonly="1" class="customRFID"/>
<field name="rfid_code" force_save="1" readonly="1" class="customRFID"
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
<script src="/sf_manufacturing/static/src/js/customRFID.js"></script>
</group>
<!-- <group>-->

View File

@@ -39,24 +39,29 @@ class FunctionalCuttingToolEntity(models.Model):
functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')],
string='状态', store=True, default='正常')
current_location_id = fields.Many2one('stock.location', string='当前位置', readonly=True)
current_location = fields.Char('位置', compute='_compute_current_location_id')
current_location = fields.Selection(
[('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')],
string='位置', compute='_compute_current_location_id', store=True)
image = fields.Binary('图片', readonly=True)
active = fields.Boolean(string='已归档', default=True)
@api.depends('barcode_id')
@api.depends('barcode_id.quant_ids')
def _compute_current_location_id(self):
for record in self:
if record.barcode_id.quant_ids:
for quant_id in record.barcode_id.quant_ids:
if quant_id.inventory_quantity_auto_apply > 0:
record.sudo().current_location_id = quant_id.location_id
record.sudo().current_location = quant_id.location_id.name
record.current_location_id = quant_id.location_id
if quant_id.location_id.name == '制造前':
record.current_location = '机内刀库'
else:
record.current_location = quant_id.location_id.name
if record.current_location_id:
record.sudo().get_location_num()
else:
record.sudo().current_location_id = False
record.sudo().current_location = False
record.current_location_id = False
record.current_location = False
def get_location_num(self):
"""
@@ -64,15 +69,15 @@ class FunctionalCuttingToolEntity(models.Model):
"""
for obj in self:
if obj.current_location_id:
if obj.current_location_id.name in ['刀具房']:
if obj.current_location in ['刀具房']:
obj.tool_room_num = 1
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
elif "线边刀库" in obj.current_location_id.name:
elif "线边刀库" in obj.current_location:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 1
obj.machine_knife_library_num = 0
elif "机内刀库" in obj.current_location_id.name:
elif "机内刀库" in obj.current_location:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 1
@@ -180,33 +185,45 @@ class FunctionalCuttingToolEntity(models.Model):
('coarse_middle_thin', '=', self.coarse_middle_thin)]
return result
# ==========刀具组接口==========
# def _register_functional_tool_groups(self, obj):
# create_url = '/AutoDeviceApi/ToolGroup'
# sf_sync_config = self.env['res.config.settings'].get_values()
# token = sf_sync_config['token']
# sf_secret_key = sf_sync_config['sf_secret_key']
# headers = Common.get_headers(obj, token, sf_secret_key)
# strurl = sf_sync_config['sf_url'] + create_url
# val = {
# 'ToolName': obj.name,
# 'GroupName': obj.tool_groups_id.name,
# 'ToolId': obj.code
# }
# kw = json.dumps(val, ensure_ascii=False)
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
# ret = r.json()
# if r == 200:
# return "刀具组发送成功"
# else:
# raise ValidationError("刀具组发送失败")
def tool_inventory_displacement_out(self):
"""
机床当前刀库实时信息接口,功能刀具出库
"""
# 获取位置对象
location_inventory_id = self.current_location_id
stock_location_id = self.env['stock.location'].search([('name', '=', '制造前')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
self.barcode_id.create_stock_quant(location_inventory_id, stock_location_id,
self.functional_tool_name_id.id, '机床装刀')
# @api.model_create_multi
# def create(self, vals):
# obj = super(FunctionalCuttingToolEntity, self).create(vals)
# # 调用刀具组接口
# self._register_functional_tool_groups(obj)
# return obj
# ==========刀具组接口==========
# def _register_functional_tool_groups(self, obj):
# create_url = '/AutoDeviceApi/ToolGroup'
# sf_sync_config = self.env['res.config.settings'].get_values()
# token = sf_sync_config['token']
# sf_secret_key = sf_sync_config['sf_secret_key']
# headers = Common.get_headers(obj, token, sf_secret_key)
# strurl = sf_sync_config['sf_url'] + create_url
# val = {
# 'ToolName': obj.name,
# 'GroupName': obj.tool_groups_id.name,
# 'ToolId': obj.code
# }
# kw = json.dumps(val, ensure_ascii=False)
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
# ret = r.json()
# if r == 200:
# return "刀具组发送成功"
# else:
# raise ValidationError("刀具组发送失败")
# @api.model_create_multi
# def create(self, vals):
# obj = super(FunctionalCuttingToolEntity, self).create(vals)
# # 调用刀具组接口
# self._register_functional_tool_groups(obj)
# return obj
class FunctionalToolWarning(models.Model):

View File

@@ -79,6 +79,9 @@ class SfMaintenanceEquipment(models.Model):
'functional_tool_name_id': functional_tool_id.id,
'tool_install_time': time
})
if functional_tool_id.current_location_id.name != '制造前':
# 对功能刀具进行出库到生产线
functional_tool_id.tool_inventory_displacement_out()
functional_tool_id.write({
'max_lifetime_value': data['MaxLife'],
'used_value': data['UseLife'],

View File

@@ -152,8 +152,8 @@
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="current_location_id"/>
<field name="current_location" invisible="1"/>
<field name="current_location_id" invisible="1"/>
<field name="current_location"/>
</group>
<group>
<field name="tool_loading_length"/>
@@ -203,7 +203,7 @@
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
<searchpanel>
<field name="sf_cutting_tool_type_id" icon="fa-building" enable_counters="1"/>
<field name="current_location_id" icon="fa-building" enable_counters="1"/>
<field name="current_location" icon="fa-building" enable_counters="1"/>
<field name="functional_tool_status" icon="fa-building" enable_counters="1"/>
</searchpanel>
</search>