工艺确认后的错误提示
This commit is contained in:
@@ -432,7 +432,6 @@ class MrpProduction(models.Model):
|
|||||||
# 工艺确认
|
# 工艺确认
|
||||||
def technology_confirm(self):
|
def technology_confirm(self):
|
||||||
process_parameters = []
|
process_parameters = []
|
||||||
account_moves = []
|
|
||||||
purchase_orders = []
|
purchase_orders = []
|
||||||
parameters_not = []
|
parameters_not = []
|
||||||
# 获取原有的工单对应的工序
|
# 获取原有的工单对应的工序
|
||||||
@@ -443,10 +442,6 @@ class MrpProduction(models.Model):
|
|||||||
for deleted_design in deleted_designs:
|
for deleted_design in deleted_designs:
|
||||||
workorder = self.env['mrp.workorder'].search([('technology_design_id', '=', deleted_design.id)])
|
workorder = self.env['mrp.workorder'].search([('technology_design_id', '=', deleted_design.id)])
|
||||||
purchase = workorder._get_surface_technics_purchase_ids()
|
purchase = workorder._get_surface_technics_purchase_ids()
|
||||||
account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids.ids)])
|
|
||||||
if account.state not in ['cancel', False]:
|
|
||||||
if account.name not in account_moves:
|
|
||||||
account_moves.append(account.name)
|
|
||||||
if purchase.state not in ['cancel','draft', False]:
|
if purchase.state not in ['cancel','draft', False]:
|
||||||
purchase_orders.append(purchase.name)
|
purchase_orders.append(purchase.name)
|
||||||
special_design = self.technology_design_ids.filtered(
|
special_design = self.technology_design_ids.filtered(
|
||||||
@@ -460,9 +455,7 @@ class MrpProduction(models.Model):
|
|||||||
if not product_production_process:
|
if not product_production_process:
|
||||||
if special.process_parameters_id not in process_parameters:
|
if special.process_parameters_id not in process_parameters:
|
||||||
process_parameters.append(special.process_parameters_id.display_name)
|
process_parameters.append(special.process_parameters_id.display_name)
|
||||||
|
|
||||||
if account_moves:
|
|
||||||
raise UserError(_("请联系工厂生产经理对该(%s)账单进行取消", ", ".join(account_moves)))
|
|
||||||
if purchase_orders:
|
if purchase_orders:
|
||||||
raise UserError(_("请联系工厂生产经理对该(%s)采购订单进行取消", ", ".join(purchase_orders)))
|
raise UserError(_("请联系工厂生产经理对该(%s)采购订单进行取消", ", ".join(purchase_orders)))
|
||||||
if parameters_not:
|
if parameters_not:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
|
from odoo.exceptions import UserError
|
||||||
from odoo.tools import OrderedSet
|
from odoo.tools import OrderedSet
|
||||||
|
|
||||||
|
|
||||||
@@ -16,6 +17,20 @@ class PurchaseOrder(models.Model):
|
|||||||
compute='_compute_workorder_count',
|
compute='_compute_workorder_count',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def button_cancel(self):
|
||||||
|
account_moves = set() # 使用集合以避免重复,并提高查找速度
|
||||||
|
accounts = self.env['account.move'].search(
|
||||||
|
[('id', 'in', self.invoice_ids.ids), ('state', 'not in', ['cancel', False])])
|
||||||
|
|
||||||
|
# 直接筛选掉状态为'cancel'或False的记录,避免多次迭代
|
||||||
|
for account in accounts:
|
||||||
|
account_moves.add(account.name) # 使用set的add方法避免重复添加
|
||||||
|
|
||||||
|
# 如果你需要list形式的结果,可以将set转换为list
|
||||||
|
account_moves = list(account_moves)
|
||||||
|
if account_moves:
|
||||||
|
raise UserError(_("请联系工厂生产经理对该采购单的账单进行取消"))
|
||||||
|
return super(PurchaseOrder, self).button_cancel()
|
||||||
def action_view_production(self):
|
def action_view_production(self):
|
||||||
origins = [order.name for order in self.picking_ids]
|
origins = [order.name for order in self.picking_ids]
|
||||||
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||||
|
|||||||
Reference in New Issue
Block a user