From c536dde2cc978892293b898bc4d5a8eb48a2f2dd Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 16 Jul 2024 17:24:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=B3=A8=E9=87=8A=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/res_config_setting.py | 1 - sf_manufacturing/models/mrp_production.py | 40 ++++++++++--------- sf_manufacturing/models/mrp_workorder.py | 8 +++- sf_manufacturing/models/product_template.py | 4 +- .../views/mrp_production_addional_change.xml | 7 ++-- sf_manufacturing/wizard/rework_wizard.py | 5 ++- .../wizard/rework_wizard_views.xml | 3 +- sf_mrs_connect/controllers/controllers.py | 33 +++++++-------- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- 10 files changed, 62 insertions(+), 47 deletions(-) diff --git a/sf_machine_connect/models/res_config_setting.py b/sf_machine_connect/models/res_config_setting.py index 78d08003..16cc4d77 100644 --- a/sf_machine_connect/models/res_config_setting.py +++ b/sf_machine_connect/models/res_config_setting.py @@ -8,7 +8,6 @@ _logger = logging.getLogger(__name__) class ResBFMConfigSettings(models.TransientModel): _inherit = 'res.config.settings' - lost_agent_id = fields.Char('22') bfm_url = fields.Selection( [("https://bfm.cs.jikimo.com", "开发环境(https://bfm.cs.jikimo.com)"), ("https://bfm.t.jikimo.com", "测试环境(https://bfm.t.jikimo.com)"), diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index be35e436..4a0e6bb9 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -129,13 +129,16 @@ class MrpProduction(models.Model): if production.state == 'progress': if all(wo_state not in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')): production.state = 'pending_cam' - if production.state == 'pending_cam': - if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')): - production.state = 'done' + # if production.state == 'pending_cam': + # if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')): + # production.state = 'done' if any( ( - wo.test_results == '返工' and wo.state == 'done' and programming_state == '编程中') or wo.state == 'rework' or ( - wo.is_rework is True and wo.state == 'done') for wo in + wo.test_results == '返工' and wo.state == 'done' and production.programming_state == '已编程') or ( + wo.state == 'rework' and production.programming_state == '编程中') or ( + wo.is_rework is True and wo.state == 'done' and production.programming_state in ['编程中', + '已编程']) + for wo in production.workorder_ids): production.state = 'rework' @@ -198,8 +201,8 @@ class MrpProduction(models.Model): production.write({'programming_state': '已编程未下发' if item[ 'programming_state'] == '已编程' else '编程中'}) else: - self.write({'programming_state': '已编程未下发' if item[ - 'programming_state'] == '已编程' else '编程中'}) + return item['programming_state'] + else: raise UserError(ret['message']) except Exception as e: @@ -760,8 +763,11 @@ class MrpProduction(models.Model): # 返工 def button_rework(self): - if self.programming_state != '已编程': - self._cron_get_programming_state() + cloud_programming_state = None + if self.programming_state != '已编程' and self.reprogramming_num >= 1: + cloud_programming_state = self._cron_get_programming_state() + logging.info('cloud_programming_state:%s' % cloud_programming_state) + logging.info('programming_state:%s' % self.programming_state) return { 'name': _('返工'), 'type': 'ir.actions.act_window', @@ -771,8 +777,12 @@ class MrpProduction(models.Model): 'context': { 'default_production_id': self.id, 'default_product_id': self.product_id.id, - 'default_programming_state': self.programming_state, - 'default_is_reprogramming': True if self.programming_state in ['已编程'] else False + 'default_programming_state': self.programming_state if cloud_programming_state is not None else cloud_programming_state, + 'default_is_reprogramming': False if (cloud_programming_state in ['编程中', + '待编程'] and self.programming_state in [ + '编程中']) + or (cloud_programming_state in [ + '已编程'] and self.programming_state in ['已编程未下发']) else True } } @@ -807,13 +817,7 @@ class MrpProduction(models.Model): lambda m1: m1.state != 'rework' and m1.processing_panel == rework_workorder[0].processing_panel) if not new_pancel_workorder.cnc_ids: production.get_new_program(rework_workorder[0].processing_panel) - rework_production = self.env['mrp.production'].search( - [('state', '=', 'rework'), ('programming_no', '=', production.programming_no)]) - if rework_production: - rework_production.workorder_ids.filtered( - lambda m2: m2.state != 'rework' and m2.processing_panel == rework_workorder[ - 0].processing_panel and m2.routing_type == '装夹预调').write({'state': 'ready'}) - rework_production.write({'state': 'progress'}) + production.write({'state': 'progress', 'programming_state': '已下发'}) # 从cloud获取重新编程过的最新程序 def get_new_program(self, processing_panel): diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index b6571a04..6da74cbc 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -827,6 +827,7 @@ class ResMrpWorkOrder(models.Model): re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id), ('processing_panel', '=', workorder.processing_panel), ('is_rework', '=', True), ('state', 'in', ['done', 'rework'])]) + logging.info('re_work:%s' % re_work.state) if workorder.state not in ['cancel', 'progress', 'rework']: logging.info('工序:%s' % workorder.routing_type) logging.info('状态:%s' % workorder.state) @@ -840,10 +841,14 @@ class ResMrpWorkOrder(models.Model): # if re_work: # workorder.state = 'rework' if workorder.production_id.state == 'rework': - if (workorder.routing_type == 'CNC加工' and re_work.state == 'done') or ( + if (workorder.routing_type == 'CNC加工' and workorder.state == 'done') or ( workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '编程中' and re_work): logging.info('面111:%s' % workorder.processing_panel) workorder.state = 'waiting' + elif workorder.production_id.state == 'progress': + logging.info('面222:%s' % workorder.processing_panel) + if workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已下发' and re_work: + workorder.state = 'ready' # else: # if workorder.state not in ['cancel', 'rework']: # workorder.state = 'rework' @@ -998,6 +1003,7 @@ class ResMrpWorkOrder(models.Model): 'detailed_reason': record.detailed_reason, 'processing_panel': record.processing_panel, 'routing_type': record.routing_type, + 'handle_result': '待处理' if record.test_results == '返工' or record.is_rework is True else '', 'test_results': record.test_results, 'test_report': record.detection_report})]}) if record.routing_type == '解除装夹': diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index f292d694..4d05de81 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -7,8 +7,8 @@ import os from odoo import models, fields, api, _ from odoo.exceptions import ValidationError 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/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index ee767897..9ee96732 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -120,9 +120,9 @@