修改接口方法

This commit is contained in:
qihao.gong@jikimo.com
2024-02-22 14:30:51 +08:00
parent 87e9ecb9e2
commit 3fe9c9e532
4 changed files with 49 additions and 22 deletions

View File

@@ -141,6 +141,9 @@ class Manufacturing_Connect(http.Controller):
routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
if not workorder:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'}
return json.JSONEncoder().encode(res)
workorder.button_start()
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
@@ -173,13 +176,16 @@ class Manufacturing_Connect(http.Controller):
routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
if not workorder:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'}
return json.JSONEncoder().encode(res)
workorder.button_finish()
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('button_Work_End error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/QcCheck', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
@http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def Workorder_QcCheck(self, **kw):
"""
@@ -215,3 +221,7 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('Workorder_QcCheck error:%s' % e)
return json.JSONEncoder().encode(res)

View File

@@ -8,8 +8,8 @@ from datetime import datetime
import requests
from odoo import http
from odoo.http import request
# from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
from odoo import models, fields, api
from odoo.modules import get_resource_path
from odoo.exceptions import ValidationError, UserError

View File

@@ -4,6 +4,9 @@ import logging
import base64
import qrcode
import io
import requests
from odoo import api, fields, models, _
from odoo.osv import expression
from odoo.exceptions import UserError
@@ -383,6 +386,26 @@ class ShelfLocation(models.Model):
record.product_id = False
record.location_status = '空闲'
#调取获取货位信息接口
def get_sf_shelf_location_info(self):
# sf_sync_config = self.env['res.config.settings'].get_values()
# token = sf_sync_config['token']
# sf_secret_key = sf_sync_config['sf_secret_key']
# headers = Common.get_headers(self, token, sf_secret_key)
# strurl = sf_sync_config['sf_url'] + self.crea_url
headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
crea_url = 'https://x24467i973.zicp.fun/AutoDeviceApi/GetLocationInfos'
# objs_all = self.env['maintenance.equipment'].search([('id', '=', self.id)])
# machine_tool_list = []
params = {'DeviceId': 'Cabinet-AL'}
r = requests.get(crea_url, params=params,headers=headers)
ret = r.json()
print(ret)
if ret['Succeed'] == True:
return '获取库位信息成功'
else:
raise UserError("该库位无产品")
class Sf_stock_move_line(models.Model):
_inherit = 'stock.move.line'

View File

@@ -66,7 +66,7 @@
<record id="view_shelf_location_tree" model="ir.ui.view">
<field name="name">shelf.location.tree</field>
<field name="name">Shelf Location tree</field>
<field name="model">sf.shelf.location</field>
<field name="arch" type="xml">
<tree string="Shelf Location">
@@ -113,26 +113,19 @@
</record>
<record id="view_shelf_location_form" model="ir.ui.view">
<field name="name">shelf.location.form</field>
<field name="name">Shelf Location form</field>
<field name="model">sf.shelf.location</field>
<field name="arch" type="xml">
<form string="Shelf Location">
<header>
<field name="location_status" invisible="1"/>
<button string="生成货位" name="create_location" type="object" class="oe_highlight"
attrs="{'invisible': [('hide_shelf', '=', False)]}"/>
<button string="禁用货位" name="action_location_status_disable" type="object"
class="oe_highlight"
attrs="{'invisible': ['|', ('hide_shelf', '=', True), ('location_status', '!=', '空闲')]}"/>
<button string="启用货位" name="action_location_status_enable" type="object"
class="oe_highlight"
attrs="{'invisible': ['|', ('hide_shelf', '=', True), ('location_status', '!=', '禁用')]}"/>
<button type="object" class="oe_highlight" name='get_sf_shelf_location_info' string="获取货位信息"/>
<field name="location_status" invisible="1"/>
<button string="禁用货位" name="action_location_status_disable" type="object" class="oe_highlight"
attrs="{'invisible': [('location_status', '!=', '空闲')]}"/>
<button string="启用货位" name="action_location_status_enable" type="object" class="oe_highlight"
attrs="{'invisible': [('location_status', '!=', '禁用')]}"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
@@ -262,6 +255,11 @@
<!-- </record> -->
<menuitem id="shelf_location_kanban_menu" name="货位看板" parent="stock.menu_stock_root"
sequence="51"
action="shelf_location_kanban_action_id"
groups="sf_warehouse.group_sf_stock_user"/>
<record id="action_sf_shelf_location" model="ir.actions.act_window">
<field name="name">货位</field>
<field name="type">ir.actions.act_window</field>
@@ -286,15 +284,11 @@
<!-- sequence="50" -->
<!-- action="kanban_action_id"/> -->
<menuitem id="shelf_location_kanban_menu" name="货位看板" parent="stock.menu_stock_root"
sequence="51"
action="shelf_location_kanban_action_id"
<menuitem id="menu_sf_shelf_location" name="货位" parent="stock.menu_warehouse_config"
sequence="20"
action="action_sf_shelf_location"
groups="sf_warehouse.group_sf_stock_user"/>
<menuitem id="menu_sf_shelf_location" name="货架货位" parent="stock.menu_warehouse_config"
sequence="20"/>
</data>
</odoo>