You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. import os
  3. from odoo import models, fields, api
  4. from odoo.exceptions import ValidationError
  5. class ConfigSettings(models.TransientModel):
  6. _name = 'galicea_git.config.settings'
  7. _inherit = 'res.config.settings'
  8. git_http_backend = fields.Char(
  9. 'Absolute path to Git HTTP backend',
  10. required=True
  11. )
  12. git_http_backend_valid = fields.Boolean(
  13. compute='_compute_git_http_backend_valid'
  14. )
  15. @api.one
  16. @api.depends('git_http_backend')
  17. def _compute_git_http_backend_valid(self):
  18. self.git_http_backend_valid = self.git_http_backend and os.access(self.git_http_backend, os.X_OK)
  19. @api.one
  20. def set_params(self):
  21. self.env['ir.config_parameter'].set_param('galicea_git.git_http_backend', self.git_http_backend)
  22. @api.model
  23. def get_default_values(self, fields):
  24. return {
  25. 'git_http_backend': self.env['ir.config_parameter'].get_param('galicea_git.git_http_backend')
  26. }
  27. @api.multi
  28. def execute(self):
  29. self.ensure_one()
  30. if not self.env.user.has_group('galicea_git.group_admin'):
  31. raise AccessError("Only Git administrators can change those settings")
  32. super(ConfigSettings, self.sudo()).execute()
  33. act_window = self.env.ref('galicea_git.config_settings_action')
  34. return act_window.read()[0]