新增获取库区信息定时器
修改库存变更接口
This commit is contained in:
@@ -320,22 +320,20 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
workorder = request.env['mrp.workorder'].sudo().search(
|
workorder = request.env['mrp.workorder'].sudo().search(
|
||||||
[('rfid_code', '=', RfidCode)], limit=1)
|
[('rfid_code', '=', RfidCode)], limit=1)
|
||||||
if not workorder:
|
if not workorder:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未找到该工单'}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未根据RfidCode找到该工单'}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
old_localtion = request.env['sf.shelf.location'].sudo().search(
|
old_localtion = request.env['sf.shelf.location'].sudo().search(
|
||||||
[('barcode', '=', OldPosition)], limit=1)
|
[('barcode', '=', OldPosition)], limit=1)
|
||||||
new_localtion = request.env['sf.shelf.location'].sudo().search(
|
new_localtion = request.env['sf.shelf.location'].sudo().search(
|
||||||
[('barcode', '=', NewPosition)], limit=1)
|
[('barcode', '=', NewPosition)], limit=1)
|
||||||
if not new_localtion:
|
if not new_localtion:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该存储位置'}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
if workorder and old_localtion and new_localtion:
|
if old_localtion:
|
||||||
old_localtion.location_status = '空闲'
|
old_localtion.location_status = '空闲'
|
||||||
new_localtion.location_status = '占用'
|
old_localtion.production_id = False
|
||||||
new_localtion.production_id = workorder.production_id.id
|
new_localtion.location_status = '占用'
|
||||||
if old_localtion == 'None':
|
new_localtion.production_id = workorder.production_id.id
|
||||||
new_localtion.location_status = '占用'
|
|
||||||
new_localtion.production_id = workorder.production_id.id
|
|
||||||
# return json.JSONEncoder().encode(res)
|
# return json.JSONEncoder().encode(res)
|
||||||
# else:
|
# else:
|
||||||
# res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
|
# res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
|
||||||
|
|||||||
@@ -103,7 +103,6 @@
|
|||||||
<xpath expr="//field[@name='state']" position="before">
|
<xpath expr="//field[@name='state']" position="before">
|
||||||
<field name='user_permissions' invisible="1"/>
|
<field name='user_permissions' invisible="1"/>
|
||||||
<field name='name' invisible="1"/>
|
<field name='name' invisible="1"/>
|
||||||
<field name='routing_type' invisible="1"/>
|
|
||||||
<field name='is_delivery' invisible="1"/>
|
<field name='is_delivery' invisible="1"/>
|
||||||
<button name="button_start" type="object" string="开始" class="btn-success"
|
<button name="button_start" type="object" string="开始" class="btn-success"
|
||||||
attrs="{'invisible': ['|', '|', '|','|',('production_state','in', ('draft', 'done',
|
attrs="{'invisible': ['|', '|', '|','|',('production_state','in', ('draft', 'done',
|
||||||
@@ -160,6 +159,7 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
<field name="production_id" position="after" invisible="0">
|
<field name="production_id" position="after" invisible="0">
|
||||||
<group>
|
<group>
|
||||||
|
<field name='routing_type'/>
|
||||||
<field name="date_planned_start" invisible="1"/>
|
<field name="date_planned_start" invisible="1"/>
|
||||||
<field name="date_planned_finished" invisible="1"/>
|
<field name="date_planned_finished" invisible="1"/>
|
||||||
<!-- <field name="production_id" readonly="1"/>-->
|
<!-- <field name="production_id" readonly="1"/>-->
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['stock', 'web', 'sf_base'],
|
'depends': ['stock', 'web', 'sf_base'],
|
||||||
'data': [
|
'data': [
|
||||||
|
'data/ir_cron_data.xml',
|
||||||
'security/sf_stock_security.xml',
|
'security/sf_stock_security.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'views/view.xml',
|
'views/view.xml',
|
||||||
|
|||||||
14
sf_warehouse/data/ir_cron_data.xml
Normal file
14
sf_warehouse/data/ir_cron_data.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding='UTF-8'?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="ir_cron_sf_shelf_location_datasync">
|
||||||
|
<field name="name">定时同步库区信息</field>
|
||||||
|
<field name="model_id" ref="model_sf_shelf_location_datasync"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model._cron_shelf_location_datasync()</field>
|
||||||
|
<field name="interval_number">4</field>
|
||||||
|
<field name="interval_type">hours</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -1 +1,2 @@
|
|||||||
from . import model
|
from . import model
|
||||||
|
from . import sync_common
|
||||||
|
|||||||
@@ -398,12 +398,13 @@ class ShelfLocation(models.Model):
|
|||||||
crea_url = 'https://x24467i973.zicp.fun/AutoDeviceApi/GetLocationInfos'
|
crea_url = 'https://x24467i973.zicp.fun/AutoDeviceApi/GetLocationInfos'
|
||||||
# objs_all = self.env['maintenance.equipment'].search([('id', '=', self.id)])
|
# objs_all = self.env['maintenance.equipment'].search([('id', '=', self.id)])
|
||||||
# machine_tool_list = []
|
# machine_tool_list = []
|
||||||
params = {'DeviceId': 'Cabinet-AL'}
|
|
||||||
r = requests.get(crea_url, params=params, headers=headers)
|
r = requests.get(crea_url, headers=headers)
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
|
|
||||||
print(ret)
|
print(ret)
|
||||||
if ret['Succeed'] == True:
|
if ret['Succeed'] == True:
|
||||||
return '获取库位信息成功'
|
return ret['Datas']
|
||||||
else:
|
else:
|
||||||
raise UserError("该库位无产品")
|
raise UserError("该库位无产品")
|
||||||
|
|
||||||
|
|||||||
30
sf_warehouse/models/sync_common.py
Normal file
30
sf_warehouse/models/sync_common.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
|
import json
|
||||||
|
import base64
|
||||||
|
import requests
|
||||||
|
from odoo import models
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class MrsShelfLocationDataSync(models.Model):
|
||||||
|
_name = 'sf.shelf.location.datasync'
|
||||||
|
_description = '同步库存信息'
|
||||||
|
|
||||||
|
def _cron_shelf_location_datasync(self):
|
||||||
|
try:
|
||||||
|
shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info()
|
||||||
|
for item in shelfinfo:
|
||||||
|
location_id = self.env['sf.shelf.location'].search([('barcode', '=', item['Postion'])], limit=1)
|
||||||
|
if location_id:
|
||||||
|
workorder_id = self.env['mrp.workorder'].search([('rfid_code', '=', item['RfidCode'])], limit=1)
|
||||||
|
if workorder_id:
|
||||||
|
location_id.production_id = workorder_id.production_id.id
|
||||||
|
location_id.location_status = '占用'
|
||||||
|
logging.info('货架已获取信息:%s' % item)
|
||||||
|
except Exception as e:
|
||||||
|
logging.info("捕获错误信息:%s" % e)
|
||||||
|
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
||||||
@@ -119,8 +119,6 @@
|
|||||||
<form string="Shelf Location">
|
<form string="Shelf Location">
|
||||||
<header>
|
<header>
|
||||||
|
|
||||||
<button type="object" class="oe_highlight" name='get_sf_shelf_location_info' string="获取货位信息"/>
|
|
||||||
|
|
||||||
<field name="location_status" invisible="1"/>
|
<field name="location_status" invisible="1"/>
|
||||||
<button string="禁用货位" name="action_location_status_disable" type="object" class="oe_highlight"
|
<button string="禁用货位" name="action_location_status_disable" type="object" class="oe_highlight"
|
||||||
attrs="{'invisible': [('location_status', '!=', '空闲')]}"/>
|
attrs="{'invisible': [('location_status', '!=', '空闲')]}"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user