From 63b1f732dba3010901f92b6c3c3ade86ebd541a6 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 25 Nov 2024 11:40:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 4 ++-- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index b01cc465..210a27d0 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 87848e3a..d963d021 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -5,8 +5,8 @@ import requests import os from datetime import datetime # 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 cb29baa6981560dc3ea0bf35ead5d441a17372cd Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 25 Nov 2024 14:31:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=BF=98=E5=8E=9F=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 | 34 +++++++++++++------ sf_manufacturing/models/mrp_workorder.py | 2 +- sf_manufacturing/models/product_template.py | 4 +-- sf_manufacturing/views/mrp_workorder_view.xml | 2 +- sf_sale/models/quick_easy_order.py | 4 +-- sf_sale/models/quick_easy_order_old.py | 4 +-- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index a3d44a5a..a1cc56d2 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -278,7 +278,7 @@ class MrpProduction(models.Model): @api.depends( 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'tool_state', - 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state', 'programming_state') + 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state', 'programming_state', 'is_adjust') def _compute_state(self): for production in self: if not production.state or not production.product_uom_id: @@ -314,11 +314,16 @@ class MrpProduction(models.Model): if not production.workorder_ids or production.is_adjust is True: production.state = 'technology_to_confirmed' else: - production.state = 'confirmed' + if production.is_adjust is True: + production.state = 'technology_to_confirmed' + else: + production.state = 'confirmed' elif production.state == 'pending_cam' and production.schedule_state == '未排': production.state = 'confirmed' elif production.state == 'to_close' and production.schedule_state == '已排': production.state = 'pending_cam' + elif production.state == 'confirmed' and production.is_adjust is True: + production.state = 'technology_to_confirmed' if production.state == 'progress': if all(wo_state not in ('progress', 'done', 'rework', 'scrap') for wo_state in production.workorder_ids.mapped('state')): @@ -1397,7 +1402,7 @@ class MrpProduction(models.Model): def _compute_production_type(self): for production in self: production.production_type = '自动化产线加工' if not production.product_id.is_manual_processing else '人工线下加工' - + @api.model_create_multi def create(self, vals_list): """ @@ -1413,7 +1418,7 @@ class MrpProduction(models.Model): vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id() if not vals.get('procurement_group_id'): product_id = self.env['product.product'].browse(vals['product_id']) - if product_id.product_tmpl_id.single_manufacturing: + if product_id.product_tmpl_id.single_manufacturing: if product_id.id not in product_group_id.keys(): procurement_group_vals = self._prepare_procurement_group_vals(vals) group_id = self.env["procurement.group"].create(procurement_group_vals).id @@ -1423,23 +1428,29 @@ class MrpProduction(models.Model): vals['procurement_group_id'] = product_group_id[product_id.id] return super(MrpProduction, self).create(vals_list) - @api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id', 'procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id') + @api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id', + 'procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id') def _compute_purchase_order_count(self): for production in self: # 找到来源的第一张制造订单的采购组 if production.product_id.product_tmpl_id.single_manufacturing == True: - first_production = self.env['mrp.production'].search([('origin', '=', production.origin), ('product_id', '=', production.product_id.id)], limit=1, order='id asc') - production.purchase_order_count = len(first_production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | - first_production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id) + first_production = self.env['mrp.production'].search( + [('origin', '=', production.origin), ('product_id', '=', production.product_id.id)], limit=1, + order='id asc') + production.purchase_order_count = len( + first_production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | + first_production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id) else: - production.purchase_order_count = len(production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | - production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id) + production.purchase_order_count = len( + production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | + production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id) @api.depends('procurement_group_id', 'procurement_group_id.stock_move_ids.group_id') def _compute_picking_ids(self): for order in self: if order.product_id.product_tmpl_id.single_manufacturing == True: - first_order = self.env['mrp.production'].search([('origin', '=', order.origin), ('product_id', '=', order.product_id.id)], limit=1, order='id asc') + first_order = self.env['mrp.production'].search( + [('origin', '=', order.origin), ('product_id', '=', order.product_id.id)], limit=1, order='id asc') order.picking_ids = self.env['stock.picking'].search([ ('group_id', '=', first_order.procurement_group_id.id), ('group_id', '!=', False), ]) @@ -1450,6 +1461,7 @@ class MrpProduction(models.Model): ]) order.delivery_count = len(order.picking_ids) + class sf_detection_result(models.Model): _name = 'sf.detection.result' _description = "检测结果" diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 2bc90f1d..63afbb18 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1062,7 +1062,7 @@ class ResMrpWorkOrder(models.Model): if workorder.production_id.workorder_ids.filtered(lambda wk: wk.sequence == 0): continue # ===== 对所有按序号排序的非[进行中、完成、返工、取消]状态的工单,除了第一条之外的工单状态都设置为[等待其他工单] ===== - logging.info(workorder.state) + # logging.info(workorder.state) work_ids = workorder.production_id.workorder_ids.filtered( lambda wk: wk.state not in ['done', 'rework', 'cancel']) if not work_ids: diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index ebbf5bd2..f5f685aa 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/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 1faec0ac..53134cc4 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -251,7 +251,7 @@ decoration-danger="tag_type == '重新加工'"/> + attrs="{'invisible': [('rfid_code_old', '!=', False)]}" widget="qrcode_widget"/> 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 d963d021..87848e3a 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -5,8 +5,8 @@ import requests import os from datetime import datetime # 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