From 363463e31d64030648ec491cf1214f7fce781fe5 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Tue, 19 Dec 2023 17:31:37 +0800
Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E5=AE=89?=
=?UTF-8?q?=E8=A3=85=E6=97=B6=E8=87=AA=E5=8A=A8=E9=85=8D=E7=BD=AE=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E6=88=BF=E4=BD=8D=E7=BD=AE=EF=BC=8C=E9=87=8D=E6=96=B0?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BA=86=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85?=
=?UTF-8?q?=E5=85=A5=E5=BA=93=E7=9A=84=E4=BD=9C=E4=B8=9A=E7=B1=BB=E5=9E=8B?=
=?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=90=8D=E7=A7=B0=E4=B8=BA=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E5=85=A5=E5=BA=93=E7=9A=84=E5=8F=82?=
=?UTF-8?q?=E8=80=83=E5=BA=8F=E5=88=97=E9=85=8D=E7=BD=AE=EF=BC=9B2?=
=?UTF-8?q?=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E6=89=80=E4=BB=A5?=
=?UTF-8?q?=E7=9A=84=E8=A3=85=E5=88=80=E9=95=BF=E6=94=B9=E4=B8=BA=E6=80=BB?=
=?UTF-8?q?=E9=95=BF=E5=BA=A6=EF=BC=9B3=E3=80=81=E6=9C=BA=E5=BA=8A?=
=?UTF-8?q?=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E5=92=8C=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E7=BB=84=E8=A3=85=E5=8D=95=E5=BC=B9=E7=AA=97=E7=95=8C=E9=9D=A2?=
=?UTF-8?q?=E5=81=9A=E5=AD=97=E6=AE=B5=E5=BF=85=E5=A1=AB=E6=8E=A7=E5=88=B6?=
=?UTF-8?q?=EF=BC=8C=E5=AF=B9=E6=96=B0=E5=88=80=E9=9A=90=E8=97=8F=E5=88=87?=
=?UTF-8?q?=E5=89=8A=E7=9B=B8=E5=85=B3=E5=AD=97=E6=AE=B5=EF=BC=9B4?=
=?UTF-8?q?=E3=80=81=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=8D=95=E5=BC=B9?=
=?UTF-8?q?=E7=AA=97=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=BA=9B=E5=AD=97=E6=AE=B5?=
=?UTF-8?q?=E7=9A=84=E6=95=B0=E5=80=BC=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=86=99?=
=?UTF-8?q?=E5=92=8C=E8=AE=A1=E7=AE=97=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_base/models/tool_base_new.py | 20 +++---
sf_dlm_management/__manifest__.py | 1 +
sf_dlm_management/data/stock_data.xml | 29 ++++++++
sf_manufacturing/data/stock_data.xml | 27 ++------
sf_tool_management/models/base.py | 53 ++++++++++-----
sf_tool_management/views/tool_base_views.xml | 9 +--
sf_tool_management/wizard/wizard.py | 70 +++++++++++++++++---
sf_tool_management/wizard/wizard_view.xml | 12 ++--
8 files changed, 153 insertions(+), 68 deletions(-)
create mode 100644 sf_dlm_management/data/stock_data.xml
diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py
index c619ea9f..932bb106 100644
--- a/sf_base/models/tool_base_new.py
+++ b/sf_base/models/tool_base_new.py
@@ -77,32 +77,32 @@ class CuttingToolModel(models.Model):
integral_run_out_accuracy_min = fields.Char('整体式刀具端跳精度min')
fit_blade_shape_id = fields.Many2one('maintenance.equipment.image',
- '适配刀片形状', domain=[('type', '=', '刀片形状')])
+ '适配刀片形状', domain=[('type', '=', '刀片形状')])
suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image',
'suitable_machining_method_library_rel',
'适合加工方式', domain=[('type', '=', '加工能力')])
blade_tip_characteristics_id = fields.Many2one('maintenance.equipment.image',
- '刀尖特征', domain=[('type', '=', '刀尖特征')])
+ '刀尖特征', domain=[('type', '=', '刀尖特征')])
handle_type_id = fields.Many2one('maintenance.equipment.image',
- '柄部类型', domain=[('type', '=', '柄部类型')])
+ '柄部类型', domain=[('type', '=', '柄部类型')])
cutting_direction_ids = fields.Many2many('maintenance.equipment.image', 'cutting_direction_library_rel',
'走刀方向', domain=[('type', '=', '走刀方向')])
suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'suitable_coolant_library_rel',
'适合冷却液', domain=[('type', '=', '冷却液')])
compaction_way_id = fields.Many2one('maintenance.equipment.image',
- '压紧方式', domain=[('type', '=', '压紧方式')])
+ '压紧方式', domain=[('type', '=', '压紧方式')])
integral_tool_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters',
- 'standard_library_id', string='整体式刀具基本参数')
+ 'standard_library_id', string='整体式刀具基本参数')
blade_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters',
- 'standard_library_id', string='刀片基本参数')
+ 'standard_library_id', string='刀片基本参数')
cutter_bar_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters',
- 'standard_library_id', string='刀杆基本参数')
+ 'standard_library_id', string='刀杆基本参数')
cutter_head_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters',
- 'standard_library_id', string='刀盘基本参数')
+ 'standard_library_id', string='刀盘基本参数')
knife_handle_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters',
- 'standard_library_id', string='刀柄基本参数')
+ 'standard_library_id', string='刀柄基本参数')
chuck_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters',
- 'standard_library_id', string='夹头基本参数')
+ 'standard_library_id', string='夹头基本参数')
cutting_speed_ids = fields.One2many('sf.cutting.speed', 'standard_library_id', string='切削速度Vc')
feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz',
domain=[('cutting_speed', '!=', False)])
diff --git a/sf_dlm_management/__manifest__.py b/sf_dlm_management/__manifest__.py
index a32ecf81..a5c894d4 100644
--- a/sf_dlm_management/__manifest__.py
+++ b/sf_dlm_management/__manifest__.py
@@ -11,6 +11,7 @@
'website': 'https://www.sf.jikimo.com',
'depends': ['sf_sale', 'sf_dlm', 'sf_manufacturing'],
'data': [
+ 'data/stock_data.xml',
'views/product_template_management_view.xml',
],
'demo': [
diff --git a/sf_dlm_management/data/stock_data.xml b/sf_dlm_management/data/stock_data.xml
new file mode 100644
index 00000000..d6067cdf
--- /dev/null
+++ b/sf_dlm_management/data/stock_data.xml
@@ -0,0 +1,29 @@
+
+
+
+
+ 刀具房
+ internal
+ 库区
+ 存货区
+ DJF
+ true
+
+
+
+
+
+
+ 刀具组装入库
+ internal
+
+ true
+
+ ZR
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_manufacturing/data/stock_data.xml b/sf_manufacturing/data/stock_data.xml
index b65b2235..74d02b4a 100644
--- a/sf_manufacturing/data/stock_data.xml
+++ b/sf_manufacturing/data/stock_data.xml
@@ -13,6 +13,12 @@
5
+
+ My Company 刀具组装入库
+ ZR/
+ 5
+
+
外协
@@ -31,15 +37,6 @@
-
-
-
-
-
-
-
-
-
外协入库
internal
@@ -63,17 +60,5 @@
search="[('barcode','=','WH-PREPRODUCTION')]"/>
-
-
- 刀具组装入库
- internal
- true
-
- ZR
-
-
-
-
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 54834390..44b2b912 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -22,7 +22,7 @@ class FunctionalCuttingToolEntity(models.Model):
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True)
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
- tool_loading_length = fields.Float(string='装刀长(mm)', readonly=True)
+ tool_loading_length = fields.Float(strin='总长度(mm)', readonly=True)
functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True)
effective_length = fields.Float(string='有效长(mm)', readonly=True)
tool_room_num = fields.Integer(string='刀具房数量', readonly=True)
@@ -107,19 +107,41 @@ class FunctionalCuttingToolEntity(models.Model):
suitable_machining_method_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_machining_product_template_tool_entity', '适合加工方式',
- domain=[('type', '=', '加工能力')], related='cutting_tool_integral_model_id.suitable_machining_method_ids')
+ domain=[('type', '=', '加工能力')])
blade_tip_characteristics_id = fields.Many2one(
'maintenance.equipment.image', '刀尖特征',
- domain=[('type', '=', '刀尖特征')], related='cutting_tool_integral_model_id.blade_tip_characteristics_id')
+ domain=[('type', '=', '刀尖特征')])
handle_type_id = fields.Many2one(
'maintenance.equipment.image', '柄部类型',
- domain=[('type', '=', '柄部类型')], related='cutting_tool_integral_model_id.handle_type_id')
+ domain=[('type', '=', '柄部类型')])
cutting_direction_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_cutting_product_template_tool_entity', '走刀方向',
- domain=[('type', '=', '走刀方向')], related='cutting_tool_integral_model_id.cutting_direction_ids')
+ domain=[('type', '=', '走刀方向')])
suitable_coolant_ids = fields.Many2many(
'maintenance.equipment.image', 'rel_coolant_product_template_tool_entity', '适合冷却液',
- domain=[('type', '=', '冷却液')], related='cutting_tool_integral_model_id.suitable_coolant_ids')
+ domain=[('type', '=', '冷却液')])
+
+ @api.depends('cutting_tool_integral_model_id', 'cutting_tool_blade_model_id')
+ def _compute_maintenance_equipment_image(self):
+ for record in self:
+ if record.cutting_tool_integral_model_id:
+ record.suitable_machining_method_ids = record.cutting_tool_integral_model_id.suitable_machining_method_ids.ids
+ record.blade_tip_characteristics_id = record.cutting_tool_integral_model_id.blade_tip_characteristics_id.ids
+ record.handle_type_id = record.cutting_tool_integral_model_id.handle_type_id.ids
+ record.cutting_direction_ids = record.cutting_tool_integral_model_id.cutting_direction_ids.ids
+ record.suitable_coolant_ids = record.cutting_tool_integral_model_id.suitable_coolant_ids.ids
+ elif record.cutting_tool_blade_model_id:
+ record.suitable_machining_method_ids = record.cutting_tool_blade_model_id.suitable_machining_method_ids.ids
+ record.blade_tip_characteristics_id = record.cutting_tool_blade_model_id.blade_tip_characteristics_id.ids
+ record.handle_type_id = record.cutting_tool_blade_model_id.handle_type_id.ids
+ record.cutting_direction_ids = record.cutting_tool_blade_model_id.cutting_direction_ids.ids
+ record.suitable_coolant_ids = record.cutting_tool_blade_model_id.suitable_coolant_ids.ids
+ else:
+ record.suitable_machining_method_ids = []
+ record.blade_tip_characteristics_id = []
+ record.handle_type_id = []
+ record.cutting_direction_ids = []
+ record.suitable_coolant_ids = []
def _get_functional_tool_model_ids(self, functional_tool_model_code):
functional_tool_model_ids = []
@@ -332,8 +354,7 @@ class MachineTableToolChangingApply(models.Model):
# 设备信息
maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床', readonly=True,
domain=[('category_id.equipment_type', '=', '机床')])
- production_line_id = fields.Many2one('sf.production.line', string='生产线', readonly=True,
- group_expand='_read_group_names')
+ production_line_id = fields.Many2one('sf.production.line', string='生产线', readonly=True)
machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型', readonly=True,
compute='_compute_machine_table_type_id')
machine_tool_code = fields.Char(string='机台号', related='maintenance_equipment_id.name')
@@ -344,9 +365,10 @@ class MachineTableToolChangingApply(models.Model):
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', store=True,
domain=[('product_id.name', '=', '功能刀具')],
related='functional_tool_name_id.barcode_id')
- functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称')
+ functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', domain=[('assemble_status', '=', '1')],
+ string='功能刀具名称')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
- related='functional_tool_name_id.functional_tool_type_id')
+ related='functional_tool_name_id.after_assembly_functional_tool_type_id')
tool_position_interface_type = fields.Selection(
[('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'),
@@ -403,11 +425,6 @@ class MachineTableToolChangingApply(models.Model):
if len(records) > 1:
raise ValidationError('该刀位号已存在,请重新选择!!!')
- @api.model
- def _read_group_names(self, categories, domain, order):
- names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
- return categories.browse(names)
-
@api.constrains('functional_tool_status')
def automation_apply_for_tool_change(self):
"""
@@ -520,7 +537,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False)
diameter = fields.Integer(string='刀具直径(mm)', readonly=False)
tool_included_angle = fields.Float(string='刀尖R角(mm)', readonly=False)
- tool_loading_length = fields.Float(string='装刀长(mm)', readonly=False)
+ tool_loading_length = fields.Float(strin='总长度(mm)', readonly=False)
extension_length = fields.Float(string='伸出长(mm)')
effective_length = fields.Float(string='有效长(mm)')
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=False, default='0')
@@ -608,7 +625,7 @@ class FunctionalToolAssembly(models.Model):
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True)
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
- tool_loading_length = fields.Float(string='装刀长(mm)', readonly=True)
+ tool_loading_length = fields.Float(strin='总长度(mm)', readonly=True)
functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True)
effective_length = fields.Float(string='有效长(mm)', readonly=True)
loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀'), ('2', '按库存组装')],
@@ -744,7 +761,7 @@ class FunctionalToolAssembly(models.Model):
after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)', readonly=True)
after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)', readonly=True)
after_assembly_used_value = fields.Integer(string='组装后已使用值(min)', readonly=True)
- after_assembly_tool_loading_length = fields.Float(string='组装后装刀长(mm)', readonly=True)
+ after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)', readonly=True)
after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', readonly=True)
after_assembly_effective_length = fields.Float(string='组装后有效长(mm)', readonly=True)
L_D_number = fields.Float(string='L/D值(mm)', readonly=True)
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index 0553eb97..c4202131 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -156,9 +156,10 @@
-
-
-
+
+
+
+
@@ -990,7 +991,7 @@
string="最大寿命值(min)"/>
-
+
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 8b3af487..b198c2e7 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -35,23 +35,34 @@ class ToolChangeRequirementInformation(models.TransientModel):
replacement_tool_name = fields.Char(string='待换功能刀具名称', required=True)
replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型')
replacement_diameter = fields.Integer(string='待换刀具直径(mm)')
- replacement_knife_tip_r_angle = fields.Float(string='待换刀具刀尖R角(mm)')
- replacement_tool_setting_length = fields.Float(string='待换刀具装刀长(mm)')
+ replacement_knife_tip_r_angle = fields.Float(string='待换刀具刀尖R角(mm)', requride=True)
+ replacement_tool_setting_length = fields.Float(string='待换刀具总长度(mm)', requride=True)
replacement_extension_length = fields.Float(string='待换刀具伸出长(mm)')
replacement_effective_length = fields.Float(string='待换刀具有效长(mm)')
- replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
+ replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], requride=True,
string='待换刀具粗/中/精', default='3')
replacement_max_lifetime_value = fields.Integer(string='待换刀具最大寿命值(min)')
replacement_alarm_value = fields.Integer(string='待换刀具报警值(min)')
replacement_used_value = fields.Integer(string='待换刀具已使用值(min)')
- new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', default='0')
+ new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', default='0', requride=True)
replacement_whether_standard_knife = fields.Boolean(string='待换刀具是否标准刀', default=True)
used_tool_time = fields.Datetime(string='用刀时间',
default=lambda self: fields.Datetime.now() + timedelta(hours=4))
applicant = fields.Char(string='申请人', default=lambda self: self.env.user.name, readonly=True)
reason_for_applying = fields.Char(string='申请原因')
+ @api.constrains('replacement_knife_tip_r_angle', 'replacement_diameter', 'replacement_tool_coarse_middle_thin',
+ 'new_former')
+ def _check_length_or_diamenter(self):
+ for obj in self:
+ if obj.replacement_diameter == 0 and obj.replacement_knife_tip_r_angle == 0:
+ raise ValidationError('待换功能刀具信息【刀具直径】和【刀尖R角】不能同时为0!!!')
+ if not obj.new_former:
+ raise ValidationError('待换功能刀具信息【新/旧】不能位空!!!')
+ if not obj.replacement_tool_coarse_middle_thin:
+ raise ValidationError('待换功能刀具信息【粗/中/精】不能位空!!!')
+
def tool_changing_apply(self):
"""
确认换刀申请(按键)
@@ -173,7 +184,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True)
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
- tool_loading_length = fields.Float(string='装刀长(mm)', readonly=True)
+ tool_loading_length = fields.Float(string='总长度(mm)', readonly=True)
functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True)
effective_length = fields.Float(string='有效长(mm)', readonly=True)
loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀'), ('2', '按库存组装')],
@@ -336,7 +347,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', required=True)
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
- string='组装后功能刀具类型')
+ string='组装后功能刀具类型',
+ compute='_compute_after_assembly_functional_tool_type_id')
after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)')
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)')
after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', default='0')
@@ -350,14 +362,54 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)')
after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)')
after_assembly_used_value = fields.Integer(string='组装后已使用值(min)')
- after_assembly_tool_loading_length = fields.Float(string='组装后装刀长(mm)')
- after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)')
+ after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)')
+ after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', required=True)
after_assembly_effective_length = fields.Float(string='组装后有效长(mm)')
- L_D_number = fields.Float(string='L/D值(mm)')
+ L_D_number = fields.Float(string='L/D值(mm)', compute='_compute_l_d_number')
hiding_length = fields.Float(string='避空长(mm)')
functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False)
+ @api.onchange('integral_code_id')
+ def _onchange_after_assembly_functional_tool_diameter(self):
+ for obj in self:
+ if obj.integral_code_id:
+ obj.after_assembly_functional_tool_diameter = obj.integral_code_id.product_id.cutting_tool_blade_diameter
+ else:
+ obj.after_assembly_functional_tool_diameter = 0
+
+ @api.onchange('blade_code_id')
+ def _onchange_after_assembly_knife_tip_r_angle(self):
+ for obj in self:
+ if obj.blade_code_id:
+ obj.after_assembly_knife_tip_r_angle = obj.blade_code_id.product_id.cutting_tool_blade_tip_circular_arc_radius
+ else:
+ obj.after_assembly_knife_tip_r_angle = 0
+
+ @api.depends('functional_tool_type_id')
+ def _compute_after_assembly_functional_tool_type_id(self):
+ for obj in self:
+ if obj.functional_tool_type_id:
+ obj.after_assembly_functional_tool_type_id = obj.functional_tool_type_id
+ else:
+ obj.after_assembly_functional_tool_type_id = None
+
+ @api.depends('hiding_length', 'after_assembly_functional_tool_diameter')
+ def _compute_l_d_number(self):
+ for record in self:
+ if record.hiding_length != 0 and record.after_assembly_functional_tool_diameter != 0:
+ record.L_D_number = record.hiding_length / record.after_assembly_functional_tool_diameter
+ else:
+ record.L_D_number = 0
+
+ @api.constrains('after_assembly_tool_loading_length', 'after_assembly_functional_tool_length')
+ def _check_length_control(self):
+ for obj in self:
+ if obj.after_assembly_tool_loading_length == 0:
+ raise ValidationError('组装参数信息【总长度】不能为0!!!')
+ if obj.after_assembly_functional_tool_length == 0:
+ raise ValidationError('组装参数信息【伸出长】不能为0!!!')
+
def functional_tool_assembly(self):
"""
功能刀具组装
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
index bf061d99..453d6f60 100644
--- a/sf_tool_management/wizard/wizard_view.xml
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -40,7 +40,7 @@
options="{'no_create': True, 'no_quick_create': True}"/>
-
+
@@ -341,9 +341,9 @@
-
-
-
+
+
+
@@ -351,11 +351,11 @@
-
+
-
+
From ce67b7985b3c0f82f319ce9b3b8adc615d6cec91 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Wed, 20 Dec 2023 15:21:06 +0800
Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=92=8C=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=BC=B9=E7=AA=97?=
=?UTF-8?q?=E7=95=8C=E9=9D=A2=E7=9A=84=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E7=89=A9=E6=96=99=E8=A7=84=E6=A0=BC=E5=AD=97=E6=AE=B5=EF=BC=9B?=
=?UTF-8?q?2=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E7=A1=AE=E8=AE=A4=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=EF=BC=8C=E5=88=9B=E5=BB=BA=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85?=
=?UTF-8?q?=E5=85=A5=E5=BA=93=E4=BD=9C=E4=B8=9A=E6=97=B6=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?name=E5=AD=97=E6=AE=B5=E5=86=85=E5=AE=B9=EF=BC=8C=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E4=BD=9C=E4=B8=9A=E8=87=AA=E5=8A=A8=E9=AA=8C=E8=AF=81?=
=?UTF-8?q?=EF=BC=9B3=E3=80=81=E4=BC=98=E5=8C=96=E8=87=AA=E5=8A=A8?=
=?UTF-8?q?=E7=94=9F=E6=88=90=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=BA=8F?=
=?UTF-8?q?=E5=88=97=E5=8F=B7=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 103 ++++-------
sf_tool_management/views/tool_base_views.xml | 6 +
sf_tool_management/wizard/wizard.py | 172 +++++++++----------
sf_tool_management/wizard/wizard_view.xml | 30 ++--
4 files changed, 129 insertions(+), 182 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 44b2b912..3a919de7 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -657,91 +657,52 @@ class FunctionalToolAssembly(models.Model):
# 整体式刀具型号
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', readonly=True)
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
- readonly=True)
- integral_name = fields.Char('整体式刀具名称', readonly=True, compute='_compute_auto_fill')
- sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True)
+ related='integral_code_id.product_id.cutting_tool_model_id')
+ integral_name = fields.Char('整体式刀具名称', related='integral_code_id.product_id.name')
+ integral_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='整体式刀具规格',
+ related='integral_code_id.product_id.specification_id')
+ sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
+ related='integral_code_id.product_id.brand_id')
# 刀片型号
blade_code_id = fields.Many2one('stock.lot', '刀片序列号', readonly=True)
- cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', readonly=True)
- blade_name = fields.Char('刀片名称', readonly=True, compute='_compute_auto_fill')
- sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=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')
+ 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')
# 刀杆型号
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', readonly=True)
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
- readonly=True)
- bar_name = fields.Char('刀杆名称', readonly=True, compute='_compute_auto_fill')
- sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True)
+ related='bar_code_id.product_id.cutting_tool_model_id')
+ bar_name = fields.Char('刀杆名称', related='bar_code_id.product_id.name')
+ 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')
# 刀盘型号
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', readonly=True)
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
- readonly=True)
- pad_name = fields.Char('刀盘名称', readonly=True, compute='_compute_auto_fill')
- sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True)
+ related='pad_code_id.product_id.cutting_tool_model_id')
+ pad_name = fields.Char('刀盘名称', related='pad_code_id.product_id.name')
+ 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')
# 刀柄型号
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', readonly=True)
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
- readonly=True)
- handle_name = fields.Char('刀柄名称', readonly=True, compute='_compute_auto_fill')
- sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True)
+ 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', '夹头序列号', readonly=True)
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
- readonly=True)
- chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill')
- sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True)
-
- @api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id')
- def _compute_auto_fill(self):
- for record in self:
- if record.integral_code_id:
- print(record.integral_code_id.product_id)
- record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_model_id.id
- record.integral_name = record.integral_code_id.product_id.name
- record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_integral_model_id = None
- record.integral_name = None
- record.sf_tool_brand_id_1 = None
- if record.blade_code_id:
- record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_model_id.id
- record.blade_name = record.blade_code_id.product_id.name
- record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_blade_model_id = None
- record.blade_name = None
- record.sf_tool_brand_id_2 = None
- if record.bar_code_id:
- record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_model_id.id
- record.bar_name = record.bar_code_id.product_id.name
- record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_cutterbar_model_id = None
- record.bar_name = None
- record.sf_tool_brand_id_3 = None
- if record.pad_code_id:
- record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_model_id.id
- record.pad_name = record.pad_code_id.product_id.name
- record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_cutterpad_model_id = None
- record.pad_name = None
- record.sf_tool_brand_id_4 = None
- if record.handle_code_id:
- record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_model_id.id
- record.handle_name = record.handle_code_id.product_id.name
- record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_cutterhandle_model_id = None
- record.handle_name = None
- record.sf_tool_brand_id_5 = None
- if record.chuck_code_id:
- record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_model_id.id
- record.chuck_name = record.chuck_code_id.product_id.name
- record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_cutterhead_model_id = None
- record.chuck_name = None
- record.sf_tool_brand_id_6 = None
+ related='chuck_code_id.product_id.cutting_tool_model_id')
+ chuck_name = fields.Char('夹头名称', related='chuck_code_id.product_id.name')
+ 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')
# 组装功能刀具参数信息
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index c4202131..68b595b0 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -1012,6 +1012,7 @@
options="{'no_create': True, 'no_quick_create': True}"/>
+
@@ -1024,6 +1025,7 @@
options="{'no_create': True, 'no_quick_create': True}"/>
+
@@ -1036,6 +1038,7 @@
options="{'no_create': True, 'no_quick_create': True}"/>
+
@@ -1051,6 +1054,7 @@
options="{'no_create': True, 'no_quick_create': True}"/>
+
@@ -1065,6 +1069,7 @@
options="{'no_create': True, 'no_quick_create': True}"/>
+
@@ -1079,6 +1084,7 @@
options="{'no_create': True, 'no_quick_create': True}"/>
+
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index b198c2e7..89b9f854 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -1,4 +1,4 @@
-from datetime import timedelta
+from datetime import timedelta, datetime
from odoo import fields, models, api
from odoo.exceptions import ValidationError
@@ -213,18 +213,24 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
('quant_ids.location_id.name', 'in', ['刀具房']),
('quant_ids.quantity', '>', 0)])
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
- readonly=True)
- integral_name = fields.Char('整体式刀具名称', readonly=True)
- sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True)
+ related='integral_code_id.product_id.cutting_tool_model_id')
+ integral_name = fields.Char('整体式刀具名称', related='integral_code_id.product_id.name')
+ integral_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='整体式刀具规格',
+ related='integral_code_id.product_id.specification_id')
+ sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
+ related='integral_code_id.product_id.brand_id')
# 刀片型号
blade_code_id = fields.Many2one('stock.lot', '刀片序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片'),
('quant_ids.location_id.name', 'in', ['刀具房']),
('quant_ids.quantity', '>', 0)])
- cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', readonly=True)
- blade_name = fields.Char('刀片名称', readonly=True)
- sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=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')
+ 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')
# 刀杆型号
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号',
@@ -232,9 +238,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
('quant_ids.location_id.name', 'in', ['刀具房']),
('quant_ids.quantity', '>', 0)])
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
- readonly=True)
- bar_name = fields.Char('刀杆名称', readonly=True)
- sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True)
+ related='bar_code_id.product_id.cutting_tool_model_id')
+ bar_name = fields.Char('刀杆名称', related='bar_code_id.product_id.name')
+ 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')
# 刀盘型号
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号',
@@ -242,9 +250,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
('quant_ids.location_id.name', 'in', ['刀具房']),
('quant_ids.quantity', '>', 0)])
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
- readonly=True)
- pad_name = fields.Char('刀盘名称', readonly=True)
- sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True)
+ related='pad_code_id.product_id.cutting_tool_model_id')
+ pad_name = fields.Char('刀盘名称', related='pad_code_id.product_id.name')
+ 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')
# 刀柄型号
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True,
@@ -252,9 +262,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
('quant_ids.location_id.name', 'in', ['刀具房']),
('quant_ids.quantity', '>', 0)])
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
- readonly=True)
- handle_name = fields.Char('刀柄名称', readonly=True)
- sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True)
+ 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,
@@ -262,9 +274,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
('quant_ids.location_id.name', 'in', ['刀具房']),
('quant_ids.quantity', '>', 0)])
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
- readonly=True)
- chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill')
- sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True)
+ related='chuck_code_id.product_id.cutting_tool_model_id')
+ chuck_name = fields.Char('夹头名称', related='chuck_code_id.product_id.name')
+ 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')
def on_barcode_scanned(self, barcode):
"""
@@ -291,58 +305,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
else:
raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
- @api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id')
- def _compute_auto_fill(self):
- for record in self:
- if record.integral_code_id:
- record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_model_id.id
- record.integral_name = record.integral_code_id.product_id.name
- record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_integral_model_id = None
- record.integral_name = None
- record.sf_tool_brand_id_1 = None
- if record.blade_code_id:
- record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_model_id.id
- record.blade_name = record.blade_code_id.product_id.name
- record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_blade_model_id = None
- record.blade_name = None
- record.sf_tool_brand_id_2 = None
- if record.bar_code_id:
- record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_model_id.id
- record.bar_name = record.bar_code_id.product_id.name
- record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_cutterbar_model_id = None
- record.bar_name = None
- record.sf_tool_brand_id_3 = None
- if record.pad_code_id:
- record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_model_id.id
- record.pad_name = record.pad_code_id.product_id.name
- record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_cutterpad_model_id = None
- record.pad_name = None
- record.sf_tool_brand_id_4 = None
- if record.handle_code_id:
- record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_model_id.id
- record.handle_name = record.handle_code_id.product_id.name
- record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_cutterhandle_model_id = None
- record.handle_name = None
- record.sf_tool_brand_id_5 = None
- if record.chuck_code_id:
- record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_model_id.id
- record.chuck_name = record.chuck_code_id.product_id.name
- record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id
- else:
- record.cutting_tool_cutterhead_model_id = None
- record.chuck_name = None
- record.sf_tool_brand_id_6 = None
-
# 组装功能刀具参数信息
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', required=True)
@@ -430,7 +392,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 创建功能刀具批次/序列号记录
stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly)
# 创建刀具组装入库单
- self.create_stocking_picking(stock_lot, functional_tool_assembly)
+ self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly)
# 刀具物料出库
if self.integral_code_id:
product_id.tool_material_stock_moves(self.integral_code_id)
@@ -488,26 +450,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
if not self.bar_code_id and not self.pad_code_id:
raise ValidationError('【刀盘】和【刀杆】必须填写一个!')
- def create_stocking_picking(self, stock_lot, functional_tool_assembly):
- """
- 创建刀具组装入库单
- """
- # 获取名称为刀具组装入库的作业类型
- picking_type_id = self.env['stock.picking.type'].sudo().search([('name', '=', '刀具组装入库')])
- # 创建刀具组装入库单
- picking_id = self.env['stock.picking'].create({
- 'picking_type_id': picking_type_id.id
- })
- # 创建作业详情对象记录,并绑定到刀具组装入库单
- self.env['stock.move.line'].create({
- 'picking_id': picking_id.id,
- 'product_id': stock_lot.product_id.id,
- 'lot_id': stock_lot.id,
- 'functional_tool_name_id': functional_tool_assembly.id
- })
- # 将刀具组装入库单的状态更改为就绪
- picking_id.action_confirm()
-
def get_desc_1(self, stock_lot):
return {
'barcode_id': stock_lot.id,
@@ -575,6 +517,50 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
}
+class StockPicking(models.Model):
+ _inherit = 'stock.picking'
+
+ def create_stocking_picking(self, stock_lot, functional_tool_assembly):
+ """
+ 创建刀具组装入库单
+ """
+ # 获取名称为刀具组装入库的作业类型
+ picking_type_id = self.env['stock.picking.type'].sudo().search([('name', '=', '刀具组装入库')])
+ # 创建刀具组装入库单
+ picking_id = self.env['stock.picking'].create({
+ 'name': self._get_name_stock(picking_type_id),
+ 'picking_type_id': picking_type_id.id,
+ 'location_id': picking_type_id.default_location_src_id.id,
+ 'location_dest_id': picking_type_id.default_location_dest_id.id,
+ })
+ # 创建作业详情对象记录,并绑定到刀具组装入库单
+ self.env['stock.move.line'].create({
+ 'picking_id': picking_id.id,
+ 'product_id': stock_lot.product_id.id,
+ 'lot_id': stock_lot.id,
+ 'qty_done': 1,
+ 'functional_tool_name_id': functional_tool_assembly.id
+ })
+ # 将刀具组装入库单的状态更改为就绪
+ picking_id.action_confirm()
+ picking_id.button_validate()
+
+ def _get_name_stock(self, picking_type_id):
+ name = picking_type_id.sequence_id.prefix + str(
+ datetime.strptime(str(fields.Date.today()), "%Y-%m-%d").strftime("%Y%m%d"))
+ stock_id = self.env['stock.picking'].sudo().search(
+ [('name', 'like', name), ('picking_type_id', '=', picking_type_id.id)],
+ limit=1,
+ order="id desc"
+ )
+ if not stock_id:
+ num = "%03d" % 1
+ else:
+ m = int(stock_id.name[-3:]) + 1
+ num = "%03d" % m
+ return name + str(num)
+
+
class ProductProduct(models.Model):
_inherit = 'product.product'
@@ -605,7 +591,7 @@ class ProductProduct(models.Model):
[('id', '=', tool_assembly_order_id)])
code = 'JKM-T-' + str(tool_assembly_order.after_assembly_functional_tool_type_id.code) + '-' + str(
tool_assembly_order.after_assembly_functional_tool_diameter) + '-'
- new_time = fields.Date.today()
+ new_time = datetime.strptime(str(fields.Date.today()), "%Y-%m-%d").strftime("%Y%m%d")
code += str(new_time) + '-'
stock_lot_id = self.env['stock.lot'].sudo().search(
[('name', 'like', new_time), ('product_id.name', '=', '功能刀具')],
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
index 453d6f60..7b3d2ab5 100644
--- a/sf_tool_management/wizard/wizard_view.xml
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -206,14 +206,13 @@
options="{'no_create': True, 'no_quick_create': True}"/>
-
+
+
-
-
@@ -228,14 +227,13 @@
options="{'no_create': True, 'no_quick_create': True}"/>
-
+
+
-
-
@@ -251,14 +249,13 @@
options="{'no_create': True, 'no_quick_create': True}"/>
-
+
+
-
-
@@ -274,14 +271,13 @@
options="{'no_create': True, 'no_quick_create': True}"/>
-
+
+
-
-
@@ -296,14 +292,13 @@
options="{'no_create': True, 'no_quick_create': True}"/>
-
+
+
-
-
@@ -318,14 +313,13 @@
options="{'no_create': True, 'no_quick_create': True}"/>
-
+
+
-
-