diff --git a/sf_machine_connect/views/WorkCenterBarcodes.xml b/sf_machine_connect/views/WorkCenterBarcodes.xml
index d44c8a82..aea9731b 100644
--- a/sf_machine_connect/views/WorkCenterBarcodes.xml
+++ b/sf_machine_connect/views/WorkCenterBarcodes.xml
@@ -25,6 +25,9 @@
+
+
+
\ No newline at end of file
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 002c83aa..ba7bc2c5 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -21,6 +21,8 @@ class ResMrpWorkOrder(models.Model):
_inherit = 'mrp.workorder'
_order = 'sequence asc,create_date desc'
+ product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name')
+
product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True,
string="坯料长度(mm)")
product_tmpl_id_width = fields.Float(related='production_id.product_tmpl_id.width', readonly=True, store=True,
@@ -849,12 +851,12 @@ class ResMrpWorkOrder(models.Model):
limit=1, order='id asc')
if not cnc_workorder.cnc_ids:
raise UserError(_('该制造订单还未下发CNC程序,请稍后再试'))
- else:
- for item in cnc_workorder.cnc_ids:
- functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search(
- [('tool_name_id.name', '=', item.cutting_tool_name)])
- if not functional_cutting_tool:
- raise UserError(_('该制造订单的CNC程序为%s没有对应的功能刀具' % item.cutting_tool_name))
+ # else:
+ # for item in cnc_workorder.cnc_ids:
+ # functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search(
+ # [('tool_name_id.name', '=', item.cutting_tool_name)])
+ # if not functional_cutting_tool:
+ # raise UserError(_('该制造订单的CNC程序为%s没有对应的功能刀具' % item.cutting_tool_name))
if self.routing_type == '解除装夹':
'''
记录开始时间
@@ -1009,10 +1011,15 @@ class ResMrpWorkOrder(models.Model):
for workorder in record.production_id.workorder_ids:
if workorder.state != 'done':
is_production_id = False
- if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺']:
+ if record.routing_type == '解除装夹':
for workorder in record.production_id.workorder_ids:
- workorder.rfid_code_old = workorder.rfid_code
- workorder.rfid_code = None
+ if workorder.processing_panel == record.processing_panel:
+ rfid_code = workorder.rfid_code
+ workorder.write({'rfid_code_old': rfid_code,
+ 'rfid_code': ''})
+ workorder.rfid_code_old = rfid_code
+ workorder.rfid_code = ''
+ if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺']:
for move_raw_id in record.production_id.move_raw_ids:
move_raw_id.quantity_done = move_raw_id.product_uom_qty
record.process_state = '已完工'
@@ -1254,11 +1261,12 @@ class SfWorkOrderBarcodes(models.Model):
workorder.write(val)
self.write(val)
workorder_rfid = self.env['mrp.workorder'].search(
- [('production_id', '=', workorder.production_id.id)])
+ [('production_id', '=', workorder.production_id.id),
+ ('processing_panel', '=', workorder.processing_panel)])
if workorder_rfid:
for item in workorder_rfid:
item.write({'rfid_code': barcode})
- logging.info("Rfid绑定成功!!!")
+ logging.info("Rfid[%s]绑定成功!!!" % barcode)
else:
raise UserError('该Rfid【%s】绑定的是【%s】, 不是托盘!!!' % (barcode, lot.product_id.name))
self.process_state = '待检测'
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index 95d877b3..49f00140 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -701,13 +701,36 @@ class ReStockMove(models.Model):
),
}
+ def put_move_line(self):
+ """
+ 确认订单时,自动分配序列号
+ """
+ if self.product_id.tracking == "serial":
+ if self.product_id.categ_id.name == '刀具':
+ self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
+ else:
+ self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
+ self._generate_serial_numbers()
+ for item in self.move_line_nosuggest_ids:
+ if item.lot_name:
+ lot_name = item.lot_name
+ if item.product_id.categ_id.name == '坯料':
+ lot_name = lot_name.split('[', 1)[0]
+ item.lot_qr_code = self.compute_lot_qr_code(lot_name)
+
def _put_tool_lot(self, company, product, origin):
if product.tracking == "lot" and self.product_id.categ_id.name == '刀具':
if not self.move_line_nosuggest_ids:
- lot_names = self.env['stock.lot'].generate_lot_names(
- '%s-%s-%s' % ('%s-T-DJWL-%s' % (
- product.cutting_tool_model_id.code.split('-')[0], product.cutting_tool_material_id.code),
- datetime.now().strftime("%Y%m%d"), origin), 1)
+ lot_code = '%s-%s-%s' % ('%s-T-DJWL-%s' % (
+ product.cutting_tool_model_id.code.split('-')[0], product.cutting_tool_material_id.code),
+ datetime.now().strftime("%Y%m%d"), origin)
+ move_line_ids = self.env['stock.move.line'].sudo().search([('lot_name', 'like', lot_code)], limit=1,
+ order='id desc')
+ if not move_line_ids:
+ lot_code = '%s-001' % lot_code
+ else:
+ lot_code = '%s-%03d' % (lot_code, int(move_line_ids.lot_name[-3:]) + 1)
+ lot_names = self.env['stock.lot'].generate_lot_names(lot_code, 1)
move_lines_commands = self._generate_serial_move_line_commands_tool_lot(lot_names)
self.write({'move_line_nosuggest_ids': move_lines_commands})
for item in self.move_line_nosuggest_ids:
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index 11219363..b56405b9 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -19,6 +19,7 @@
+
@@ -214,7 +215,7 @@
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
-
diff --git a/sf_manufacturing/views/stock_lot_views.xml b/sf_manufacturing/views/stock_lot_views.xml
index 2aed0d2c..4b6cce72 100644
--- a/sf_manufacturing/views/stock_lot_views.xml
+++ b/sf_manufacturing/views/stock_lot_views.xml
@@ -41,8 +41,8 @@
stock.lot
-
-
+
+
diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py
index 9486f73c..6508132d 100644
--- a/sf_sale/models/sale_order.py
+++ b/sf_sale/models/sale_order.py
@@ -215,6 +215,17 @@ class RePurchaseOrder(models.Model):
if len(product_id) != len(line):
raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name)
+ def button_confirm(self):
+ result = super(RePurchaseOrder, self).button_confirm()
+ for item in self:
+ # 确认订单时,自动分配序列号
+ if item.picking_ids:
+ for picking_id in item.picking_ids:
+ if picking_id.move_ids:
+ for move_id in picking_id.move_ids:
+ move_id.put_move_line()
+ return result
+
class ResPartnerToSale(models.Model):
_inherit = 'res.partner'
diff --git a/sf_tool_management/controllers/controllers.py b/sf_tool_management/controllers/controllers.py
index b6adb6b7..4b0909dc 100644
--- a/sf_tool_management/controllers/controllers.py
+++ b/sf_tool_management/controllers/controllers.py
@@ -121,7 +121,7 @@ class Manufacturing_Connect(http.Controller):
{'Succeed': False, 'ErrorCode': 201, 'code': data_list[0], 'Error': '没有找到正在组装的组装单!'})
tool_assembly.write({
'after_assembly_tool_loading_length': float(data_list[1] or "0"), # 高度(总长度)
- 'after_assembly_functional_tool_diameter': float(data_list[2] or "0"), # 直径
+ 'after_assembly_functional_tool_diameter': float(data_list[2] or "0") * 2, # 直径
'after_assembly_knife_tip_r_angle': float(data_list[3] or "0") # R角
})
except Exception as e:
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index bbcf9927..8daf1488 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -926,7 +926,7 @@ class FunctionalToolDismantle(models.Model):
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
# =================刀柄是否[报废]拆解=======
- location_dest_scrap = self.env['stock.location'].search([('name', '=', 'Scrap')])
+ location_dest_scrap_ids = self.env['stock.location'].search([('name', 'in', ('Scrap', '报废'))])
if self.handle_rfid:
lot = self.env['stock.lot'].sudo().search([('rfid', '=', self.handle_rfid)])
if not lot:
@@ -934,30 +934,33 @@ class FunctionalToolDismantle(models.Model):
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
if self.scrap_boolean:
# 刀柄报废 入库到Scrap
- lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, code,
+ lot.create_stock_quant(location, location_dest_scrap_ids[-1], functional_tool_assembly.id, code,
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
+ lot.tool_material_status = '报废'
else:
# 刀柄不报废 入库到刀具房
lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, code,
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
+ lot.tool_material_status = '可用'
+
# ==============功能刀具[报废]拆解================
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
# 除刀柄外物料报废 入库到Scrap
if self.integral_product_id:
self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
- location_dest_scrap, code)
+ location_dest_scrap_ids[-1], code)
elif self.blade_product_id:
- self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap,
- code)
+ self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location,
+ location_dest_scrap_ids[-1], code)
if self.bar_product_id:
- self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap,
- code)
+ self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location,
+ location_dest_scrap_ids[-1], code)
elif self.pad_product_id:
- self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap,
- code)
+ self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location,
+ location_dest_scrap_ids[-1], code)
if self.chuck_product_id:
- self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap,
- code)
+ self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location,
+ location_dest_scrap_ids[-1], code)
# ===========功能刀具[磨削]拆解==============
# elif self.dismantle_cause in ['刀具需磨削']:
# location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py
index 32c153d7..d308f1f1 100644
--- a/sf_tool_management/models/maintenance_equipment.py
+++ b/sf_tool_management/models/maintenance_equipment.py
@@ -142,9 +142,6 @@ class StockLot(models.Model):
record.tool_material_status = '报废'
else:
record.tool_material_status = '未入库'
- if record.fixture_material_search_id:
- # 注册夹具物料状态到cloud平台
- record.enroll_fixture_material_stock()
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 6aec47e9..af772016 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -854,10 +854,10 @@ class ProductProduct(models.Model):
'company_id': self.env.company.id
})
# 获取位置对象
- location_inventory_id = self.env['stock.location'].search([('name', '=', 'Production')])
+ location_inventory_ids = self.env['stock.location'].search([('name', 'in', ('Production', '生产'))])
stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
- stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id,
+ stock_lot.create_stock_quant(location_inventory_ids[-1], stock_location_id, functional_tool_assembly.id,
obj.assembly_order_code, obj, obj.after_tool_groups_id)
return stock_lot
diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py
index 62a7836b..34fa57fe 100644
--- a/sf_warehouse/models/model.py
+++ b/sf_warehouse/models/model.py
@@ -1143,7 +1143,10 @@ class CustomStockMove(models.Model):
move_lines = self.move_line_ids # 获取当前 stock.move 对应的所有 stock.move.line 记录
for line in move_lines:
if line.lot_name: # 确保 lot_name 存在
- qr_data = self.compute_lot_qr_code(line.lot_name)
+ lot_name = line.lot_name
+ if line.product_id.categ_id.name == '坯料':
+ lot_name = lot_name.split('[', 1)[0]
+ qr_data = self.compute_lot_qr_code(lot_name)
# 假设 stock.move.line 模型中有一个字段叫做 lot_qr_code 用于存储二维码数据
line.lot_qr_code = qr_data
return result