Commit d9c4951b by 夏超

[add] 新增补件工单逻辑

parent fddf4697
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
'views/iniherit_work_order_view.xml', 'views/iniherit_work_order_view.xml',
'views/roke_work_log_views.xml', 'views/roke_work_log_views.xml',
'views/iniherit_work_center_view.xml', 'views/iniherit_work_center_view.xml',
'wizard/inherit_roke_create_work_record_wizard_view.xml' 'wizard/inherit_roke_create_work_record_wizard_view.xml',
'views/inherit_roke_scrap_order_view.xml'
], ],
'qweb': [ 'qweb': [
], ],
......
...@@ -49,10 +49,10 @@ class JzjxInheritRokeWorkstationProductionTask(RokeWorkstationProductionTask): ...@@ -49,10 +49,10 @@ class JzjxInheritRokeWorkstationProductionTask(RokeWorkstationProductionTask):
union all''' if work_order.ids else ""} union all''' if work_order.ids else ""}
SELECT id, 'work' as "type", create_date SELECT id, 'work' as "type", create_date
FROM roke_work_order FROM roke_work_order
WHERE type = '返修' WHERE type in ('返修', '补件')
and process_id in ({" , ".join([f"{v}" for v in process_list])}) and process_id in ({" , ".join([f"{v}" for v in process_list])})
and state = '未完工' and state = '未完工'
and repair_task_id is not null and task_id is null
) as task_repair_work ) as task_repair_work
ORDER BY create_date desc ORDER BY create_date desc
LIMIT {limit} LIMIT {limit}
......
...@@ -35,6 +35,7 @@ class RokeWorkstationWorkOrderModel(http.Controller): ...@@ -35,6 +35,7 @@ class RokeWorkstationWorkOrderModel(http.Controller):
"unqualified_qty": v.unqualified_qty or 0, "unqualified_qty": v.unqualified_qty or 0,
"scrap_qty": sum(v.scrap_line_ids.mapped("qty")), "scrap_qty": sum(v.scrap_line_ids.mapped("qty")),
"repair_qty": sum(v.repair_line_ids.mapped("qty")), "repair_qty": sum(v.repair_line_ids.mapped("qty")),
"is_rfe": v.scrap_order_id.is_rfe,
"work_time": pytz_conversion(_self, v.work_time.strftime('%Y-%m-%d %H:%M')) "work_time": pytz_conversion(_self, v.work_time.strftime('%Y-%m-%d %H:%M'))
}) })
return {"code": 0, "message": f"获取成功!", "data": data} return {"code": 0, "message": f"获取成功!", "data": data}
...@@ -42,7 +43,7 @@ class RokeWorkstationWorkOrderModel(http.Controller): ...@@ -42,7 +43,7 @@ class RokeWorkstationWorkOrderModel(http.Controller):
@http.route('/roke/workstation/work_record/get_workstation_work_process', type='json', auth='user', csrf=False, cors="*") @http.route('/roke/workstation/work_record/get_workstation_work_process', type='json', auth='user', csrf=False, cors="*")
def get_workstation_work_process(self): def get_workstation_work_process(self):
""" """
获取工单的不良报工记录 获取工单的任务内的工序
""" """
_self = http.request _self = http.request
work_order_id = _self.jsonrequest.get("work_order_id", 0) work_order_id = _self.jsonrequest.get("work_order_id", 0)
...@@ -58,3 +59,44 @@ class RokeWorkstationWorkOrderModel(http.Controller): ...@@ -58,3 +59,44 @@ class RokeWorkstationWorkOrderModel(http.Controller):
"name": v.process_id.name or "" "name": v.process_id.name or ""
}) })
return {"code": 0, "message": f"获取成功!", "data": data} return {"code": 0, "message": f"获取成功!", "data": data}
@http.route('/roke/workstation/scrap_order/get_workstation_work_process', type='json', auth='user', csrf=False,
cors="*")
def get_workstation_work_process(self):
"""
生成补件工单
"""
_self = http.request
work_record_id = _self.jsonrequest.get("work_record_id", 0)
process_list = _self.jsonrequest.get("process_list", [])
if not work_record_id:
return {"code": 1, "message": f"入参错误! “报工记录ID”为必传数据。"}
if not process_list:
return {"code": 1, "message": f"入参错误! “工序”为必传数据。"}
work_record = _self.env["roke.work.record"].search([("id", "=", work_record_id)])
if not work_record_id:
return {"code": 1, "message": f"校验错误! 没找到对应的报工记录。"}
work_order_ids = []
index = 1
for v in process_list:
plan_qty = v.get("qty", 0)
process_id = v.get("process_id", 0)
work_order_ids.append((0, 0, {
"process_id": process_id,
"product_id": work_record.work_order_id.product_id.id,
"plan_qty": plan_qty,
"sequence": index,
"planned_start_time": work_record.work_order_id.planned_start_time,
"plan_date": work_record.work_order_id.plan_date,
"repair_task_id": work_record.pt_id.id,
"type": "补件"
}))
index += 1
for v in work_record.scrap_line_ids:
v.write({
"scrap_work_order_ids": work_order_ids,
"is_rfe": True
})
break
work_record.scrap_order_id.write({"is_rfe": True})
return {"code": 0, "message": f"补件工单创建成功!"}
...@@ -4,3 +4,4 @@ from . import inherit_workcenter ...@@ -4,3 +4,4 @@ from . import inherit_workcenter
from . import work_log from . import work_log
from . import inherit_res_config_settings from . import inherit_res_config_settings
from . import inheirt_roke_repair_order from . import inheirt_roke_repair_order
from . import inherit_roke_scrap_order
import logging
from . import generator
from odoo import models, fields, api, _
_logger = logging.getLogger(__name__)
class JzjxInheritScrapOrder(models.Model):
_inherit = "roke.scrap.order"
is_rfe = fields.Boolean(string="是否工单补件")
class JzjxInheritScrapOrderLine(models.Model):
_inherit = "roke.scrap.order.line"
scrap_work_order_ids = fields.Many2many("roke.work.order", string="返修工单")
is_rfe = fields.Boolean(string="是否工单补件")
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="inherit_view_roke_repair_order_form" model="ir.ui.view">
<field name="name">inherit.roke.scrap.order.line.form</field>
<field name="model">roke.scrap.order.line</field>
<field name="inherit_id" ref="roke_mes_quality.view_roke_scrap_order_line_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='eplenish_pt_ids']" position="after">
<page string="补件工单" name="scrap_work_order_ids">
<field name="scrap_work_order_ids" readonly="1"/>
</page>
</xpath>
</field>
</record>
<record id="inherit_view_roke_scrap_order_form" model="ir.ui.view">
<field name="name">inherit.roke.scrap.order.form</field>
<field name="model">roke.scrap.order</field>
<field name="inherit_id" ref="roke_mes_quality.view_roke_scrap_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='line_ids']/tree//button[@name='execute_replenish']" position="replace">
<field name="is_rfe" invisible="1"/>
<field name="allow_replenish_qty" invisible="1"/>
<button name="execute_replenish" type="object" string="执行补件" class="oe_highlight"
attrs="{'invisible': ['|', ('allow_replenish_qty', '&lt;=', 0), '|', ('state', 'in', ['取消', '待确认']), ('is_rfe', '=', True)]}"/>
</xpath>
<xpath expr="//button[@name='multi_execute_replenish']" position="replace">
<field name="is_rfe" invisible="1"/>
<button name="multi_execute_replenish" type="object" string="批量执行补件" class="oe_highlight"
attrs="{'invisible': ['|', ('state', 'in', ['取消', '待确认']), '|', ('can_replenish', '!=', True), ('is_rfe', '=', True)]}"/>
</xpath>
</field>
</record>
<record id="inherit_view_roke_scrap_order_line_tree" model="ir.ui.view">
<field name="name">inherit.roke.scrap.order.line.tree</field>
<field name="model">roke.scrap.order.line</field>
<field name="inherit_id" ref="roke_mes_quality.view_roke_scrap_order_line_tree"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='execute_replenish']" position="replace">
<field name="is_rfe" invisible="1"/>
<button name="execute_replenish" type="object" string="执行补件" class="oe_highlight"
attrs="{'invisible': ['|', ('allow_replenish_qty', '&lt;=', 0), '|', ('state', 'in', ['取消', '待确认']), ('is_rfe', '=', True)]}"/>
</xpath>
</field>
</record>
</odoo>
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