Compare commits
10 Commits
release/re
...
feature/pa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
284234adf2 | ||
|
|
3ba79d88b5 | ||
|
|
c5755c318c | ||
|
|
dcaca89c6f | ||
|
|
5774f241a0 | ||
|
|
ad02cbf8cb | ||
|
|
79d561ba68 | ||
|
|
6e46d1d8dc | ||
|
|
5d2ddfb510 | ||
|
|
58acdc4913 |
@@ -459,7 +459,7 @@ class MrpProduction(models.Model):
|
||||
process_parameters.append(special.process_parameters_id.display_name)
|
||||
|
||||
if account_moves:
|
||||
raise UserError(_("请联系工厂生产经理对采购订单为%s生成的账单进行取消", ", ".join(account_moves)))
|
||||
raise UserError(_("请联系工厂生产经理对会计凭证为%s生成的账单进行取消", ", ".join([move.name for move in account_moves])))
|
||||
if parameters_not:
|
||||
raise UserError(_("【工艺设计】-【工序】为%s未选择参数,请选择", ", ".join(parameters_not)))
|
||||
if process_parameters:
|
||||
|
||||
@@ -275,31 +275,18 @@ class ResMrpWorkOrder(models.Model):
|
||||
def _compute_surface_technics_purchase_ids(self):
|
||||
for order in self:
|
||||
if order.routing_type == '表面工艺' and order.state not in ['cancel']:
|
||||
# if order.production_id.production_type == '自动化产线加工':
|
||||
# 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),
|
||||
domain = [('purchase_type', '=', 'consignment'),
|
||||
('origin', 'like', '%' + self.production_id.name + '%'),
|
||||
('state', '!=', 'cancel')]
|
||||
purchase = self.env['purchase.order'].search(domain)
|
||||
purchase_num = 0
|
||||
order.surface_technics_purchase_count = 0
|
||||
if not purchase:
|
||||
order.surface_technics_purchase_count = 0
|
||||
for po in purchase:
|
||||
for line in po.order_line:
|
||||
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id:
|
||||
if line.product_qty == 1:
|
||||
purchase_num += 1
|
||||
order.surface_technics_purchase_count = purchase_num
|
||||
if any(
|
||||
line.product_id and line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id
|
||||
for line in po.order_line):
|
||||
order.surface_technics_purchase_count = 1
|
||||
else:
|
||||
order.surface_technics_purchase_count = 0
|
||||
|
||||
@@ -1063,6 +1050,13 @@ class ResMrpWorkOrder(models.Model):
|
||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||
if purchase_orders_id.state == 'purchase':
|
||||
workorder.state = 'ready'
|
||||
move_out = workorder.move_subcontract_workorder_ids[1]
|
||||
for mo in move_out:
|
||||
if mo.state != 'done':
|
||||
mo.write({'state': 'assigned', 'production_id': False})
|
||||
if not mo.move_line_ids:
|
||||
self.env['stock.move.line'].create(
|
||||
mo.get_move_line(workorder.production_id, workorder))
|
||||
continue
|
||||
else:
|
||||
workorder.state = 'waiting'
|
||||
@@ -1092,12 +1086,22 @@ class ResMrpWorkOrder(models.Model):
|
||||
if workorder.is_subcontract is False:
|
||||
workorder.state = 'ready'
|
||||
else:
|
||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||
if purchase_orders_id:
|
||||
workorder.state = 'ready' if purchase_orders_id.state == 'purchase' else 'waiting'
|
||||
else:
|
||||
workorder.state = 'waiting'
|
||||
|
||||
if len(workorder.production_id.picking_ids.filtered(
|
||||
lambda w: w.state not in ['done',
|
||||
'cancel'])) == 0 and workorder.production_id.programming_state == '已编程':
|
||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||
if purchase_orders_id:
|
||||
if purchase_orders_id.state == 'purchase':
|
||||
workorder.state = 'ready'
|
||||
move_out = workorder.move_subcontract_workorder_ids[1]
|
||||
for mo in move_out:
|
||||
if mo.state != 'done':
|
||||
mo.write({'state': 'assigned', 'production_id': False})
|
||||
if not mo.move_line_ids:
|
||||
self.env['stock.move.line'].create(
|
||||
mo.get_move_line(workorder.production_id, workorder))
|
||||
else:
|
||||
workorder.state = 'waiting'
|
||||
# 重写工单开始按钮方法
|
||||
def button_start(self):
|
||||
# 判断工单状态是否为等待组件
|
||||
@@ -1280,7 +1284,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
raise UserError('请先完成该工单的工艺外协再进行操作')
|
||||
# 表面工艺外协,最后一张工单
|
||||
workorders = self.production_id.workorder_ids
|
||||
subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True).sorted('sequence')
|
||||
subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence')
|
||||
if self == subcontract_workorders[-1]:
|
||||
# 给下一个库存移动就绪
|
||||
self.move_subcontract_workorder_ids[0].move_dest_ids._action_done()
|
||||
@@ -1304,8 +1308,10 @@ class ResMrpWorkOrder(models.Model):
|
||||
is_production_id = False
|
||||
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'])
|
||||
if (len(rework_workorder) + len(done_workorder) == len(record.production_id.workorder_ids)) or (
|
||||
len(done_workorder) == len(record.production_id.workorder_ids)):
|
||||
if (len(rework_workorder) + len(done_workorder) == len(
|
||||
record.production_id.workorder_ids.filtered(lambda wo: wo.state != 'cancel'))) or (
|
||||
len(done_workorder) == len(
|
||||
record.production_id.workorder_ids.filtered(lambda wo: wo.state != 'cancel'))):
|
||||
is_production_id = True
|
||||
if record.routing_type in ['解除装夹'] or (
|
||||
record.is_rework is True and record.routing_type in ['装夹预调']):
|
||||
|
||||
@@ -44,18 +44,18 @@ class PurchaseOrder(models.Model):
|
||||
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||
purchase.production_count = len(production_id)
|
||||
|
||||
def button_confirm(self):
|
||||
super().button_confirm()
|
||||
workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id), ('state', '!=', 'cancel')])
|
||||
for workorder in workorders:
|
||||
if workorder.routing_type == '表面工艺' and workorder.is_subcontract is True:
|
||||
move_out = workorder.move_subcontract_workorder_ids[1]
|
||||
for mo in move_out:
|
||||
if mo.state != 'done':
|
||||
mo.write({'state': 'assigned', 'production_id': False})
|
||||
if not mo.move_line_ids:
|
||||
self.env['stock.move.line'].create(mo.get_move_line(workorder.production_id, workorder))
|
||||
return True
|
||||
# def button_confirm(self):
|
||||
# super().button_confirm()
|
||||
# workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id), ('state', '!=', 'cancel')])
|
||||
# for workorder in workorders:
|
||||
# if workorder.routing_type == '表面工艺' and workorder.is_subcontract is True:
|
||||
# move_out = workorder.move_subcontract_workorder_ids[1]
|
||||
# for mo in move_out:
|
||||
# if mo.state != 'done':
|
||||
# mo.write({'state': 'assigned', 'production_id': False})
|
||||
# if not mo.move_line_ids:
|
||||
# self.env['stock.move.line'].create(mo.get_move_line(workorder.production_id, workorder))
|
||||
# return True
|
||||
|
||||
origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id')
|
||||
origin_sale_ids = fields.Many2many('sale.order', string='销售订单号(多个)', store=True,
|
||||
|
||||
@@ -637,7 +637,7 @@ class StockPicking(models.Model):
|
||||
if move_in:
|
||||
workorder = move_in.subcontract_workorder_id
|
||||
workorders = workorder.production_id.workorder_ids
|
||||
subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True).sorted('sequence')
|
||||
subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True and wo.state!='cancel').sorted('sequence')
|
||||
if workorder == subcontract_workorders[-1]:
|
||||
self.env['stock.quant']._update_reserved_quantity(
|
||||
move_in.product_id, move_in.location_dest_id, move_in.product_uom_qty,
|
||||
|
||||
@@ -396,23 +396,6 @@ class RePurchaseOrder(models.Model):
|
||||
production = self.env['mrp.production'].search([('name', '=', production_name)])
|
||||
for workorder in production.workorder_ids.filtered(
|
||||
lambda wd: wd.routing_type == '表面工艺' and wd.state == 'waiting' and line.product_id.server_product_process_parameters_id == wd.surface_technics_parameters_id):
|
||||
work_ids = workorder.production_id.workorder_ids.filtered(
|
||||
lambda wk: wk.state not in ['done', 'rework', 'cancel'])
|
||||
min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence)
|
||||
artificial_offline = (
|
||||
workorder.production_id.production_type == '人工线下加工' and workorder.production_id.schedule_state != '已排')
|
||||
auto_production = (
|
||||
workorder.production_id.production_type == '自动化产线加工' and workorder.production_id.programming_state != '已编程')
|
||||
if workorder.sequence == min_sequence_wk.sequence:
|
||||
if artificial_offline or auto_production:
|
||||
raise UserError('等待组件')
|
||||
else:
|
||||
sorted_work_ids = work_ids.sorted(key=lambda w: w.sequence)
|
||||
previous_workorder = self.env['mrp.workorder'].search([('sequence', '<', workorder.sequence),
|
||||
('production_id', '=', workorder.production_id.id),
|
||||
('state', '=', 'done')], order='sequence desc', limit=1)
|
||||
if not previous_workorder:
|
||||
raise UserError('等待组件')
|
||||
workorder.state = 'ready'
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user