diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 3b2649a2..322cf096 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -300,29 +300,32 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
智能工厂组装单处扫码绑定刀具物料')
"""
for record in self:
- records = record.env['stock.lot'].search([('name', '=', barcode)])
- if not records:
- raise ValidationError('扫描的条形码数据不存在,请重新扫描!')
- for record_stock_lot in records:
- if record_stock_lot.quant_ids[-1].location_id.name == '刀具组装位置':
- raise ValidationError('该刀具物料已使用,请重新选择!!!')
- elif record_stock_lot.quant_ids[-1].location_id.name not in '刀具房':
- raise ValidationError('该刀具物料未入库,请重新选择!!!')
- tool_material_name = record_stock_lot.product_id.cutting_tool_material_id.name
- if tool_material_name == '整体式刀具':
- record.integral_code_id = record_stock_lot.id
- elif tool_material_name == '刀片':
- record.blade_code_id = record_stock_lot.id
- elif tool_material_name == '刀杆':
- record.bar_code_id = record_stock_lot.id
- elif tool_material_name == '刀盘':
- record.pad_code_id = record_stock_lot.id
- elif tool_material_name == '刀柄':
- record.handle_code_id = record_stock_lot.id
- elif tool_material_name == '夹头':
- record.chuck_code_id = record_stock_lot.id
- else:
- raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
+ if 'DJWL' in barcode:
+ records = record.env['stock.lot'].search([('name', '=', barcode)])
+ if not records:
+ raise ValidationError('扫描的条形码数据不存在,请重新扫描!')
+ for record_stock_lot in records:
+ if record_stock_lot.quant_ids[-1].location_id.name == '刀具组装位置':
+ raise ValidationError('该刀具物料已使用,请重新选择!!!')
+ elif record_stock_lot.quant_ids[-1].location_id.name not in '刀具房':
+ raise ValidationError('该刀具物料未入库,请重新选择!!!')
+ tool_material_name = record_stock_lot.product_id.cutting_tool_material_id.name
+ if tool_material_name == '整体式刀具':
+ record.integral_code_id = record_stock_lot.id
+ elif tool_material_name == '刀片':
+ record.blade_code_id = record_stock_lot.id
+ elif tool_material_name == '刀杆':
+ record.bar_code_id = record_stock_lot.id
+ elif tool_material_name == '刀盘':
+ record.pad_code_id = record_stock_lot.id
+ elif tool_material_name == '刀柄':
+ record.handle_code_id = record_stock_lot.id
+ elif tool_material_name == '夹头':
+ record.chuck_code_id = record_stock_lot.id
+ else:
+ raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
+ else:
+ record.rfid = barcode
# 组装功能刀具参数信息
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
@@ -676,7 +679,8 @@ class ProductProduct(models.Model):
location_inventory_id = self.env['stock.location'].search([('name', '=', '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_id, stock_location_id, functional_tool_assembly.id,
+ '功能刀具组装')
return stock_lot
@@ -710,20 +714,20 @@ class ProductProduct(models.Model):
location_inventory_id = tool_material.quant_ids.location_id[-1]
stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
- tool_material.create_stock_quant(location_inventory_id, stock_location_id, None)
+ tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装')
class StockLot(models.Model):
_inherit = 'stock.lot'
- def create_stock_quant(self, location_inventory_id, stock_location_id, functional_tool_assembly_id):
+ def create_stock_quant(self, location_inventory_id, stock_location_id, functional_tool_assembly_id, name):
"""
对功能刀具组装过程的功能刀具和刀具物料进行库存移动,以及创建移动历史
"""
# 创建库存移动记录
- stock_move_id = self.env['stock.move'].create({
- 'name': '功能刀具组装',
+ stock_move_id = self.env['stock.move'].sudo().create({
+ 'name': name,
'product_id': self.product_id.id,
'location_id': location_inventory_id.id,
'location_dest_id': stock_location_id.id,
@@ -732,7 +736,7 @@ class StockLot(models.Model):
})
# 创建移动历史记录
- stock_move_line_id = self.env['stock.move.line'].create({
+ stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.product_id.id,
'functional_tool_name_id': functional_tool_assembly_id,
'lot_id': self.id,
diff --git a/zpl_print/models/common.py b/zpl_print/models/common.py
index d45f74e0..6e4e7eca 100644
--- a/zpl_print/models/common.py
+++ b/zpl_print/models/common.py
@@ -8,7 +8,7 @@ class Common(models.Model):
_description = u'公用类'
def print_zpl(self, zpl_str):
- WinDll_path = "D://桌面//pythonZPL//tsc_python_sdk_example//TSC_Python_SDK_Example//tsc_sample//libs//TSCLIB.dll"
+ WinDll_path = "D://桌面//pythonZPL//zebra_zpl//libs//TSCLIB.dll"
try:
tsclibrary = ctypes.WinDLL(WinDll_path)
tsclibrary.openportW("USB")