30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
# -*- 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("数据错误导致同步失败,请联系管理员") |