Commit 30d7abc4 by 夏超

[fix] 新增任务的工艺设计

parent ae978a57
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
'views/inherit_roke_scrap_order_view.xml' 'views/inherit_roke_scrap_order_view.xml'
], ],
'qweb': [ 'qweb': [
"static/src/xml/roke_craft_design.xml",
], ],
'application': False, 'application': False,
'installable': True, 'installable': True,
......
import datetime import datetime
import json import json
import logging import logging
import os
from jinja2 import FileSystemLoader, Environment
import pytz import pytz
from odoo import models, fields, api, http, SUPERUSER_ID, _ from odoo import models, fields, api, http, SUPERUSER_ID, _
from odoo.addons.roke_workstation_api.controllers.data_analysis import reduce_pytz_conversion, pytz_conversion from odoo.addons.roke_workstation_api.controllers.data_analysis import reduce_pytz_conversion, pytz_conversion
...@@ -9,8 +10,50 @@ from odoo.addons.roke_workstation_api.controllers.data_analysis import reduce_py ...@@ -9,8 +10,50 @@ from odoo.addons.roke_workstation_api.controllers.data_analysis import reduce_py
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
# 设置查找html文件的路径
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
templateloader = FileSystemLoader(searchpath=BASE_DIR + "/static")
env = Environment(loader=templateloader)
class RokeWorkstationWorkOrderModel(http.Controller): class RokeWorkstationWorkOrderModel(http.Controller):
@http.route('/roke/craft_design/index', type='http', auth='user', csrf=False, cors="*")
def roke_index_demo_module(self, **kwargs):
product_id = kwargs.get("product_id", False)
routing_id = kwargs.get("routing_id", False)
user_id = http.request.env.user.id
values = {
"product_id": product_id,
"routing_id": routing_id,
"user_id": user_id
}
template = env.get_template('/src/html/index.html')
html = template.render(values)
return html
@http.route('/roke/workstation/craft_design/workstation_product/get', type='json', auth='user', csrf=False, cors="*")
def workstation_product_get(self):
"""
获取工单的不良报工记录
"""
_self = http.request
product_id = _self.jsonrequest.get("product_id", 0)
product = _self.env["roke.product"].sudo().search([("id", "=", product_id)])
data = {
"type": "product",
"parent_id": 0,
"id": product.id,
"name": product.name or "",
"specification": product.specification or "",
"code": product.code or "",
"capacity": product.capacity or 0.0,
"fpy": product.fpy or 0.0,
"category": {"id": product.category_id.id, "name": product.category_id.name or ""},
"has_bom": False,
}
return {"code": 0, "message": f"获取成功!", "data": data}
@http.route('/roke/workstation/work_record/workstation_work_record', type='json', auth='user', csrf=False, cors="*") @http.route('/roke/workstation/work_record/workstation_work_record', type='json', auth='user', csrf=False, cors="*")
def get_workstation_work_record(self): def get_workstation_work_record(self):
""" """
......
...@@ -5,3 +5,4 @@ from . import work_log ...@@ -5,3 +5,4 @@ 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 from . import inherit_roke_scrap_order
from . import inherit_roke_routing
...@@ -95,3 +95,26 @@ class InheritProductionTask(models.Model): ...@@ -95,3 +95,26 @@ class InheritProductionTask(models.Model):
plan_qty = int(plan_qty) plan_qty = int(plan_qty)
res.update({"plan_qty": plan_qty}) res.update({"plan_qty": plan_qty})
return res return res
def craft_design(self):
if not self.routing_id:
raise ValidationError("该任务没有工艺路线!请先选择工艺路线。")
if not self.routing_id.routing_task_id or self.routing_id.routing_task_id.id != self.id:
routing_id = self.routing_id.copy()
routing_id.update({
"state": "确认",
"routing_task_id": self.id
})
self.write({"routing_id": routing_id.id})
self._onchange_routing_id()
else:
routing_id = self.routing_id
return {
"name": "工艺设计",
"type": "ir.actions.client",
"tag": "jzjx_project.roke_craft_design",
"target": "current",
"params": {
"controller": f"/roke/craft_design/index?product_id={self.product_id.id}&routing_id={routing_id.id}"
}
}
import datetime
import pymysql
import logging
from odoo import api, models, fields
_logger = logging.getLogger(__name__)
class InheritRokeRoutingModel(models.Model):
_inherit = "roke.routing"
routing_task_id = fields.Many2one("roke.production.task")
def _get_check_vals(self, check):
data = {
"sequence": check.sequence,
"name": check.name,
"description": check.description,
"input_type": check.input_type,
"standard_value": check.standard_value,
"upper_value": check.upper_value,
"lower_value": check.lower_value,
}
check_option = []
for v in check.select_item_ids:
check_option.append((0, 0, {
"sequence": v.sequence,
"value": v.value
}))
data.update({
"select_item_ids": check_option
})
return data
def get_routing_line_value(self, line):
"""
获取工艺明细内容
:param process:
:return:
"""
res = super(InheritRokeRoutingModel, self).get_routing_line_value(line)
check_ids = []
for v in line.check_ids:
check_ids.append((0, 0, self._get_check_vals(v)))
res.update({
"scrap_reason_ids": [(6, 0, line.scrap_reason_ids.ids)],
"check_ids": check_ids,
})
return res
def _get_standard_item_vals(self, standard_item):
"""
作业规范
"""
res = super(InheritRokeRoutingModel, self)._get_standard_item_vals(standard_item)
res.update({
"description": standard_item.description or "",
"sequence": standard_item.sequence,
})
return res
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
[[ product_id ]] [[ routing_id ]]
</body>
</html>
\ No newline at end of file
odoo.define('jzjx_project.roke_craft_design', function (require) {
"use strict";
var core = require('web.core');
var session = require('web.session');
var AbstractAction = require('web.AbstractAction');
var RokeCraftDesign = AbstractAction.extend({
template: 'jzjx_project.roke_craft_design',
init: function (parent, action, params) {
this.action_controller = `${action.params.controller}&user_id=${session.uid}`;
return this._super.apply(this, arguments);
}
});
core.action_registry.add('jzjx_project.roke_craft_design', RokeCraftDesign);
return RokeCraftDesign;
});
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="roke_routing_settings_template" xml:space="preserve">
<t t-name="jzjx_project.roke_craft_design">
<iframe id="roke_craft_design.xml_iframe" t-attf-src="#{widget.action_controller}" frameBorder="no" width="100%" height="100%" />
</t>
</templates>
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<xpath expr="script[last()]" position="after"> <xpath expr="script[last()]" position="after">
<!-- <script type="text/javascript" src="/roke_pub_wx_notice/static/src/js/sync_wx_btn.js"/>--> <!-- <script type="text/javascript" src="/roke_pub_wx_notice/static/src/js/sync_wx_btn.js"/>-->
<script type="text/javascript" src="/jzjx_project/static/src/js/button.js"/> <script type="text/javascript" src="/jzjx_project/static/src/js/button.js"/>
<script type="text/javascript" src="/jzjx_project/static/src/js/roke_craft_design.js"/>
</xpath> </xpath>
</template> </template>
</odoo> </odoo>
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
<xpath expr="//header" position="inside"> <xpath expr="//header" position="inside">
<button name="upload_task" type="object" string="上传任务" class="btn btn-primary" <button name="upload_task" type="object" string="上传任务" class="btn btn-primary"
attrs="{'invisible': [('UploadMsg', '=', 'OK')]}"/> attrs="{'invisible': [('UploadMsg', '=', 'OK')]}"/>
<field name="record_ids" invisible="1"/>
<button name="craft_design" type="object" string="工艺设计" class="btn btn-primary"
attrs="{'invisible': [('record_ids', '!=', [])]}"/>
</xpath> </xpath>
</field> </field>
</record> </record>
......
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