38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
# -*- 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)
|