diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py
index e3b737f0..f2010b4a 100644
--- a/sf_base/models/tool_base_new.py
+++ b/sf_base/models/tool_base_new.py
@@ -316,6 +316,7 @@ class ToolInventory(models.Model):
name = fields.Char('功能刀具名称', required=True)
type = fields.Char('类型')
+ functional_cutting_tool_model_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
prefix = fields.Char('前缀')
postfix = fields.Char('后缀')
diameter = fields.Float('直径(mm)')
@@ -326,5 +327,9 @@ class ToolInventory(models.Model):
cutter_number = fields.Char('刀号')
blade_number = fields.Integer('刃数(个)')
extension = fields.Float('伸出长度(mm)')
+ work_material = fields.Selection([('钢', '钢'), ('铝', '铝')], string='加工材料')
+ life_span = fields.Float('寿命(h)')
+
+ tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组')
active = fields.Boolean('已归档', default=True)
diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml
index 25d1824f..e52a6222 100644
--- a/sf_base/views/tool_views.xml
+++ b/sf_base/views/tool_views.xml
@@ -556,19 +556,23 @@
-
-
-
+
+
+
+
+
+
-
+
+
@@ -579,7 +583,10 @@
-
+
+
+
+
diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py
index 0a44f130..7f01743c 100644
--- a/sf_mrs_connect/models/sync_common.py
+++ b/sf_mrs_connect/models/sync_common.py
@@ -52,8 +52,6 @@ class MrStaticResourceDataSync(models.Model):
logging.info("夹具型号已每日同步成功")
self.env['sf.fixture.materials.basic.parameters'].sync_fixture_materials_basic_parameters_yesterday()
logging.info("夹具型号基本参数已每日同步成功")
- self.env['sf.functional.fixture.type'].sync_fixture_materials_basic_parameters_yesterday()
- logging.info("夹具型号基本参数已每日同步成功")
self.env['sf.functional.fixture.type'].sync_functional_fixture_type_yesterday()
logging.info("功能夹具类型已每日同步成功")
self.env['sf.cutting.tool.material'].sync_cutting_tool_material_yesterday()
diff --git a/sf_sale/views/res_partner_view.xml b/sf_sale/views/res_partner_view.xml
index 4b2d55d6..cc8f49fb 100644
--- a/sf_sale/views/res_partner_view.xml
+++ b/sf_sale/views/res_partner_view.xml
@@ -26,7 +26,7 @@
+ attrs="{'readonly': [('id','!=', False)]}"/>
{'required': [('phone', '=', False)],'readonly': [('id','!=', False)]}
@@ -37,19 +37,19 @@
- {'required': [('supplier_rank','>', 0)],'readonly': [('id','!=', False)]}
+ {'readonly': [('id','!=', False)]}
- {'required': [('supplier_rank','>', 0)],'readonly': [('id','!=', False)]}
+ {'readonly': [('id','!=', False)]}
- {'required': [('supplier_rank','>', 0)],'readonly': [('id','!=', False)]}
+ {'readonly': [('id','!=', False)]}
- {'required': [('supplier_rank','>', 0)],'readonly': [('id','!=', False)]}
+ {'readonly': [('id','!=', False)]}
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 36bb310d..303c87d5 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -222,132 +222,147 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
image = fields.Binary('图片')
# 功能刀具组装信息
- # 整体式刀具型号
+ # ===============整体式刀具型号=================
+ integral_freight_barcode = fields.Char('整体式刀具货位')
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),
('tool_material_status', '=', '可用')])
+ integral_product_id = fields.Many2one('product.product', string='整体式刀具名称',
+ compute='_compute_integral_product_id', store=True)
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
- related='integral_code_id.product_id.cutting_tool_model_id')
- integral_name = fields.Char('整体式刀具名称', related='integral_code_id.product_id.name')
+ related='integral_product_id.cutting_tool_model_id')
integral_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='整体式刀具规格',
- related='integral_code_id.product_id.specification_id')
+ related='integral_product_id.specification_id')
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
- related='integral_code_id.product_id.brand_id')
+ related='integral_product_id.brand_id')
- # 刀片型号
+ @api.depends('integral_freight_barcode')
+ def _compute_integral_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
+ if location:
+ self.integral_product_id = location.product_id.id
+
+ # ===============刀片型号====================
+ blade_freight_barcode = fields.Char('刀片货位')
blade_code_id = fields.Many2one('stock.lot', '刀片序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片'),
('tool_material_status', '=', '可用')])
+ blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id',
+ store=True)
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
- related='blade_code_id.product_id.cutting_tool_model_id')
- blade_name = fields.Char('刀片名称', related='blade_code_id.product_id.name')
+ related='blade_product_id.cutting_tool_model_id')
blade_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀片规格',
- related='blade_code_id.product_id.specification_id')
- sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_code_id.product_id.brand_id')
+ related='blade_product_id.specification_id')
+ sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
- # 刀杆型号
+ @api.depends('blade_freight_barcode')
+ def _compute_blade_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
+ if location:
+ self.blade_product_id = location.product_id.id
+
+ # ====================刀杆型号==================
+ bar_freight_barcode = fields.Char('刀杆货位')
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆'),
('tool_material_status', '=', '可用')])
+ bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id',
+ store=True)
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
- related='bar_code_id.product_id.cutting_tool_model_id')
- bar_name = fields.Char('刀杆名称', related='bar_code_id.product_id.name')
+ related='bar_product_id.cutting_tool_model_id')
bar_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀杆规格',
- related='bar_code_id.product_id.specification_id')
- sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_code_id.product_id.brand_id')
+ related='bar_product_id.specification_id')
+ sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
- # 刀盘型号
+ @api.depends('bar_freight_barcode')
+ def _compute_bar_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
+ if location:
+ self.bar_product_id = location.product_id.id
+
+ # ===============刀盘型号===================
+ pad_freight_barcode = fields.Char('刀盘货位')
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘'),
('tool_material_status', '=', '可用')])
+ pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id',
+ store=True)
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
- related='pad_code_id.product_id.cutting_tool_model_id')
- pad_name = fields.Char('刀盘名称', related='pad_code_id.product_id.name')
+ related='pad_product_id.cutting_tool_model_id')
pad_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀盘规格',
- related='pad_code_id.product_id.specification_id')
- sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_code_id.product_id.brand_id')
+ related='pad_product_id.specification_id')
+ sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
- # 刀柄型号
+ @api.depends('pad_freight_barcode')
+ def _compute_pad_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
+ if location:
+ self.pad_product_id = location.product_id.id
+
+ # ================刀柄型号===============
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True,
domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄'),
('tool_material_status', '=', '可用')])
+ handle_product_id = fields.Many2one('product.product', string='刀柄名称', related='handle_code_id.product_id')
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
related='handle_code_id.product_id.cutting_tool_model_id')
- handle_name = fields.Char('刀柄名称', related='handle_code_id.product_id.name')
handle_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀柄规格',
related='handle_code_id.product_id.specification_id')
sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_code_id.product_id.brand_id')
- # 夹头型号
- chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', required=True,
+ # =================夹头型号==============
+ chuck_freight_barcode = fields.Char('夹头货位', required=True)
+ chuck_code_id = fields.Many2one('stock.lot', '夹头序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '夹头'),
('tool_material_status', '=', '可用')])
+ chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id',
+ store=True)
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
- related='chuck_code_id.product_id.cutting_tool_model_id')
- chuck_name = fields.Char('夹头名称', related='chuck_code_id.product_id.name')
+ related='chuck_product_id.cutting_tool_model_id')
chuck_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='夹头规格',
- related='chuck_code_id.product_id.specification_id')
- sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_code_id.product_id.brand_id')
+ related='chuck_product_id.specification_id')
+ sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
+
+ @api.depends('chuck_freight_barcode')
+ def _compute_chuck_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
+ if location:
+ self.chuck_product_id = location.product_id.id
+
+ # ========================================
def on_barcode_scanned(self, barcode):
"""
- 智能工厂组装单处扫码绑定刀具物料')
+ 智能工厂组装单处扫码绑定刀具物料
"""
for record in self:
- if 'DJWL' in barcode:
- lot_ids = record.env['stock.lot'].sudo().search([('name', '=', barcode)])
- if not lot_ids:
- raise ValidationError('扫描的条形码数据不存在,请重新扫描!')
- for lot_id in lot_ids:
- if lot_id.quant_ids[-1].location_id.name == '刀具组装位置':
- raise ValidationError('该刀具物料已使用,请重新扫描!!!')
- elif lot_id.quant_ids[-1].location_id.name not in '刀具房':
- raise ValidationError('该刀具物料未入库,请重新扫描!!!')
- tool_material_name = lot_id.product_id.cutting_tool_material_id.name
- if tool_material_name == '整体式刀具':
- record.integral_code_id = lot_id.id
- elif tool_material_name == '刀片':
- record.blade_code_id = lot_id.id
- elif tool_material_name == '刀杆':
- record.bar_code_id = lot_id.id
- elif tool_material_name == '刀盘':
- record.pad_code_id = lot_id.id
- elif tool_material_name == '刀柄':
- record.handle_code_id = lot_id.id
- record.chuck_code_id = record.get_chuck_code_id(lot_id).id or False
- elif tool_material_name == '夹头':
- record.chuck_code_id = lot_id.id
- else:
- raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
- else:
- lot_ids = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)])
- if not lot_ids:
- raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
+ lot_ids = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)])
+ if lot_ids:
for lot_id in lot_ids:
if lot_id.quant_ids[-1].location_id.name in '刀具房':
record.handle_code_id = lot_id.id
- record.chuck_code_id = record.get_chuck_code_id(lot_id).id or False
elif lot_id.quant_ids[-1].location_id.name == '刀具组装位置':
raise ValidationError('该刀柄已使用,请重新扫描!!!')
else:
raise ValidationError('该刀柄未入库,请重新扫描!!!')
-
- def get_chuck_code_id(self, lot_id):
- # 适用夹头型号
- cutting_tool_chuck_id = lot_id.product_id.cutting_tool_chuck_id
- # 适用夹头尺寸
- fit_chuck_size = lot_id.product_id.cutting_tool_fit_chuck_size
- # 适用夹头产品
- chuck_product_id = self.env['product.product'].sudo().search(
- [('cutting_tool_model_id', '=', cutting_tool_chuck_id.id),
- ('cutting_tool_er_size_model', '=', fit_chuck_size)])
- # 适用夹头产品序列号
- chuck_product_lot_ids = self.env['stock.lot'].sudo().search(
- [('product_id', '=', chuck_product_id.id), ('tool_material_status', '=', '可用')])
- for chuck_product_lot_id in chuck_product_lot_ids:
- if chuck_product_lot_id.quant_ids[-1].location_id.name in '刀具房':
- return chuck_product_lot_id
- return False
+ else:
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', barcode)])
+ if location:
+ material_name = location.product_id.cutting_tool_material_id.name
+ if material_name == '整体式刀具':
+ record.integral_freight_barcode = barcode
+ elif material_name == '刀片':
+ record.blade_freight_barcode = barcode
+ elif material_name == '刀杆':
+ record.bar_freight_barcode = barcode
+ elif material_name == '刀盘':
+ record.pad_freight_barcode = barcode
+ elif material_name == '夹头':
+ record.chuck_freight_barcode = barcode
+ else:
+ raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
+ else:
+ raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
@api.depends('handle_code_id')
def _compute_rfid(self):
@@ -437,7 +452,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
else:
obj.after_assembly_functional_tool_name = ''
- @api.onchange('integral_code_id')
+ @api.onchange('integral_freight_barcode')
def _onchange_after_assembly_functional_tool_diameter(self):
for obj in self:
if obj.integral_code_id:
@@ -573,12 +588,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'name': self.after_assembly_functional_tool_name,
'rfid': self.rfid,
'tool_groups_id': self.tool_groups_id.id,
- 'integral_code_id': self.integral_code_id.id,
- 'blade_code_id': self.blade_code_id.id,
- 'bar_code_id': self.bar_code_id.id,
- 'pad_code_id': self.pad_code_id.id,
+ 'integral_product_id': self.integral_product_id.id,
+ 'blade_product_id': self.blade_product_id.id,
+ 'bar_product_id': self.bar_product_id.id,
+ 'pad_product_id': self.pad_product_id.id,
'handle_code_id': self.handle_code_id.id,
- 'chuck_code_id': self.chuck_code_id.id,
+ 'chuck_product_id': self.chuck_product_id.id,
'after_assembly_functional_tool_name': self.after_assembly_functional_tool_name,
'after_assembly_functional_tool_type_id': self.after_assembly_functional_tool_type_id.id,
@@ -613,12 +628,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'tool_groups_id': self.tool_groups_id.id,
'functional_tool_name_id': functional_tool_assembly_id.id,
'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id,
- 'cutting_tool_integral_model_id': self.integral_code_id.product_id.id,
- 'cutting_tool_blade_model_id': self.blade_code_id.product_id.id,
- 'cutting_tool_cutterbar_model_id': self.bar_code_id.product_id.id,
- 'cutting_tool_cutterpad_model_id': self.pad_code_id.product_id.id,
- 'cutting_tool_cutterhandle_model_id': self.handle_code_id.product_id.id,
- 'cutting_tool_cutterhead_model_id': self.chuck_code_id.product_id.id,
+ 'cutting_tool_integral_model_id': self.integral_product_id.id,
+ 'cutting_tool_blade_model_id': self.blade_product_id.id,
+ 'cutting_tool_cutterbar_model_id': self.bar_product_id.id,
+ 'cutting_tool_cutterpad_model_id': self.pad_product_id.id,
+ 'cutting_tool_cutterhandle_model_id': self.handle_product_id.id,
+ 'cutting_tool_cutterhead_model_id': self.chuck_product_id.id,
'functional_tool_diameter': self.after_assembly_functional_tool_diameter,
'knife_tip_r_angle': self.after_assembly_knife_tip_r_angle,
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
index a1b35664..912f7dcf 100644
--- a/sf_tool_management/wizard/wizard_view.xml
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -201,20 +201,18 @@
+ attrs="{'invisible': ['|','|',('blade_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
-
+
-
+
@@ -223,20 +221,18 @@
-
+
-
+
-
+
@@ -246,20 +242,18 @@
+ attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
-
+
-
+
@@ -269,20 +263,18 @@
+ attrs="{'invisible': ['|',('bar_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False)]}">
-
+
-
+
@@ -304,7 +296,7 @@
-
+
@@ -319,14 +311,12 @@
-
+
-
+