Merge branch 'refs/heads/release/release_2.7' into feature/part_number

# Conflicts:
#	sf_manufacturing/models/mrp_workorder.py
This commit is contained in:
liaodanlong
2025-01-08 11:26:16 +08:00
2 changed files with 28 additions and 16 deletions

View File

@@ -2,7 +2,6 @@ import re
import json import json
import logging import logging
import base64 import base64
import traceback
import urllib.parse import urllib.parse
from datetime import date from datetime import date
from datetime import datetime, timedelta from datetime import datetime, timedelta
@@ -17,7 +16,8 @@ from odoo.addons.sf_base.commons.common import Common
from odoo.exceptions import UserError, ValidationError from odoo.exceptions import UserError, ValidationError
from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
_logger = logging.getLogger(__name__)
class ResMrpWorkOrder(models.Model): class ResMrpWorkOrder(models.Model):
_inherit = 'mrp.workorder' _inherit = 'mrp.workorder'
_order = 'sequence asc' _order = 'sequence asc'
@@ -275,22 +275,34 @@ class ResMrpWorkOrder(models.Model):
def _compute_surface_technics_purchase_ids(self): def _compute_surface_technics_purchase_ids(self):
for order in self: for order in self:
if order.routing_type == '表面工艺' and order.state not in ['cancel']: if order.routing_type == '表面工艺' and order.state not in ['cancel']:
domain = [('purchase_type', '=', 'consignment'), # if order.production_id.production_type == '自动化产线加工':
('origin', 'like', '%' + self.production_id.name + '%'), # domain = [('programming_no', '=', order.production_id.programming_no)]
# else:buzhdiao
# domain = [('origin', '=', order.production_id.origin)]
# production_programming = self.env['mrp.production'].search(domain, order='name asc')
# production_list = [production.name for production in production_programming]
# production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False)
# technology_design = self.env['sf.technology.design'].search(
# [('process_parameters_id', '=', order.surface_technics_parameters_id.id),
# ('production_id', '=', order.production_id.id)])
# if technology_design.is_auto is False:
# domain = [('origin', '=', order.production_id.name)]
# else:
domain = [('purchase_type', '=', 'consignment'), ('origin', '=', order.production_id.name),
('state', '!=', 'cancel')] ('state', '!=', 'cancel')]
purchase = self.env['purchase.order'].search(domain) purchase = self.env['purchase.order'].search(domain)
order.surface_technics_purchase_count = 0 purchase_num = 0
if not purchase: if not purchase:
order.surface_technics_purchase_count = 0 order.surface_technics_purchase_count = 0
for po in purchase: for po in purchase:
if any( for line in po.order_line:
line.product_id and line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id:
for line in po.order_line): if line.product_qty == 1:
order.surface_technics_purchase_count = 1 purchase_num += 1
order.surface_technics_purchase_count = purchase_num
else: else:
order.surface_technics_purchase_count = 0 order.surface_technics_purchase_count = 0
def action_view_surface_technics_purchase(self): def action_view_surface_technics_purchase(self):
self.ensure_one() self.ensure_one()
# if self.routing_type == '表面工艺': # if self.routing_type == '表面工艺':
@@ -1285,7 +1297,7 @@ class ResMrpWorkOrder(models.Model):
raise UserError('请先完成该工单的工艺外协再进行操作') raise UserError('请先完成该工单的工艺外协再进行操作')
# 表面工艺外协,最后一张工单 # 表面工艺外协,最后一张工单
workorders = self.production_id.workorder_ids workorders = self.production_id.workorder_ids
subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence') subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True).sorted('sequence')
if self == subcontract_workorders[-1]: if self == subcontract_workorders[-1]:
# 给下一个库存移动就绪 # 给下一个库存移动就绪
self.move_subcontract_workorder_ids[0].move_dest_ids._action_done() self.move_subcontract_workorder_ids[0].move_dest_ids._action_done()
@@ -1309,8 +1321,8 @@ class ResMrpWorkOrder(models.Model):
is_production_id = False is_production_id = False
rework_workorder = record.production_id.workorder_ids.filtered(lambda p: p.state == 'rework') rework_workorder = record.production_id.workorder_ids.filtered(lambda p: p.state == 'rework')
done_workorder = record.production_id.workorder_ids.filtered(lambda p1: p1.state in ['done']) done_workorder = record.production_id.workorder_ids.filtered(lambda p1: p1.state in ['done'])
if (len(rework_workorder) + len(done_workorder) == len(record.production_id.workorder_ids.filtered(lambda wo: wo.state != 'cancel'))) or ( if (len(rework_workorder) + len(done_workorder) == len(record.production_id.workorder_ids)) or (
len(done_workorder) == len(record.production_id.workorder_ids.filtered(lambda wo: wo.state != 'cancel'))): len(done_workorder) == len(record.production_id.workorder_ids)):
is_production_id = True is_production_id = True
if record.routing_type in ['解除装夹'] or ( if record.routing_type in ['解除装夹'] or (
record.is_rework is True and record.routing_type in ['装夹预调']): record.is_rework is True and record.routing_type in ['装夹预调']):

View File

@@ -605,10 +605,10 @@ class StockPicking(models.Model):
sale_info = self.env['sale.order'].sudo().search( sale_info = self.env['sale.order'].sudo().search(
[('name', '=', sale_name)]) [('name', '=', sale_name)])
else: else:
production_list = self.env['mrp.production'].sudo().search( sale_order_line = self.env['sale.order.line'].sudo().search(
[('product_id', '=', product_id.id)]) [('product_id', '=', product_id.id)])
if production_list: if sale_order_line:
sale_info = production_list[0].sale_order_id sale_info = sale_order_line[0].order_id
if sale_info: if sale_info:
item.sale_order_id = sale_info.id item.sale_order_id = sale_info.id
item.retrospect_ref = sale_info.order_code item.retrospect_ref = sale_info.order_code