From ce86a66e9213f414aa226ffb0e09add15fa8e9e5 Mon Sep 17 00:00:00 2001 From: "JIKIMO-YXH\\xianghui" <3437689193@qq.com> Date: Wed, 25 Oct 2023 17:35:12 +0800 Subject: [PATCH 1/5] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E4=BA=A7=E5=93=81=E7=B1=BB?= =?UTF-8?q?=E5=88=AB=E5=92=8C=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E6=A8=A1?= =?UTF-8?q?=E7=89=88=EF=BC=9B2=E3=80=81=E6=96=B0=E5=A2=9E=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=BB=84=E8=A3=85=E5=90=8E=E4=BD=8D=E7=BD=AE=E5=92=8C=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E5=85=A5=E5=BA=93=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E7=B1=BB=E5=9E=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_dlm/data/product_data.xml | 24 ++++++++++++++++++++++++ sf_manufacturing/data/stock_data.xml | 21 +++++++++++++++++++++ sf_manufacturing/models/model_type.py | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/sf_dlm/data/product_data.xml b/sf_dlm/data/product_data.xml index a31f97fc..15cfc8b5 100644 --- a/sf_dlm/data/product_data.xml +++ b/sf_dlm/data/product_data.xml @@ -30,6 +30,30 @@ 夹具 + + 功能刀具 + 功能刀具 + + + + + 功能刀具模板 + + + + delivery + product + false + true + + + + true + serial + false + + CNC加工产品模板 diff --git a/sf_manufacturing/data/stock_data.xml b/sf_manufacturing/data/stock_data.xml index 8efbdd55..15ad1a55 100644 --- a/sf_manufacturing/data/stock_data.xml +++ b/sf_manufacturing/data/stock_data.xml @@ -22,6 +22,15 @@ + + 组装后 + + internal + DJ-ZZ + true + + + 外协入库 internal @@ -46,6 +55,18 @@ + + 刀具组装入库 + internal + true + + + + ZR + + + diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py index 672741e3..71161b59 100644 --- a/sf_manufacturing/models/model_type.py +++ b/sf_manufacturing/models/model_type.py @@ -6,7 +6,7 @@ class ResProductCategory(models.Model): type = fields.Selection( [("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"), - ("夹具", "夹具")], + ("夹具", "夹具"), ("功能刀具", "功能刀具")], default="", string="类型") From e3d58c2a9e2a0be6b89ca3f44202b73adab4a625 Mon Sep 17 00:00:00 2001 From: "JIKIMO-YXH\\xianghui" <3437689193@qq.com> Date: Thu, 26 Oct 2023 17:39:33 +0800 Subject: [PATCH 2/5] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E4=BA=A7?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E7=94=9F=E6=88=90=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=EF=BC=8C=E8=A7=A3=E5=86=B3=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=97=A0=E6=B3=95=E9=80=89=E6=8B=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?2=E3=80=81=E4=BC=98=E5=8C=96=E5=8F=96=E6=B6=88=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=9B3=E3=80=81=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E7=A1=AE=E5=AE=9A=E5=90=8E?= =?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=EF=BC=8C=E7=94=9F=E6=88=90=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=BB=84=E8=A3=85=E5=85=A5=E5=BA=93=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_dlm/data/product_data.xml | 7 +-- sf_manufacturing/data/stock_data.xml | 2 - sf_tool_management/models/base.py | 12 ++-- sf_tool_management/views/tool_base_views.xml | 33 +---------- sf_tool_management/wizard/wizard.py | 62 ++++++++++++++++++++ 5 files changed, 72 insertions(+), 44 deletions(-) diff --git a/sf_dlm/data/product_data.xml b/sf_dlm/data/product_data.xml index 15cfc8b5..528c6ec2 100644 --- a/sf_dlm/data/product_data.xml +++ b/sf_dlm/data/product_data.xml @@ -35,10 +35,8 @@ 功能刀具 - - 功能刀具模板 - + 功能刀具 @@ -49,9 +47,8 @@ - true + false serial - false diff --git a/sf_manufacturing/data/stock_data.xml b/sf_manufacturing/data/stock_data.xml index 15ad1a55..4e1841e2 100644 --- a/sf_manufacturing/data/stock_data.xml +++ b/sf_manufacturing/data/stock_data.xml @@ -59,8 +59,6 @@ 刀具组装入库 internal true - - ZR diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index a55f4f17..ff3f1bed 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -895,27 +895,27 @@ class FunctionalToolAssembly(models.Model): ('assemble_status', '=', '1') ]).write({ 'cutting_tool_integral_model_id': None, - 'integral_code': None, + 'integral_code_id': None, 'integral_name': None, 'sf_tool_brand_id_1': None, 'cutting_tool_blade_model_id': None, - 'blade_code': None, + 'blade_code_id': None, 'blade_name': None, 'sf_tool_brand_id_2': None, 'cutting_tool_cutterbar_model_id': None, - 'bar_code': None, + 'bar_code_id': None, 'bar_name': None, 'sf_tool_brand_id_3': None, 'cutting_tool_cutterpad_model_id': None, - 'pad_code': None, + 'pad_code_id': None, 'pad_name': None, 'sf_tool_brand_id_4': None, 'cutting_tool_cutterhandle_model_id': None, - 'handle_code': None, + 'handle_code_id': None, 'handle_name': None, 'sf_tool_brand_id_5': None, 'cutting_tool_cutterhead_model_id': None, - 'chuck_code': None, + 'chuck_code_id': None, 'chuck_name': None, 'sf_tool_brand_id_6': None, 'coarse_middle_thin': None, diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 0e9f7386..077cb027 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -1127,7 +1127,7 @@ - +
@@ -1165,7 +1165,7 @@
- +
@@ -1208,35 +1208,6 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index c9dd4eb9..7218bd1f 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -392,9 +392,71 @@ class FunctionalToolAssemblyOrder(models.TransientModel): self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).write(desc_2) # 修改功能刀具组装信息 functional_tool_assembly.write(desc_1) + + # 创建组装入库单 + # 创建功能刀具批次/序列号记录 + stock_lot = self.create_assemble_warehouse_receipt() + # 创建刀具组装入库单 + self.create_stocking_picking(stock_lot) + # 关闭弹出窗口 return {'type': 'ir.actions.act_window_close'} + def create_stocking_picking(self, stock_lot): + """ + 创建刀具组装入库单 + """ + # 获取名称为刀具组装入库的作业类型 + 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 + }) + # 将刀具组装入库单的状态更改为就绪 + picking_id.action_confirm() + + def create_assemble_warehouse_receipt(self): + """ + 创建功能刀具批次/序列号记录 + """ + product_id = self.env['product.product'].search([('name', '=', '功能刀具')]) + + stock_lot = self.env['stock.lot'].create({ + 'name': self.get_stock_lot_name(), + 'product_id': product_id.id, + 'product_qty': 1.00, + 'company_id': self.env.company.id + }) + + return stock_lot + + def get_stock_lot_name(self): + """ + 生成功能刀具序列号 + """ + code = 'JKM-T-' + str(self.code) + '-' + str(self.functional_tool_diameter) + '-' + new_time = fields.Date.today() + code += str(new_time) + '-' + stock_lot_id = self.env['stock.lot'].sudo().search( + [('name', 'like', new_time), ('product_id.name', '=', '功能刀具')], + limit=1, + order="id desc" + ) + print(stock_lot_id) + if not stock_lot_id: + num = "%03d" % 1 + else: + m = int(stock_lot_id.name[-3:]) + 1 + num = "%03d" % m + print(num) + return code + str(num) + class DeliveryOfCargoFromStorage(models.TransientModel): _name = 'sf.delivery.of.cargo.from.storage' From 5b9fcb2e53a30367b4278dd1f470a3089d2e4c2e Mon Sep 17 00:00:00 2001 From: "JIKIMO-YXH\\xianghui" <3437689193@qq.com> Date: Fri, 27 Oct 2023 17:46:19 +0800 Subject: [PATCH 3/5] =?UTF-8?q?1=E3=80=81=E5=88=9B=E5=BB=BA=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E8=AF=A5=E6=89=B9?= =?UTF-8?q?=E6=AC=A1/=E5=BA=8F=E5=88=97=E5=8F=B7=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_dlm/data/product_data.xml | 5 +++-- sf_manufacturing/data/stock_data.xml | 9 +++++++++ sf_tool_management/wizard/wizard.py | 28 +++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/sf_dlm/data/product_data.xml b/sf_dlm/data/product_data.xml index 528c6ec2..4474a524 100644 --- a/sf_dlm/data/product_data.xml +++ b/sf_dlm/data/product_data.xml @@ -38,8 +38,9 @@ 功能刀具 - + + + false delivery product false diff --git a/sf_manufacturing/data/stock_data.xml b/sf_manufacturing/data/stock_data.xml index 4e1841e2..b65b2235 100644 --- a/sf_manufacturing/data/stock_data.xml +++ b/sf_manufacturing/data/stock_data.xml @@ -31,6 +31,15 @@ + + + + + + + + + 外协入库 internal diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 7218bd1f..a0fd7b95 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -430,12 +430,36 @@ class FunctionalToolAssemblyOrder(models.TransientModel): stock_lot = self.env['stock.lot'].create({ 'name': self.get_stock_lot_name(), 'product_id': product_id.id, - 'product_qty': 1.00, 'company_id': self.env.company.id }) + # 创建功能刀具该批次/序列号位置 + self.create_stock_quant(product_id, stock_lot) return stock_lot + def create_stock_quant(self, product_id, stock_lot): + """ + 创建功能刀具该批次/序列号位置 + """ + # 获取组装后位置对象 + stock_location = self.env['stock.location'].search([('name', '=', '组装后')]) + # + self.env['stock.move'].create({ + '': + }) + + # 创建功能刀具该批次/序列号位置 + # stock_quant = self.env['stock.quant'].create({ + # 'location_id': stock_location.id, + # 'product_id': product_id.id, + # 'lot_id': stock_lot.id, + # 'quantity': 1.0 + # }) + + # # 应用该位置 + # bool = stock_quant.action_apply_inventory() + # return stock_quant + def get_stock_lot_name(self): """ 生成功能刀具序列号 @@ -448,13 +472,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel): limit=1, order="id desc" ) - print(stock_lot_id) if not stock_lot_id: num = "%03d" % 1 else: m = int(stock_lot_id.name[-3:]) + 1 num = "%03d" % m - print(num) return code + str(num) From deccb6e3cdc2da85dc32ae4c6b631ef45431f6d2 Mon Sep 17 00:00:00 2001 From: "JIKIMO-YXH\\xianghui" <3437689193@qq.com> Date: Mon, 30 Oct 2023 17:43:28 +0800 Subject: [PATCH 4/5] =?UTF-8?q?1=E3=80=81=E5=88=A0=E9=99=A4=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E7=9A=84=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E7=BB=84=E8=A3=85=E5=8A=9F=E8=83=BD=E5=92=8C=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E5=8A=9F=E8=83=BD=EF=BC=9B2=E3=80=81=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E5=8D=95=E6=8D=AE=E6=9D=A5=E6=BA=90=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E6=8C=89=E9=92=AE=EF=BC=9B3=E3=80=81=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=BB=84=E8=A3=85=E5=8D=95=E7=BC=96=E7=A0=81=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=92=8C=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E7=9A=84=E6=96=B9=E6=B3=95=EF=BC=9B4=E3=80=81?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8F=B7=EF=BC=8C=E7=BB=91=E5=AE=9A=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E4=BA=A7=E5=93=81=E5=BA=8F=E5=88=97=E5=8F=B7?= =?UTF-8?q?=EF=BC=9B5=E3=80=81=E5=AE=8C=E6=88=90=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=90=8E=E7=9A=84=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E5=85=A5=E5=BA=93=E5=88=B0=E4=BD=8D=E7=BD=AE=E3=80=90?= =?UTF-8?q?=E7=BB=84=E8=A3=85=E5=90=8E=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 231 +++++++------------ sf_tool_management/views/tool_base_views.xml | 29 +-- sf_tool_management/wizard/wizard.py | 81 +++---- 3 files changed, 119 insertions(+), 222 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index ff3f1bed..3a9f3264 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -733,10 +733,12 @@ class CAMWorkOrderProgramKnifePlan(models.Model): class FunctionalToolAssembly(models.Model): _name = 'sf.functional.tool.assembly' - _description = '功能刀具组装' + _description = '功能刀具组装单' _order = 'use_tool_time asc' - functional_tool_code = fields.Char(string='功能刀具编码', readonly=True) + assembly_order_code = fields.Char(string='编码', compute='_get_code', readonly=True) + functional_tool_code = fields.Char(string='功能刀具编码', invisible=True) + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) name = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, group_expand='_read_group_functional_tool_type_ids') @@ -787,6 +789,58 @@ class FunctionalToolAssembly(models.Model): chuck_name = fields.Char('夹头名称', readonly=True) 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: + record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_material_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_material_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_material_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_material_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_material_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_material_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 + coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) tool_loading_length = fields.Char(string='装刀长(mm)', readonly=True) new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) @@ -795,11 +849,12 @@ class FunctionalToolAssembly(models.Model): cut_length = fields.Char(string='已切削长度(mm)', readonly=True) cut_number = fields.Char(string='已切削次数', readonly=True) - loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀')], string='装刀任务来源', readonly=True) + loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀'), ('2', '按库存组装')], + string='装刀任务来源', readonly=True) applicant = fields.Char(string='申请人', readonly=True) reason_for_applying = fields.Char(string='申请原因', readonly=True) apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True) - assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装'), ('2', '已出库')], string='组装状态', + assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', default='0', readonly=True) use_tool_time = fields.Datetime(string='用刀时间', readonly=True) production_line_name_id = fields.Many2one('sf.production.line', string='产线名称', readonly=False) @@ -818,155 +873,29 @@ class FunctionalToolAssembly(models.Model): sf_cam_work_order_program_knife_plan_id = fields.Many2one('sf.cam.work.order.program.knife.plan', 'CAM工单程序用刀计划') - def open_sf_cam_work_order_program_knife_plan(self): + @api.depends('loading_task_source') + def _get_code(self): """ - 跳转到CAM工单程序用刀计划界面按钮功能 + 自动生成组装单编码 """ - action = self.env.ref('sf_tool_management.sf_cam_work_order_program_knife_plan_view_act') - result = action.read()[0] - result['domain'] = [('sf_functional_tool_assembly_id', '=', self.id)] - return result - - def open_sf_machine_table_tool_changing_apply(self): - """ - 跳转到机床换刀申请界面按钮功能 - """ - action = self.env.ref('sf_tool_management.sf_machine_table_tool_changing_apply_view_act') - result = action.read()[0] - result['domain'] = [('sf_functional_tool_assembly_id', '=', self.id)] - return result - - def cancel_functional_tool_assembly(self): - """ - 取消功能刀具组装 - :return: - """ - if self.new_former == '0': - # 如果是新刀,则删除功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录的记录 - record = self.env['sf.functional.cutting.tool.entity'].search([ - ('code', '=', self.functional_tool_code)]) - self.env['sf.functional.tool.warning'].search( - [('functional_cutting_tool_id', '=', record.id)]).unlink() - self.env['sf.real.time.distribution.of.functional.tools'].search( - [('functional_cutting_tool_id', '=', record.id)]).unlink() - self.env['sf.inbound.and.outbound.records.of.functional.tools'].search( - [('functional_cutting_tool_id', '=', record.id)]).unlink() - record.unlink() - else: - # 获取功能刀具缓存信息 - record = self.env['sf.functional.cutting.tool.entity.cache'].search([ - ('code', '=', self.functional_tool_code)], limit=1) - # # 删除现有功能刀具列表记录 - # self.env['sf.functional.cutting.tool.entity'].search([ - # ('code', '=', self.functional_tool_code)]).unlink() - # 修改功能刀具列表信息 - self.env['sf.functional.cutting.tool.entity'].search([ - ('code', '=', self.functional_tool_code)]).sudo().write({ - 'code': record.code, - 'name': record.name, - 'mrs_cutting_tool_type_id': record.mrs_cutting_tool_type_id.id, - 'mrs_cutting_tool_model_id': record.mrs_cutting_tool_model_id.id, - 'cutting_tool_integral_model_id': record.cutting_tool_integral_model_id.id, - 'cutting_tool_blade_model_id': record.cutting_tool_blade_model_id.id, - 'cutting_tool_cutterbar_model_id': record.cutting_tool_cutterbar_model_id.id, - 'cutting_tool_cutterpad_model_id': record.cutting_tool_cutterpad_model_id.id, - 'cutting_tool_cutterhandle_model_id': record.cutting_tool_cutterhandle_model_id.id, - 'cutting_tool_cutterhead_model_id': record.cutting_tool_cutterhead_model_id.id, - 'diameter': record.diameter, - 'tool_grade': record.tool_grade, - 'machining_accuracy': record.machining_accuracy, - 'tool_length': record.tool_length, - 'blade_number': record.blade_number, - 'integral_blade_length': record.integral_blade_length, - 'effective_blade_length': record.effective_blade_length, - 'max_life': record.max_life, - 'is_standard': record.is_standard, - 'applicable_range': record.applicable_range, - 'image': record.image, - }) - # 删除功能刀具缓存信息 - self.env['sf.functional.cutting.tool.entity.cache'].search([ - ('code', '=', self.functional_tool_code)]).unlink() - - # 修改功能刀具组装的组装信息 - self.env['sf.functional.tool.assembly'].search([ - ('machine_tool_name_id', '=', self.machine_tool_name_id.id), - ('cutter_spacing_code', '=', self.cutter_spacing_code), - ('assemble_status', '=', '1') - ]).write({ - 'cutting_tool_integral_model_id': None, - 'integral_code_id': None, - 'integral_name': None, - 'sf_tool_brand_id_1': None, - 'cutting_tool_blade_model_id': None, - 'blade_code_id': None, - 'blade_name': None, - 'sf_tool_brand_id_2': None, - 'cutting_tool_cutterbar_model_id': None, - 'bar_code_id': None, - 'bar_name': None, - 'sf_tool_brand_id_3': None, - 'cutting_tool_cutterpad_model_id': None, - 'pad_code_id': None, - 'pad_name': None, - 'sf_tool_brand_id_4': None, - 'cutting_tool_cutterhandle_model_id': None, - 'handle_code_id': None, - 'handle_name': None, - 'sf_tool_brand_id_5': None, - 'cutting_tool_cutterhead_model_id': None, - 'chuck_code_id': None, - 'chuck_name': None, - 'sf_tool_brand_id_6': None, - 'coarse_middle_thin': None, - 'tool_loading_length': None, - 'new_former': None, - 'reference_length': None, - 'cut_time': None, - 'cut_length': None, - 'cut_number': None, - 'assemble_status': '0', - 'tool_loading_person': None, - 'tool_loading_time': None - }) - - def show_popup(self): - """ - 单个功能刀具出库 - :return: - """ - self.env['sf.delivery.of.cargo.from.storage'].search([]).unlink() - - vals = self.env['sf.functional.tool.assembly'].search( - [('check_box_1', '=', True), ('assemble_status', '=', '1')]) - if vals: - for val in vals: - self.env['sf.delivery.of.cargo.from.storage'].create({ - 'functional_tool_code': val.functional_tool_code, - 'name': val.name.id, - 'functional_tool_type_id': val.functional_tool_type_id.id, - 'production_line_name_id': val.production_line_name_id.id, - 'machine_tool_code': val.machine_tool_code, - 'receive_person': val.receive_person, - 'receive_time': val.receive_time}) - else: - self.env['sf.delivery.of.cargo.from.storage'].create({ - 'functional_tool_code': self.functional_tool_code, - 'name': self.name.id, - 'functional_tool_type_id': self.functional_tool_type_id.id, - 'production_line_name_id': self.production_line_name_id.id, - 'machine_tool_code': self.machine_tool_code, - 'receive_person': self.receive_person, - 'receive_time': self.receive_time}) - - return { - 'type': 'ir.actions.act_window', - 'name': '功能刀具出库', - 'res_model': 'sf.delivery.of.cargo.from.storage', - 'view_mode': 'tree', - 'view_type': 'tree', - 'target': 'new' - } + for record in self: + new_time = str(fields.Date.today()) + datetime = new_time[2:4] + new_time[5:7] + new_time[-2:] + functional_tool_assembly = record.env['sf.functional.tool.assembly'].sudo().search( + [('loading_task_source', '=', record.loading_task_source), + ('assembly_order_code', 'like', new_time)], limit=1, order="id desc") + print(functional_tool_assembly) + if not functional_tool_assembly: + num = "%03d" % 1 + else: + m = int(functional_tool_assembly.name[-3:]) + 1 + num = "%03d" % m + if record.loading_task_source == '0': + record.assembly_order_code = 'CAMZZD' + datetime + str(num) + if record.loading_task_source == '1': + record.assembly_order_code = 'JTZZD' + datetime + str(num) + if record.loading_task_source == '2': + record.assembly_order_code = 'MTSZZD' + datetime + str(num) def automated_assembly(self): """ diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 077cb027..6ed278af 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -997,10 +997,11 @@ sf.functional.tool.assembly + - + @@ -1034,13 +1035,8 @@ 'default_whether_standard_tool': None}" attrs="{'invisible': [('assemble_status', '!=', '0')]}" class="btn-primary"/> -