From 804bdb60e886de7440d124a85c996782792a8521 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 29 Aug 2024 14:21:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=96=E5=8D=8F=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 4 +- sf_manufacturing/models/mrp_workorder.py | 9 +--- sf_manufacturing/models/product_template.py | 4 +- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- sf_sale/models/sale_order.py | 47 ++++++++++----------- 6 files changed, 32 insertions(+), 40 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 3b72702d..6f6e8826 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -1097,9 +1097,9 @@ class MrpProduction(models.Model): ('is_subcontract', '=', True)]) if scarp_process_parameter_workorder: production_programming = self.env['mrp.production'].search( - [('programming_no', '=', self.programming_no), ('is_remanufacture', '=', False)], order='name asc') + [('programming_no', '=', self.programming_no), ('id', '!=', productions.id)], order='name asc') production_list = [production.name for production in production_programming] - purchase_orders = self.env['purchase.order'].search([('origin', '=', ','.join(production_list))]) + purchase_orders = self.env['purchase.order'].search([('origin', 'ilike', ','.join(production_list))]) for purchase_item in purchase_orders.order_line: for process_item in scarp_process_parameter_workorder: if purchase_item.product_id.categ_type == '表面工艺': diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index baf516a3..f9998587 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -184,17 +184,12 @@ class ResMrpWorkOrder(models.Model): if order.routing_type == '表面工艺': production_programming = self.env['mrp.production'].search( [('programming_no', '=', order.production_id.programming_no)], order='name asc') + production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False) production_list = [production.name for production in production_programming] purchase = self.env['purchase.order'].search([('origin', '=', ','.join(production_list))]) for line in purchase.order_line: if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id and line.product_qty == len( - production_programming): - # server_product = self.env['product.template'].search( - # [('server_product_process_parameters_id', '=', pp.id), - # ('detailed_type', '=', 'service')]) - # purchase_order_line = self.env['purchase.order.line'].search( - # [('product_id', '=', server_product.id), ('product_qty', '=', len(production_programming))]) - # if purchase_order_line: + production_no_remanufacture): order.surface_technics_purchase_count = len(purchase) else: order.surface_technics_purchase_count = 0 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_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 diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 8e92040b..d19a3b02 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -225,45 +225,42 @@ class RePurchaseOrder(models.Model): raise UserError('请对【产品】中的【税】进行选择') def get_purchase_order(self, consecutive_process_parameters, production, product_id_to_production_names): - is_exist = True server_product_process = [] production_process = product_id_to_production_names.get( production.product_id.id) for pp in consecutive_process_parameters: if pp.gain_way == '外协': - server_product = self.env['product.template'].search( + server_template = self.env['product.template'].search( [('server_product_process_parameters_id', '=', pp.id), ('detailed_type', '=', 'service')]) purchase_order_line = self.env['purchase.order.line'].search( - [('product_id', '=', server_product.id), ('product_qty', '=', len(production_process))]) + [('product_id', '=', server_template.product_variant_id.id), + ('product_qty', '=', len(production_process))], limit=1, order='id desc') if not purchase_order_line: - is_exist = False server_product_process.append((0, 0, { - 'product_id': server_product.product_variant_id.id, + 'product_id': server_template.product_variant_id.id, 'product_qty': len(production_process), - 'product_uom': server_product.uom_id.id + 'product_uom': server_template.uom_id.id })) else: for item in purchase_order_line: - purchase_order = self.env['purchase.order'].search( - [('state', '=', 'draft'), ('origin', 'ilike', production.name), - ('id', '=', item.order_id.id)]) - if not purchase_order: - is_exist = False - server_product_process.append((0, 0, { - 'product_id': server_product.product_variant_id.id, - 'product_qty': len(production_process), - 'product_uom': server_product.uom_id.id - })) - if is_exist is False: - purchase_order = self.env['purchase.order'].search( - [('state', '=', 'draft'), ('origin', '=', ','.join(production_process))]) - if not purchase_order or len(purchase_order) >= 1: - self.env['purchase.order'].sudo().create({ - 'partner_id': server_product.seller_ids.partner_id.id, - 'origin': ','.join(production_process), - 'state': 'draft', - 'order_line': server_product_process}) + if production.name in production_process: + purchase_order = self.env['purchase.order'].search( + [('state', '=', 'draft'), ('origin', '=', ','.join(production_process)), + ('id', '=', item.order_id.id)]) + if not purchase_order: + server_product_process.append((0, 0, { + 'product_id': server_template.product_variant_id.id, + 'product_qty': len(production_process), + 'product_uom': server_template.uom_id.id + })) + if server_product_process: + self.env['purchase.order'].sudo().create({ + 'partner_id': server_template.seller_ids.partner_id.id, + 'origin': ','.join(production_process), + 'state': 'draft', + 'order_line': server_product_process}) + # self.env.cr.commit() @api.onchange('order_line') def _onchange_order_line(self):