优化外协采购和出入库单(工艺退回调整)
This commit is contained in:
@@ -718,7 +718,7 @@ class MrpProduction(models.Model):
|
|||||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
||||||
for i, workorder in enumerate(sorted_workorders):
|
for i, workorder in enumerate(sorted_workorders):
|
||||||
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
||||||
if workorder.sequence == 1:
|
if i == 0:
|
||||||
consecutive_workorders.append(workorder)
|
consecutive_workorders.append(workorder)
|
||||||
elif workorder.sequence == sorted_workorders[
|
elif workorder.sequence == sorted_workorders[
|
||||||
i - 1].sequence + 1 and workorder.supplier_id.id == sorted_workorders[i - 1].supplier_id.id:
|
i - 1].sequence + 1 and workorder.supplier_id.id == sorted_workorders[i - 1].supplier_id.id:
|
||||||
@@ -726,7 +726,7 @@ class MrpProduction(models.Model):
|
|||||||
else:
|
else:
|
||||||
# 处理连续组,如果它不为空
|
# 处理连续组,如果它不为空
|
||||||
if consecutive_workorders:
|
if consecutive_workorders:
|
||||||
# 创建出库拣货单和采购订单
|
# 创建外协出入库单和采购订单
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
@@ -740,7 +740,7 @@ class MrpProduction(models.Model):
|
|||||||
i - 1].supplier_id.id:
|
i - 1].supplier_id.id:
|
||||||
consecutive_workorders = [workorder]
|
consecutive_workorders = [workorder]
|
||||||
else:
|
else:
|
||||||
# 立即创建出库拣货单和采购订单
|
# 立即创建外协出入库单和采购订单
|
||||||
self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
||||||
self.env['purchase.order'].get_purchase_order(workorder, production,
|
self.env['purchase.order'].get_purchase_order(workorder, production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
@@ -818,6 +818,17 @@ class MrpProduction(models.Model):
|
|||||||
self._reset_work_order_sequence1(k)
|
self._reset_work_order_sequence1(k)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
#需对不连续工单对应的采购单和外协出入库单做处理
|
||||||
|
def _reset_subcontract_pick_purchase(self):
|
||||||
|
for item in self:
|
||||||
|
workorder_sf = item.workorder_ids.filtered(lambda sf: sf.routing_type == '表面工艺')
|
||||||
|
for i, workorder in enumerate(workorder_sf):
|
||||||
|
if i == 0:
|
||||||
|
continue
|
||||||
|
elif workorder.sequence != workorder_sf[i - 1].sequence + 1:
|
||||||
|
# workorder.picking_ids.move_ids = False
|
||||||
|
workorder.picking_ids = False
|
||||||
|
|
||||||
def _reset_work_order_sequence(self):
|
def _reset_work_order_sequence(self):
|
||||||
"""
|
"""
|
||||||
工单工序排序方法(新)
|
工单工序排序方法(新)
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
tag_type = fields.Selection([("重新加工", "重新加工")], string="标签", tracking=True)
|
tag_type = fields.Selection([("重新加工", "重新加工")], string="标签", tracking=True)
|
||||||
|
|
||||||
def _compute_default_construction_period_status(self):
|
def _compute_default_construction_period_status(self):
|
||||||
need_list=['pending', 'waiting', 'ready', 'progress', 'to be detected','done']
|
need_list = ['pending', 'waiting', 'ready', 'progress', 'to be detected', 'done']
|
||||||
try:
|
try:
|
||||||
if self.state not in need_list:
|
if self.state not in need_list:
|
||||||
return False
|
return False
|
||||||
@@ -154,9 +154,9 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
hours = self.get_hours_diff()
|
hours = self.get_hours_diff()
|
||||||
if hours >= 12:
|
if hours >= 12:
|
||||||
return '正常'
|
return '正常'
|
||||||
elif hours > 0 and hours < 12 and self.state!='done':
|
elif hours > 0 and hours < 12 and self.state != 'done':
|
||||||
return '预警'
|
return '预警'
|
||||||
elif hours > 0 and hours < 12 and self.state=='done':
|
elif hours > 0 and hours < 12 and self.state == 'done':
|
||||||
return '正常'
|
return '正常'
|
||||||
else:
|
else:
|
||||||
return '已逾期'
|
return '已逾期'
|
||||||
@@ -168,7 +168,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
def _compute_construction_period_status(self):
|
def _compute_construction_period_status(self):
|
||||||
for worker in self:
|
for worker in self:
|
||||||
construction_period_status = worker._compute_default_construction_period_status()
|
construction_period_status = worker._compute_default_construction_period_status()
|
||||||
if construction_period_status and worker.construction_period_status!=construction_period_status:
|
if construction_period_status and worker.construction_period_status != construction_period_status:
|
||||||
worker.construction_period_status = construction_period_status
|
worker.construction_period_status = construction_period_status
|
||||||
|
|
||||||
construction_period_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')],
|
construction_period_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')],
|
||||||
@@ -199,14 +199,17 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
func(records)
|
func(records)
|
||||||
# 增加页码
|
# 增加页码
|
||||||
page_number += 1
|
page_number += 1
|
||||||
def run_compute_construction_period_status(self,records):
|
|
||||||
|
def run_compute_construction_period_status(self, records):
|
||||||
records._compute_construction_period_status()
|
records._compute_construction_period_status()
|
||||||
|
|
||||||
def _corn_update_construction_period_status(self):
|
def _corn_update_construction_period_status(self):
|
||||||
need_list=['pending', 'waiting', 'ready', 'progress', 'to be detected']
|
need_list = ['pending', 'waiting', 'ready', 'progress', 'to be detected']
|
||||||
# need_list = [
|
# need_list = [
|
||||||
# 'progress',
|
# 'progress',
|
||||||
# 'to be detected']
|
# 'to be detected']
|
||||||
self.get_page_all_records('mrp.workorder',self.run_compute_construction_period_status,[('state', 'in', need_list)],100)
|
self.get_page_all_records('mrp.workorder', self.run_compute_construction_period_status,
|
||||||
|
[('state', 'in', need_list)], 100)
|
||||||
|
|
||||||
def get_hours_diff(self):
|
def get_hours_diff(self):
|
||||||
# 获取当前日期和时间
|
# 获取当前日期和时间
|
||||||
@@ -230,16 +233,16 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
def _compute_surface_technics_picking_ids(self):
|
def _compute_surface_technics_picking_ids(self):
|
||||||
for workorder in self:
|
for workorder in self:
|
||||||
if workorder.routing_type == '表面工艺':
|
if workorder.routing_type == '表面工艺':
|
||||||
domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel'])]
|
domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel']),
|
||||||
|
('partner_id', '!=', False)]
|
||||||
previous_workorder = self.env['mrp.workorder'].search(
|
previous_workorder = self.env['mrp.workorder'].search(
|
||||||
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
||||||
('production_id', '=', workorder.production_id.id)])
|
('production_id', '=', workorder.production_id.id)])
|
||||||
if previous_workorder:
|
if previous_workorder:
|
||||||
|
if previous_workorder.supplier_id != workorder.supplier_id:
|
||||||
process_product = self.env['product.template']._get_process_parameters_product(
|
process_product = self.env['product.template']._get_process_parameters_product(
|
||||||
previous_workorder.surface_technics_parameters_id)
|
previous_workorder.surface_technics_parameters_id)
|
||||||
domain += [('partner_id', '=', process_product.partner_id.id)]
|
domain += [('partner_id', '=', process_product.partner_id.id)]
|
||||||
else:
|
|
||||||
domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
|
||||||
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
|
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
|
||||||
workorder.surface_technics_picking_count = len(picking_ids)
|
workorder.surface_technics_picking_count = len(picking_ids)
|
||||||
workorder.picking_ids = picking_ids.ids
|
workorder.picking_ids = picking_ids.ids
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError
|
|||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
|
|
||||||
|
|
||||||
from OCC.Extend.DataExchange import read_step_file
|
# from OCC.Extend.DataExchange import read_step_file
|
||||||
from OCC.Extend.DataExchange import write_stl_file
|
# from OCC.Extend.DataExchange import write_stl_file
|
||||||
|
|
||||||
|
|
||||||
class ResProductMo(models.Model):
|
class ResProductMo(models.Model):
|
||||||
|
|||||||
@@ -366,7 +366,6 @@ class StockRule(models.Model):
|
|||||||
process_parameter))
|
process_parameter))
|
||||||
productions.technology_design_ids = technology_design_values
|
productions.technology_design_ids = technology_design_values
|
||||||
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@@ -649,14 +648,13 @@ class StockPicking(models.Model):
|
|||||||
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
||||||
if len(sorted_workorders_arr) > 1:
|
if len(sorted_workorders_arr) > 1:
|
||||||
sorted_workorders_arr = sorted_workorders_arr[0]
|
sorted_workorders_arr = sorted_workorders_arr[0]
|
||||||
stock_picking = self.env['stock.picking'].search(
|
stock_picking = self.env['stock.picking'].search([('origin', '=', item.name), ('name', 'ilike', 'OCOUT')])
|
||||||
[('origin', '=', sorted_workorders_arr.production_id.name), ('name', 'ilike', 'OCOUT')])
|
if not stock_picking or sorted_workorders_arr:
|
||||||
if not stock_picking:
|
|
||||||
for sorted_workorders in sorted_workorders_arr:
|
for sorted_workorders in sorted_workorders_arr:
|
||||||
# pick_ids = []
|
# pick_ids = []
|
||||||
if not sorted_workorders.picking_ids:
|
if not sorted_workorders.picking_ids:
|
||||||
outcontract_stock_move = self.env['stock.move'].search([('production_id', '=', item.id)])
|
# outcontract_stock_move = self.env['stock.move'].search([('production_id', '=', item.id)])
|
||||||
if not outcontract_stock_move:
|
# if not outcontract_stock_move:
|
||||||
new_picking = True
|
new_picking = True
|
||||||
location_id = self.env['stock.location'].search(
|
location_id = self.env['stock.location'].search(
|
||||||
[('barcode', 'ilike', 'VL-SPOC')]).id,
|
[('barcode', 'ilike', 'VL-SPOC')]).id,
|
||||||
@@ -719,7 +717,7 @@ class ReStockMove(models.Model):
|
|||||||
return {
|
return {
|
||||||
'name': self.env['stock.picking']._get_name_Res(rescode),
|
'name': self.env['stock.picking']._get_name_Res(rescode),
|
||||||
'origin': item.name,
|
'origin': item.name,
|
||||||
# 'surface_technics_parameters_id': sorted_workorders.surface_technics_parameters_id.id,
|
'surface_technics_parameters_id': sorted_workorders.surface_technics_parameters_id.id,
|
||||||
'company_id': self.mapped('company_id').id,
|
'company_id': self.mapped('company_id').id,
|
||||||
'user_id': False,
|
'user_id': False,
|
||||||
'move_type': self.mapped('group_id').move_type or 'direct',
|
'move_type': self.mapped('group_id').move_type or 'direct',
|
||||||
|
|||||||
@@ -251,7 +251,7 @@
|
|||||||
decoration-danger="tag_type == '重新加工'"/>
|
decoration-danger="tag_type == '重新加工'"/>
|
||||||
<field name="is_test_env" invisible="1"/>
|
<field name="is_test_env" invisible="1"/>
|
||||||
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
||||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}" widget='qrcode_widget'/>
|
attrs="{'invisible': [('rfid_code_old', '!=', False)]}" />
|
||||||
<field name="rfid_code" string="RFID码(手动输入框)" force_save="1" readonly="0" cache="True"
|
<field name="rfid_code" string="RFID码(手动输入框)" force_save="1" readonly="0" cache="True"
|
||||||
attrs="{'invisible': ['|',('rfid_code_old', '!=', False), ('is_test_env', '=', False)]}"/>
|
attrs="{'invisible': ['|',('rfid_code_old', '!=', False), ('is_test_env', '=', False)]}"/>
|
||||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
|
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
|
||||||
productions._reset_work_order_sequence()
|
productions._reset_work_order_sequence()
|
||||||
|
productions._reset_subcontract_pick_purchase()
|
||||||
productions.get_subcontract_pick_purchase()
|
productions.get_subcontract_pick_purchase()
|
||||||
for item in productions:
|
for item in productions:
|
||||||
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ from datetime import datetime
|
|||||||
import requests
|
import requests
|
||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
from OCC.Extend.DataExchange import read_step_file
|
# from OCC.Extend.DataExchange import read_step_file
|
||||||
from OCC.Extend.DataExchange import write_stl_file
|
# from OCC.Extend.DataExchange import write_stl_file
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
from odoo.exceptions import ValidationError, UserError
|
from odoo.exceptions import ValidationError, UserError
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import os
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from stl import mesh
|
from stl import mesh
|
||||||
# from OCC.Core.GProp import GProp_GProps
|
# from OCC.Core.GProp import GProp_GProps
|
||||||
from OCC.Extend.DataExchange import read_step_file
|
# from OCC.Extend.DataExchange import read_step_file
|
||||||
from OCC.Extend.DataExchange import write_stl_file
|
# from OCC.Extend.DataExchange import write_stl_file
|
||||||
from odoo.addons.sf_base.commons.common import Common
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
|
|||||||
@@ -257,11 +257,10 @@ class RePurchaseOrder(models.Model):
|
|||||||
'product_uom': server_template.uom_id.id
|
'product_uom': server_template.uom_id.id
|
||||||
}))
|
}))
|
||||||
else:
|
else:
|
||||||
for item in purchase_order_line:
|
|
||||||
if production.name in production_process:
|
if production.name in production_process:
|
||||||
purchase_order = self.env['purchase.order'].search(
|
purchase_order = self.env['purchase.order'].search(
|
||||||
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
||||||
('id', '=', item.order_id.id)])
|
('purchase_type', '=', 'consignment')])
|
||||||
if not purchase_order:
|
if not purchase_order:
|
||||||
server_product_process.append((0, 0, {
|
server_product_process.append((0, 0, {
|
||||||
'product_id': server_template.product_variant_id.id,
|
'product_id': server_template.product_variant_id.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user