Skip to content

Instantly share code, notes, and snippets.

@ruter
Last active March 23, 2018 09:10
Show Gist options
  • Save ruter/230f1a462d2c314a028fcc4b29a0f67e to your computer and use it in GitHub Desktop.
Save ruter/230f1a462d2c314a028fcc4b29a0f67e to your computer and use it in GitHub Desktop.
Odoo 中继承基础设置模块并增加基础配置项 #Odoo
# -*- coding: utf-8 -*-
import logging
from odoo import models, fields, api
_logger = logging.getLogger(__name__)
class BaseConfigSettings(models.TransientModel):
_inherit = 'base.config.settings'
access_key = fields.Char('Access Key')
@api.model
def get_default_access_key(self, fields):
ir_config = self.env['ir.config_parameter']
access_key = ir_config.get_param('access_key', '')
return dict(access_key=access_key)
@api.multi
def set_default_access_key(self):
self.ensure_one()
ir_config = self.env['ir.config_parameter']
access_key = self.access_key or ''
ir_config.set_param('access_key', access_key)
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment