Commit 945b7867 by 夏超

[fix] 工位机获取工单数据修改,增加补件/返修单的下道工单

parent 25b79c71
......@@ -27,6 +27,10 @@ class InheritRokeWorkstationWorkOrder(RokeWorkstationWorkOrder):
work_order_id = _self.jsonrequest.get("work_order_id", 0)
res = super(InheritRokeWorkstationWorkOrder, self).workstation_work_order()
work_order = _self.env["roke.work.order"].search([("id", "=", work_order_id)])
next_work_order = _self.env["roke.work.order"].search([("id", "=", res.get("data", {}).get("id", 0))])
res.get("data", {}).update({
"next_wo_code": next_work_order.next_wo_id.code or ""
})
if not work_order_id or not work_order:
return res
if work_order.type == "返修":
......@@ -57,9 +61,6 @@ class InheritRokeWorkstationWorkOrder(RokeWorkstationWorkOrder):
"routing_id": routing_id.id,
"routing_line_id": line_id
})
res.get("data", {}).update({
"next_wo_code": work_order.next_wo_id.code or ""
})
return res
......
......@@ -8,19 +8,30 @@ class InheritWorkOrder(models.Model):
document_ids = fields.Many2many(related="task_id.document_ids", string="作业指导")
task_file_ids = fields.Many2many(related="task_id.file_ids")
repair_task_id = fields.Many2one('roke.production.task', string="上级任务")
repair_wr_id = fields.Many2one('roke.work.record', string="原始返修报工单")
repair_wr_id = fields.Many2one('roke.work.record', string="原始返修报工单")
next_wo_id = fields.Many2one("roke.work.order", string="下道工单", store=True, compute="_compute_next_work_order")
@api.depends("task_id")
def _compute_next_work_order(self):
for v in self:
if v.type == "生产":
sequence = min(v.mapped("sequence"))
next_wos = v.task_id.work_order_ids.filtered(lambda wo: wo.sequence > sequence)
next_wo = sorted(next_wos, key=lambda x: x['sequence'], reverse=False)
if not next_wo:
continue
v.next_wo_id = next_wo[0].id
elif v.type == "返修":
v.next_wo_id = v.repair_wr_id.work_order_id.id
elif v.type == "补件":
sequence = v.sequence
next_wos = v.repair_wr_id.scrap_line_ids.scrap_work_order_ids.filtered(lambda wo: wo.sequence > sequence)
next_wo = sorted(next_wos, key=lambda x: x['sequence'], reverse=False)
if not next_wo:
v.next_wo_id = v.repair_wr_id.work_order_id.id
else:
v.next_wo_id = next_wo[0].id
def write(self, vals):
id_dict = {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment