From 007f39f1375e531d0541a2f50a474e5da6bd16d4 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Thu, 29 May 2025 11:07:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=B7=A5=E6=97=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/__init__.py | 2 +- sf_demand_plan/controllers/__init__.py | 1 + sf_demand_plan/controllers/controllers.py | 37 +++++++++++++++++++ .../models/sf_production_demand_plan.py | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 sf_demand_plan/controllers/__init__.py create mode 100644 sf_demand_plan/controllers/controllers.py diff --git a/sf_demand_plan/__init__.py b/sf_demand_plan/__init__.py index 35e7c960..cec04a5b 100644 --- a/sf_demand_plan/__init__.py +++ b/sf_demand_plan/__init__.py @@ -1,4 +1,4 @@ # -*- 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 new file mode 100644 index 00000000..e046e49f --- /dev/null +++ b/sf_demand_plan/controllers/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/sf_demand_plan/controllers/controllers.py b/sf_demand_plan/controllers/controllers.py new file mode 100644 index 00000000..b4401a89 --- /dev/null +++ b/sf_demand_plan/controllers/controllers.py @@ -0,0 +1,37 @@ +# -*- 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 Sf_Plan_Mrs_Connect(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_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index 6678354c..04b25949 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -92,7 +92,7 @@ class sf_production_plan(models.Model): ('0', "未齐套"), ('1', "已齐套"), ], string='投料齐套检查', compute='_compute_material_check', store=True) - processing_time = fields.Char('程序工时') + processing_time = fields.Char('程序工时', readonly=True) planned_start_date = fields.Date('计划开工日期') actual_start_date = fields.Date('实际开工日期', compute='_compute_actual_start_date', store=True) actual_end_date = fields.Date('实际完工日期', compute='_compute_actual_end_date', store=True)