From 7b2908defaebc7ea258fd8c9a4984c8fa5800b4c Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 20 Aug 2024 17:52:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E5=BA=9Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 12 +++--- sf_manufacturing/models/mrp_production.py | 45 ++------------------- sf_manufacturing/models/mrp_workorder.py | 2 + sf_manufacturing/models/product_template.py | 4 +- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- 6 files changed, 18 insertions(+), 53 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 6f200926..57cf56b5 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -619,12 +619,12 @@ class Manufacturing_Connect(http.Controller): # if is_free is True: # delivery_workpiece._delivery_avg() # logging.info('agv下发下产线任务下发完成') - if ret['IsComplete'] is True: - # 向AGV任务调度下发下产线任务 - workorders = request.env['mrp.workorder'].browse(workorder_ids) - request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders) - else: - res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'} + # if ret['IsComplete'] is True: + # # 向AGV任务调度下发下产线任务 + # workorders = request.env['mrp.workorder'].browse(workorder_ids) + # request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders) + # else: + # res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'} except RepeatTaskException as e: logging.info('AGVToProduct error:%s' % e) except Exception as e: diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index c4eb21dc..66a4ddc2 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -808,7 +808,8 @@ class MrpProduction(models.Model): 'target': 'new', 'context': { 'default_production_id': self.id, - 'default_programming_state': cloud_programming['programming_state'], + 'default_programming_state': '编程中' if cloud_programming[ + 'programming_state'] != '已下发' else '已下发', 'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False } } @@ -995,6 +996,8 @@ class MrpProduction(models.Model): mo.picking_type_id = picking_type.id mo._assign_picking() mo.reference = mo.picking_id.name + else: + mo.reference = productions.name productions.write({'programming_no': self.programming_no, 'is_remanufacture': True}) productions.procurement_group_id.mrp_production_ids.move_dest_ids.write( {'group_id': self.env['procurement.group'].search([('name', '=', sale_order.name)])}) @@ -1066,46 +1069,6 @@ class MrpProduction(models.Model): production_item) else: productions.programming_state = '编程中' - for production in productions: - origin_production = production.move_dest_ids and production.move_dest_ids[ - 0].raw_material_production_id or False - orderpoint = production.orderpoint_id - if orderpoint and orderpoint.create_uid.id == SUPERUSER_ID and orderpoint.trigger == 'manual': - production.message_post( - body=_('This production order has been created from Replenishment Report.'), - message_type='comment', - subtype_xmlid='mail.mt_note') - elif orderpoint: - production.message_post_with_view( - 'mail.message_origin_link', - values={'self': production, 'origin': orderpoint}, - subtype_id=self.env.ref('mail.mt_note').id) - elif origin_production: - production.message_post_with_view( - 'mail.message_origin_link', - values={'self': production, 'origin': origin_production}, - subtype_id=self.env.ref('mail.mt_note').id) - - ''' - 创建生产计划 - ''' - # 工单耗时 - workorder_duration = 0 - for workorder in productions.workorder_ids: - workorder_duration += workorder.duration_expected - - if sale_order: - # sale_order.mrp_production_ids |= productions - self.env['sf.production.plan'].sudo().with_company(self.company_id).create({ - 'name': productions.name, - 'order_deadline': sale_order.deadline_of_delivery, - 'production_id': productions.id, - 'date_planned_start': productions.date_planned_start, - 'origin': productions.origin, - 'product_qty': productions.product_qty, - 'product_id': productions.product_id.id, - 'state': 'draft', - }) return productions # 在之前的销售单上重新生成制造订单 diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 479a56bc..c49b3c70 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1094,7 +1094,9 @@ class ResMrpWorkOrder(models.Model): # move_out._action_assign() if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress': + print(self.production_id.move_raw_ids) self.move_raw_ids = self.production_id.move_raw_ids + print(self.move_raw_ids) self.move_raw_ids[0].write({ 'materiel_length': self.move_raw_ids[0].product_id.length, 'materiel_width': self.move_raw_ids[0].product_id.width, diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 071f1167..37fa02bd 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index 081807a4..cb1886a1 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -8,8 +8,8 @@ from datetime import datetime import requests from odoo import http from odoo.http import request -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo import models, fields, api from odoo.modules import get_resource_path from odoo.exceptions import ValidationError, UserError diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 3ae65db3..92f6cda2 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # from OCC.Core.GProp import GProp_GProps -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path From 6668e0ee2f32cc92ffe6d7b9d05ef44c61bb138c Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 21 Aug 2024 14:43:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=BF=98=E5=8E=9FOCC=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 11 +++++++---- sf_manufacturing/models/mrp_workorder.py | 6 ------ sf_manufacturing/models/product_template.py | 4 ++-- sf_manufacturing/models/stock.py | 3 ++- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 66a4ddc2..466e9a62 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -987,17 +987,20 @@ class MrpProduction(models.Model): move = self.env['stock.move'].search([('origin', '=', productions.name)], order='id desc') for mo in move: print(mo.id) - if mo.name in ['/', '拉']: + if mo.procure_method == 'make_to_order' and mo.name != productions.name: if mo.name == '/': domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')] elif mo.name == '拉': domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')] picking_type = self.env['stock.picking.type'].search(domain) - mo.picking_type_id = picking_type.id + mo.write({'picking_type_id': picking_type.id}) mo._assign_picking() - mo.reference = mo.picking_id.name else: - mo.reference = productions.name + if mo.reference != productions.name: + mo.reference = productions.name + if mo.production_id: + if mo.production_id != productions: + mo.production_id = False productions.write({'programming_no': self.programming_no, 'is_remanufacture': True}) productions.procurement_group_id.mrp_production_ids.move_dest_ids.write( {'group_id': self.env['procurement.group'].search([('name', '=', sale_order.name)])}) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index c49b3c70..cb1719f4 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1094,9 +1094,7 @@ class ResMrpWorkOrder(models.Model): # move_out._action_assign() if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress': - print(self.production_id.move_raw_ids) self.move_raw_ids = self.production_id.move_raw_ids - print(self.move_raw_ids) self.move_raw_ids[0].write({ 'materiel_length': self.move_raw_ids[0].product_id.length, 'materiel_width': self.move_raw_ids[0].product_id.width, @@ -1266,7 +1264,6 @@ class ResMrpWorkOrder(models.Model): 'is_trayed': False }) - # 将FTP的检测报告文件下载到临时目录 def download_reportfile_tmp(self, workorder, reportpath): logging.info('reportpath/ftp地址:%s' % reportpath) @@ -1661,7 +1658,6 @@ class WorkPieceDelivery(models.Model): agv_scheduling_id = fields.Many2one('sf.agv.scheduling', 'AGV任务调度') - @api.model def create(self, vals): if vals.get('route_id') and vals.get('type') is None: @@ -1751,7 +1747,6 @@ class WorkPieceDelivery(models.Model): 'default_confirm_button': '确认配送' }} - # 验证agv站点是否可用 def _check_avgsite_state(self): is_free = False @@ -1856,7 +1851,6 @@ class WorkPieceDelivery(models.Model): obj.delivery_duration = 0.0 - class CMMprogram(models.Model): _name = 'sf.cmm.program' _description = "CMM程序" diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 37fa02bd..071f1167 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index db07ab91..f53d7056 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -178,7 +178,8 @@ class StockRule(models.Model): # create the move as SUPERUSER because the current user may not have the rights to do it (mto product # launched by a sale for example) logging.info(moves_values) - moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(moves_values) + moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create( + moves_values) logging.info(moves) # Since action_confirm launch following procurement_group we should activate it. moves._action_confirm() diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index cb1886a1..081807a4 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -8,8 +8,8 @@ from datetime import datetime import requests from odoo import http from odoo.http import request -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file from odoo import models, fields, api from odoo.modules import get_resource_path from odoo.exceptions import ValidationError, UserError diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 92f6cda2..3ae65db3 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # from OCC.Core.GProp import GProp_GProps -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path From e893abd83ec7d38a2baf9ce9572610e9c6ab4156 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 21 Aug 2024 14:46:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 57cf56b5..6f200926 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -619,12 +619,12 @@ class Manufacturing_Connect(http.Controller): # if is_free is True: # delivery_workpiece._delivery_avg() # logging.info('agv下发下产线任务下发完成') - # if ret['IsComplete'] is True: - # # 向AGV任务调度下发下产线任务 - # workorders = request.env['mrp.workorder'].browse(workorder_ids) - # request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders) - # else: - # res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'} + if ret['IsComplete'] is True: + # 向AGV任务调度下发下产线任务 + workorders = request.env['mrp.workorder'].browse(workorder_ids) + request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders) + else: + res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'} except RepeatTaskException as e: logging.info('AGVToProduct error:%s' % e) except Exception as e: