Commit f814b607 by 夏超

[fix] 修改手动下拉文件逻辑,添加到工作台中

parent 10995ff1
import os
from jinja2 import FileSystemLoader, Environment
from odoo import models, fields, api, http, SUPERUSER_ID, _ from odoo import models, fields, api, http, SUPERUSER_ID, _
from odoo.addons.roke_mes_quality.controller.inherit_production import InheritProduction from odoo.addons.roke_mes_quality.controller.inherit_production import InheritProduction
from odoo.addons.roke_mes_production.controller.work_report import WorkReportKanban
import logging import logging
import math import math
...@@ -77,3 +81,22 @@ class JzjxRokeRefixAutoWorkOrder(http.Controller): ...@@ -77,3 +81,22 @@ class JzjxRokeRefixAutoWorkOrder(http.Controller):
_self = http.request _self = http.request
refix_params = _self.env['ir.config_parameter'].sudo().get_param("refix_auto_work_order") refix_params = _self.env['ir.config_parameter'].sudo().get_param("refix_auto_work_order")
return {"code": 0, "message": "成功!", "state": refix_params == "True" or refix_params is True} return {"code": 0, "message": "成功!", "state": refix_params == "True" or refix_params is True}
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
templateloader = FileSystemLoader(searchpath=BASE_DIR + "/static/src/html/view")
env = Environment(loader=templateloader)
class JzjxRokeWorkReportKanban(WorkReportKanban):
@http.route('/roke/work/report/work_order_report', type='http', auth='public', csrf=False)
def work_order_report(self):
"""工单报工"""
values = {}
# 修改Jinja2 分隔符
env.variable_start_string = '[['
env.variable_end_string = ']]'
template = env.get_template('zdy_gdbg.html')
html = template.render(values)
return html
...@@ -45,29 +45,29 @@ class RokeWorkLog(models.Model): ...@@ -45,29 +45,29 @@ class RokeWorkLog(models.Model):
@api.model @api.model
def create(self, vals): def create(self, vals):
res = super(RokeWorkLog, self).create(vals) res = super(RokeWorkLog, self).create(vals)
file_list = res.fileName.split("\\") # file_list = res.fileName.split("\\")
if not file_list: # if not file_list:
return res # return res
file_name = file_list[-1].split("_") # file_name = file_list[-1].split("_")
if not file_name: # if not file_name:
return res # return res
task_code = file_name[0] # task_code = file_name[0]
task = self.env["roke.production.task"].sudo().search([("code", "=", task_code)]) # task = self.env["roke.production.task"].sudo().search([("code", "=", task_code)])
if not task: # if not task:
return res # return res
work_order = self.env["roke.work.order"].sudo().search([("process_id.name", "ilike", "切割")], limit=1) # work_order = self.env["roke.work.order"].sudo().search([("process_id.name", "ilike", "切割")], limit=1)
if not work_order: # if not work_order:
return res # return res
try: # try:
work_order.app_confirm( # work_order.app_confirm(
finish_qty=sum(res.part_ids.mapped("amount")), # finish_qty=sum(res.part_ids.mapped("amount")),
employee_id=self.env.user.employee_id.id, # employee_id=self.env.user.employee_id.id,
unqualified_qty=0, # unqualified_qty=0,
work_hours=round(res.timeTaken / 3600, 2), # work_hours=round(res.timeTaken / 3600, 2),
team_id=0, # team_id=0,
) # )
except Exception as e: # except Exception as e:
_logger.info(f"{e}") # _logger.info(f"{e}")
return res return res
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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