diff --git a/sf_demand_plan/__init__.py b/sf_demand_plan/__init__.py index cec04a5b..408a6001 100644 --- a/sf_demand_plan/__init__.py +++ b/sf_demand_plan/__init__.py @@ -1,4 +1,3 @@ # -*- coding: utf-8 -*- -from . import controllers from . import models from . import wizard diff --git a/sf_demand_plan/controllers/__init__.py b/sf_demand_plan/controllers/__init__.py deleted file mode 100644 index e046e49f..00000000 --- a/sf_demand_plan/controllers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import controllers diff --git a/sf_demand_plan/controllers/controllers.py b/sf_demand_plan/controllers/controllers.py deleted file mode 100644 index 5db1ebe6..00000000 --- a/sf_demand_plan/controllers/controllers.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -import logging -import json -from odoo import http, fields, models -from odoo.http import request -from odoo.addons.sf_base.controllers.controllers import MultiInheritController - - -class SfPlanMrsConnect(http.Controller, MultiInheritController): - - @http.route('/api/demand_plan/update_processing_time', type='json', auth='sf_token', methods=['GET', 'POST'], - csrf=False, - cors="*") - def update_processing_time(self, **kw): - """ - 根据模型id修改程序工时 - :param kw: - :return: - """ - try: - res = {'status': 1, 'message': '成功'} - datas = request.httprequest.data - ret = json.loads(datas) - ret = json.loads(ret['result']) - logging.info('根据模型id修改程序工时:%s' % ret) - demand_plan = request.env['sf.production.demand.plan'].sudo().search( - [('model_id', '=', ret['model_id'])]) - if demand_plan: - demand_plan.write( - {'processing_time': ret['total_estimated_time']}) - else: - res = {'status': 0, 'message': '未查到该需求计划'} - except Exception as e: - logging.info('update_demand_paln error:%s' % e) - res['status'] = -1 - res['message'] = '系统解析错误!' - return json.JSONEncoder().encode(res) diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 1091f905..b06c4213 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -42,6 +42,12 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController): res = {'status': -2, 'message': '查询到待工艺确认的制造订单'} return json.JSONEncoder().encode(res) if productions: + # 修改需求计划中的程序工时 + demand_plan = request.env['sf.production.demand.plan'].with_user( + request.env.ref("base.user_admin")).search([('model_id', '=', ret['folder_name'])]) + if demand_plan and ret['total_estimated_time']: + demand_plan.write( + {'processing_time': ret['total_estimated_time']}) # 拉取所有加工面的程序文件 for r in ret['processing_panel'].split(','):