程序工时修改

This commit is contained in:
guanhuan
2025-05-29 11:07:46 +08:00
parent 9b01254b3c
commit 007f39f137
4 changed files with 40 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
from . import controllers
from . import models
from . import wizard

View File

@@ -0,0 +1 @@
from . import controllers

View File

@@ -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)

View File

@@ -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)