From 098e8c25189cc6340174b7afb0599d969c8fb874 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Fri, 20 Dec 2024 17:22:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E5=B7=A5=E5=BA=8F?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 7bfc0abb..7322d75c 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -955,10 +955,11 @@ class MrpProduction(models.Model): work_ids = workorder_ids.filtered(lambda item: item.sequence == 0) # 对工单进行逐个插入 for work_id in work_ids: - for order_id in rec.workorder_ids.filtered(lambda item: item.sequence > 0): - if work_id.name == order_id.name and work_id.processing_panel == order_id.processing_panel: - work_id.sequence = order_id.sequence + 1 - break + order_rework_ids = rec.workorder_ids.filtered( + lambda item: (item.sequence > 0 and work_id.name == item.name + and work_id.processing_panel == item.processing_panel)) + order_rework_ids = sorted(order_rework_ids, key=lambda item: item.sequence, reverse=True) + work_id.sequence = order_rework_ids[0].sequence + 1 # 对该工单之后的工单工序进行加一 work_order_ids = rec.workorder_ids.filtered( lambda item: item.sequence >= work_id.sequence and item.id != work_id.id) From 0e7e7af85a0820b407905083fe0f08513e2adc20 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 23 Dec 2024 13:46:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E9=94=80?= =?UTF-8?q?=E5=94=AE=E8=AE=A2=E5=8D=95=E7=8A=B6=E6=80=81=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=E5=A4=B9=E5=85=B7=E7=89=A9=E6=96=99?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=9A=84=E6=89=98=E7=9B=98=E5=8F=AF=E7=94=A8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=EF=BC=9B3=E3=80=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E5=BC=80=E5=A7=8B=E6=8C=89=E9=94=AE=EF=BC=9B?= =?UTF-8?q?4=E3=80=81=E4=BC=98=E5=8C=96=E9=87=87=E8=B4=AD=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E9=87=87=E8=B4=AD=E7=B1=BB=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E4=BE=9B=E8=B4=A7=E6=96=B9=E5=BC=8F=E5=92=8C=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=97=B6=E6=98=AF=E5=90=A6=E5=A4=96=E5=8D=8F?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=80=89=E6=8B=A9=E5=AF=B9=E5=BA=94=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E7=B1=BB=E5=9E=8B=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bf_connect/models/process_status.py | 2 ++ sf_manufacturing/models/mrp_workorder.py | 10 ++++--- .../views/mrp_production_addional_change.xml | 4 +-- sf_manufacturing/views/mrp_workorder_view.xml | 9 +++---- sf_sale/models/sale_order.py | 26 ++++++++++++++++--- .../models/maintenance_equipment.py | 2 +- 6 files changed, 37 insertions(+), 16 deletions(-) diff --git a/sf_bf_connect/models/process_status.py b/sf_bf_connect/models/process_status.py index 09fecfae..69eb84f1 100644 --- a/sf_bf_connect/models/process_status.py +++ b/sf_bf_connect/models/process_status.py @@ -36,6 +36,8 @@ class StatusChange(models.Model): # 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法) try: res = super(StatusChange, self).action_confirm() + # 修改销售订单状态为【加工中】 + self.write({'state': 'processing'}) logging.info('原生方法返回结果:%s' % res) # 原有方法执行后,进行额外的操作(如调用外部API) process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 52fa30c8..410f8d1b 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -138,7 +138,8 @@ class ResMrpWorkOrder(models.Model): is_subcontract = fields.Boolean(string='是否外协') surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数") - picking_ids = fields.Many2many('stock.picking', string='外协出入库单', compute='_compute_surface_technics_picking_ids') + picking_ids = fields.Many2many('stock.picking', string='外协出入库单', + compute='_compute_surface_technics_picking_ids') purchase_id = fields.Many2many('purchase.order', string='外协采购单') surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids') @@ -327,7 +328,7 @@ class ResMrpWorkOrder(models.Model): 'view_mode': 'form', } return result - + def _get_surface_technics_purchase_ids(self): domain = [('origin', '=', self.production_id.name), ('purchase_type', '=', 'consignment')] purchase_orders = self.env['purchase.order'].search(domain) @@ -1429,6 +1430,8 @@ class ResMrpWorkOrder(models.Model): rfid_code = workorder.rfid_code workorder.write({'rfid_code_old': rfid_code, 'rfid_code': False}) + self.env['stock.lot'].sudo().search([('rfid', '=', rfid_code)]).write( + {'tool_material_status': '可用'}) if workorder.rfid_code: raise ValidationError(f'【{workorder.name}】工单解绑失败,请重新点击完成按钮!!!') # workorder.rfid_code_old = rfid_code @@ -1567,7 +1570,7 @@ class ResMrpWorkOrder(models.Model): 'default_confirm_button': '确认解除', # 'default_feeder_station_start_id': feeder_station_start_id, }} - + move_subcontract_workorder_ids = fields.One2many('stock.move', 'subcontract_workorder_id', string='组件') @@ -1778,6 +1781,7 @@ class SfWorkOrderBarcodes(models.Model): if workorder_rfid: for item in workorder_rfid: item.write({'rfid_code': barcode}) + lot.sudo().write({'tool_material_status': '在用'}) logging.info("Rfid[%s]绑定成功!!!" % barcode) else: raise UserError('该Rfid【%s】绑定的是【%s】, 不是托盘!!!' % (barcode, lot.product_id.name)) diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index d08ff81f..f144a91c 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -441,9 +441,7 @@