From efc4ae31c9a9e2f68b243462e14e09cd7ab35ff6 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Wed, 7 May 2025 11:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E5=A4=96=E5=8D=8F=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/__manifest__.py | 1 + sf_manufacturing/models/__init__.py | 1 + sf_manufacturing/models/mrp_production.py | 1 + sf_manufacturing/models/mrp_workorder.py | 21 +++++++++++++++---- sf_manufacturing/models/purchase_order.py | 2 +- .../models/sf_production_common.py | 2 +- .../models/stock_warehouse_orderpoint.py | 11 ++++++++++ .../views/stock_warehouse_orderpoint.xml | 16 ++++++++++++++ sf_sale/models/sale_order.py | 1 + 9 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 sf_manufacturing/models/stock_warehouse_orderpoint.py create mode 100644 sf_manufacturing/views/stock_warehouse_orderpoint.xml diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 24c8a4b0..855c1990 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -48,6 +48,7 @@ 'views/mrp_workorder_batch_replan.xml', 'views/purchase_order_view.xml', 'views/product_template_views.xml', + 'views/stock_warehouse_orderpoint.xml', ], 'assets': { diff --git a/sf_manufacturing/models/__init__.py b/sf_manufacturing/models/__init__.py index bccaf634..912217c3 100644 --- a/sf_manufacturing/models/__init__.py +++ b/sf_manufacturing/models/__init__.py @@ -18,3 +18,4 @@ from . import quick_easy_order from . import purchase_order from . import quality_check from . import purchase_request_line +from . import stock_warehouse_orderpoint \ No newline at end of file diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index df73fb72..c051126c 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -934,6 +934,7 @@ class MrpProduction(models.Model): cur_request_line.pop('group_id', None) cur_request_line.pop('production_name', None) self.env["purchase.request.line"].create(cur_request_line) + pr.button_approved() # 外协出入库单处理 def get_subcontract_pick_purchase(self): diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 3a9744d9..4c01ec06 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -512,7 +512,7 @@ class ResMrpWorkOrder(models.Model): return result def _get_surface_technics_purchase_ids(self): - domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment'), ('is_subcontract', '=', 'True'), ('state', '!=', 'cancel')] + domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment'), ('state', '!=', 'cancel')] # domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment')] # domain = [('group_id', '=', self.production_id.procurement_group_id.id), ('purchase_type', '=', 'consignment')] purchase_orders = self.env['purchase.order'].search(domain, order='id desc') @@ -1242,6 +1242,12 @@ class ResMrpWorkOrder(models.Model): }] return workorders_values_str + def check_lot_exists(self, picking_id, lot_id): + return bool( + picking_id.move_ids.move_line_ids.filtered( + lambda line: line.lot_id.id == lot_id + ) + ) def _process_compute_state(self): sorted_workorders = sorted(self, key=lambda x: x.sequence) for workorder in sorted_workorders: @@ -1263,10 +1269,17 @@ class ResMrpWorkOrder(models.Model): workorder.state = 'pending' continue # ================= 如果制造订单制造类型为【人工线下加工】========================== + lot_id = workorder.production_id.move_raw_ids.move_line_ids.lot_id + picking_ids = workorder.production_id.picking_ids.filtered( + lambda wk: wk.location_id.name == '外协收料区' and wk.location_dest_id.name == '制造前') + # exists = any( + # move_line.lot_id == lot_id + # for picking in picking_ids + # for move in picking.move_ids + # for move_line in move.move_line_ids + # ) if (workorder.production_id.production_type == '人工线下加工' - and workorder.production_id.schedule_state == '已排' - and len(workorder.production_id.picking_ids.filtered( - lambda w: w.state not in ['done', 'cancel'])) == 0): + and workorder.production_id.schedule_state == '已排' and lot_id): # and workorder.production_id.programming_state == '已编程' if workorder.is_subcontract is True: if workorder.production_id.state == 'rework': diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index 9e11e7c0..879c1f49 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -119,7 +119,7 @@ class PurchaseOrder(models.Model): total_qty = sum(quants.mapped('quantity')) # 计算该位置的总库存量 is_available = total_qty > 0 if not is_available: - continue + raise UserError('请先完成坯料入库') for production_id in productions: work_ids = production_id.workorder_ids.filtered( lambda wk: wk.state not in ['done', 'rework', 'cancel']) diff --git a/sf_manufacturing/models/sf_production_common.py b/sf_manufacturing/models/sf_production_common.py index 1c066bbe..3c4ad8cf 100644 --- a/sf_manufacturing/models/sf_production_common.py +++ b/sf_manufacturing/models/sf_production_common.py @@ -25,7 +25,7 @@ class SfProductionProcessParameter(models.Model): def _compute_service_products(self): for record in self: # 假设取第一条作为主明细 - record.service_products = record.outsourced_service_products.id if record.outsourced_service_products else False + record.service_products = record.outsourced_service_products.ids if record.outsourced_service_products else False def _inverse_service_products(self): for record in self: diff --git a/sf_manufacturing/models/stock_warehouse_orderpoint.py b/sf_manufacturing/models/stock_warehouse_orderpoint.py new file mode 100644 index 00000000..09289f52 --- /dev/null +++ b/sf_manufacturing/models/stock_warehouse_orderpoint.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# Part of SmartGo. See LICENSE file for full copyright and licensing details. +import base64 +from io import BytesIO +from odoo import api, fields, models, SUPERUSER_ID, _ + + +class StockWarehouseOrderpoint(models.Model): + _inherit = 'stock.warehouse.orderpoint' + origin = fields.Char(string='来源') + _order = 'create_date DESC' \ No newline at end of file diff --git a/sf_manufacturing/views/stock_warehouse_orderpoint.xml b/sf_manufacturing/views/stock_warehouse_orderpoint.xml new file mode 100644 index 00000000..810cd22e --- /dev/null +++ b/sf_manufacturing/views/stock_warehouse_orderpoint.xml @@ -0,0 +1,16 @@ + + + + + 补货 + stock.warehouse.orderpoint + + + + + + + + + + \ No newline at end of file diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index d15d9ed8..49bd0264 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -393,6 +393,7 @@ class RePurchaseOrder(models.Model): # route_ids result.append({ "product_id": server_template.product_variant_id.id, + 'related_product': production.product_id.id, "name": production.procurement_group_id.name, "date_required": fields.Datetime.now(), "product_uom_id":server_template.uom_id.id,