56 lines
2.3 KiB
Python
56 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of SmartGo. See LICENSE file for full copyright and licensing details.
|
|
import logging
|
|
|
|
from odoo import api, fields, models
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class ResConfigSettings(models.TransientModel):
|
|
_inherit = 'res.config.settings'
|
|
|
|
token = fields.Char(string='TOKEN', default='b811ac06-3f00-11ed-9aed-0242ac110003')
|
|
mrs_secret_key = fields.Char(string='密钥', default= 'wBmxej38OkErKhD6')
|
|
mrs_url = fields.Char(string='访问地址', default= 'https://mrs.cs.jikimo.com')
|
|
|
|
def sf_all_sync(self):
|
|
self.env['mrs.production.materials'].sync_all_production_materials()
|
|
self.env['mrs.materials.model'].sync_all_materials_model()
|
|
self.env['mrs.production.process'].sync_all_production_process()
|
|
self.env['mrs.processing.technology'].sync_all_processing_technology()
|
|
self.env['mrs.machine.brand.tags'].sync_all_machine_brand_tags()
|
|
self.env['mrs.machine_tool.type.control_system'].sync_all_machine_tool_type_control_system()
|
|
self.env['mrs.machine.brand'].sync_all_machine_brand()
|
|
self.env['mrs.machine_tool'].sync_all_machine_tool()
|
|
self.env['mrs.machine_tool.type'].sync_all_machine_tool_type()
|
|
self.env['mrs.cutting_tool.category'].sync_all_cutting_tool_category()
|
|
self.env['mrs.cutting_tool.type'].sync_all_cutting_tool_type()
|
|
|
|
@api.model
|
|
def get_values(self):
|
|
"""
|
|
重载获取参数的方法,参数都存在系统参数中
|
|
:return:
|
|
"""
|
|
values = super(ResConfigSettings, self).get_values()
|
|
config = self.env['ir.config_parameter'].sudo()
|
|
token = config.get_param('token', default='')
|
|
mrs_secret_key = config.get_param('mrs_secret_key', default='')
|
|
mrs_url = config.get_param('mrs_url', default='')
|
|
|
|
values.update(
|
|
token=token,
|
|
mrs_secret_key=mrs_secret_key,
|
|
mrs_url=mrs_url,
|
|
)
|
|
return values
|
|
|
|
def set_values(self):
|
|
super(ResConfigSettings, self).set_values()
|
|
ir_config = self.env['ir.config_parameter'].sudo()
|
|
ir_config.set_param("token", self.token or "")
|
|
ir_config.set_param("mrs_secret_key", self.mrs_secret_key or "")
|
|
ir_config.set_param("mrs_url", self.mrs_url or "")
|
|
|