diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index 536cc13a..c61ba76f 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -718,7 +718,7 @@ class MrpProduction(models.Model):
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
for i, workorder in enumerate(sorted_workorders):
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
- if workorder.sequence == 1:
+ if i == 0:
consecutive_workorders.append(workorder)
elif workorder.sequence == sorted_workorders[
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:
# 处理连续组,如果它不为空
if consecutive_workorders:
- # 创建出库拣货单和采购订单
+ # 创建外协出入库单和采购订单
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
product_id_to_production_names)
@@ -740,7 +740,7 @@ class MrpProduction(models.Model):
i - 1].supplier_id.id:
consecutive_workorders = [workorder]
else:
- # 立即创建出库拣货单和采购订单
+ # 立即创建外协出入库单和采购订单
self.env['stock.picking'].create_outcontract_picking(workorder, production)
self.env['purchase.order'].get_purchase_order(workorder, production,
product_id_to_production_names)
@@ -818,6 +818,17 @@ class MrpProduction(models.Model):
self._reset_work_order_sequence1(k)
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):
"""
工单工序排序方法(新)
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 3443094f..78618c55 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -145,7 +145,7 @@ class ResMrpWorkOrder(models.Model):
tag_type = fields.Selection([("重新加工", "重新加工")], string="标签", tracking=True)
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:
if self.state not in need_list:
return False
@@ -154,9 +154,9 @@ class ResMrpWorkOrder(models.Model):
hours = self.get_hours_diff()
if hours >= 12:
return '正常'
- elif hours > 0 and hours < 12 and self.state!='done':
+ elif hours > 0 and hours < 12 and self.state != 'done':
return '预警'
- elif hours > 0 and hours < 12 and self.state=='done':
+ elif hours > 0 and hours < 12 and self.state == 'done':
return '正常'
else:
return '已逾期'
@@ -168,7 +168,7 @@ class ResMrpWorkOrder(models.Model):
def _compute_construction_period_status(self):
for worker in self:
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
construction_period_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')],
@@ -199,14 +199,17 @@ class ResMrpWorkOrder(models.Model):
func(records)
# 增加页码
page_number += 1
- def run_compute_construction_period_status(self,records):
+
+ def run_compute_construction_period_status(self, records):
records._compute_construction_period_status()
+
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 = [
# 'progress',
# '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):
# 获取当前日期和时间
@@ -230,16 +233,16 @@ class ResMrpWorkOrder(models.Model):
def _compute_surface_technics_picking_ids(self):
for workorder in self:
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(
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
('production_id', '=', workorder.production_id.id)])
if previous_workorder:
- process_product = self.env['product.template']._get_process_parameters_product(
- previous_workorder.surface_technics_parameters_id)
- domain += [('partner_id', '=', process_product.partner_id.id)]
- else:
- domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
+ if previous_workorder.supplier_id != workorder.supplier_id:
+ process_product = self.env['product.template']._get_process_parameters_product(
+ previous_workorder.surface_technics_parameters_id)
+ domain += [('partner_id', '=', process_product.partner_id.id)]
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
workorder.surface_technics_picking_count = len(picking_ids)
workorder.picking_ids = picking_ids.ids
diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py
index baf0c1b5..f363cc53 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/models/stock.py b/sf_manufacturing/models/stock.py
index 7fea2fc9..d2d3ab84 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -366,7 +366,6 @@ class StockRule(models.Model):
process_parameter))
productions.technology_design_ids = technology_design_values
-
return True
@@ -649,41 +648,40 @@ class StockPicking(models.Model):
def create_outcontract_picking(self, sorted_workorders_arr, item):
if len(sorted_workorders_arr) > 1:
sorted_workorders_arr = sorted_workorders_arr[0]
- stock_picking = self.env['stock.picking'].search(
- [('origin', '=', sorted_workorders_arr.production_id.name), ('name', 'ilike', 'OCOUT')])
- if not stock_picking:
+ stock_picking = self.env['stock.picking'].search([('origin', '=', item.name), ('name', 'ilike', 'OCOUT')])
+ if not stock_picking or sorted_workorders_arr:
for sorted_workorders in sorted_workorders_arr:
# pick_ids = []
if not sorted_workorders.picking_ids:
- outcontract_stock_move = self.env['stock.move'].search([('production_id', '=', item.id)])
- if not outcontract_stock_move:
- new_picking = True
- location_id = self.env['stock.location'].search(
- [('barcode', 'ilike', 'VL-SPOC')]).id,
- location_dest_id = self.env['stock.location'].search(
- [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id,
- outcontract_picking_type_in = self.env.ref(
- 'sf_manufacturing.outcontract_picking_in').id,
- outcontract_picking_type_out = self.env.ref(
- 'sf_manufacturing.outcontract_picking_out').id,
- moves_out = self.env['stock.move'].sudo().create(
- self.env['stock.move']._get_stock_move_values_Res(item, location_dest_id, location_id,
- outcontract_picking_type_out))
- picking_out = self.create(
- moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
- # pick_ids.append(picking_out.id)
- moves_out.write(
- {'picking_id': picking_out.id, 'state': 'waiting'})
- moves_out._assign_picking_post_process(new=new_picking)
- moves_in = self.env['stock.move'].sudo().create(
- self.env['stock.move']._get_stock_move_values_Res(item, location_id, location_dest_id,
- outcontract_picking_type_in))
- picking_in = self.create(
- moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
- # pick_ids.append(picking_in.id)
- moves_in.write(
- {'picking_id': picking_in.id, 'state': 'waiting'})
- moves_in._assign_picking_post_process(new=new_picking)
+ # outcontract_stock_move = self.env['stock.move'].search([('production_id', '=', item.id)])
+ # if not outcontract_stock_move:
+ new_picking = True
+ location_id = self.env['stock.location'].search(
+ [('barcode', 'ilike', 'VL-SPOC')]).id,
+ location_dest_id = self.env['stock.location'].search(
+ [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id,
+ outcontract_picking_type_in = self.env.ref(
+ 'sf_manufacturing.outcontract_picking_in').id,
+ outcontract_picking_type_out = self.env.ref(
+ 'sf_manufacturing.outcontract_picking_out').id,
+ moves_out = self.env['stock.move'].sudo().create(
+ self.env['stock.move']._get_stock_move_values_Res(item, location_dest_id, location_id,
+ outcontract_picking_type_out))
+ picking_out = self.create(
+ moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
+ # pick_ids.append(picking_out.id)
+ moves_out.write(
+ {'picking_id': picking_out.id, 'state': 'waiting'})
+ moves_out._assign_picking_post_process(new=new_picking)
+ moves_in = self.env['stock.move'].sudo().create(
+ self.env['stock.move']._get_stock_move_values_Res(item, location_id, location_dest_id,
+ outcontract_picking_type_in))
+ picking_in = self.create(
+ moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
+ # pick_ids.append(picking_in.id)
+ moves_in.write(
+ {'picking_id': picking_in.id, 'state': 'waiting'})
+ moves_in._assign_picking_post_process(new=new_picking)
class ReStockMove(models.Model):
@@ -719,7 +717,7 @@ class ReStockMove(models.Model):
return {
'name': self.env['stock.picking']._get_name_Res(rescode),
'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,
'user_id': False,
'move_type': self.mapped('group_id').move_type or 'direct',
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index bbda259c..a43d287b 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)]}" />
diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py
index 93cd9db1..00a8f668 100644
--- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py
+++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py
@@ -103,6 +103,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
else:
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
productions._reset_work_order_sequence()
+ productions._reset_subcontract_pick_purchase()
productions.get_subcontract_pick_purchase()
for item in productions:
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
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 863dc96a..34500a29 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 0c777766..131a6e9d 100644
--- a/sf_sale/models/sale_order.py
+++ b/sf_sale/models/sale_order.py
@@ -257,17 +257,16 @@ class RePurchaseOrder(models.Model):
'product_uom': server_template.uom_id.id
}))
else:
- for item in purchase_order_line:
- 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 production.name in production_process:
+ purchase_order = self.env['purchase.order'].search(
+ [('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
+ ('purchase_type', '=', 'consignment')])
+ 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({