From 7b2908defaebc7ea258fd8c9a4984c8fa5800b4c Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 20 Aug 2024 17:52:36 +0800 Subject: [PATCH] =?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