# -*- coding: utf-8 -*- import logging import math import requests from dateutil.relativedelta import relativedelta from datetime import timedelta, datetime import requests import json import time import datetime from odoo import models, fields, api from odoo.exceptions import ValidationError import logging _logger = logging.getLogger(__name__) MRS = 'https://mrs.cs.jikimo.com' class MrsProductionMaterials(models.Model): _inherit = "mrs.production.materials" _description = "材料" url = '/api/production_materials/list' def sync_production_materials(self): timestamp_str = int(time.time()) headers = {'TOKEN': '4130d97c-37be-11ed-84a7-f8b54df29535', 'TIMESTAMP': '1663859413', 'check_str': 'e840309b4ac386b5b9005dfb85ca9e9eee7149bd'} str = MRS + self.url print(str) r = requests.post(str, data=None, json={},headers=headers) r = r.json() data = json.loads(r['result']) if data['status'] == 1: production_materials_list = data['production_materials_list'] if production_materials_list: for item in production_materials_list: port = self.env['mrs.production.materials'].search([('materials_no', '=', item.materials_no)]) if not port: port = item else: return "访问失败" class MrsMaterialModel(models.Model): _inherit = 'mrs.materials.model' _description = '材料型号' class MrsProductionProcess(models.Model): _inherit = 'mrs.production.process' _description = '表面工艺' class MrsProcessingTechnology(models.Model): _inherit = 'mrs.processing.technology' _description = '加工工艺' class MachineBrandTags(models.Model): _inherit = 'mrs.machine.brand.tags' _description = '标签' class MachineControlSystem(models.Model): _inherit = 'mrs.machine_tool.type.control_system' _description = '控制系统' class MachineBrand(models.Model): _inherit = 'mrs.machine.brand' _description = '品牌' class MachineTool(models.Model): _inherit = 'mrs.machine_tool' _description = '机床' class MachineToolType(models.Model): _inherit = 'mrs.machine_tool.type' _description = '机床型号' class CuttingTool(models.Model): _inherit = 'mrs.cutting_tool.category' _description = '刀具类别' class CuttingToolType(models.Model): _inherit = 'mrs.cutting_tool.type' _description = '刀具型号'