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.

38 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 ACSONE SA/NV
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp import api, models
  5. class WebEnvironmentRibbonBackend(models.AbstractModel):
  6. _name = 'web.environment.ribbon.backend'
  7. _description = 'Web Environment Ribbon Backend'
  8. @api.model
  9. def _prepare_ribbon_format_vals(self):
  10. return {
  11. 'db_name': self.env.cr.dbname,
  12. }
  13. @api.model
  14. def _prepare_ribbon_name(self):
  15. name_tmpl = self.env['ir.config_parameter'].get_param('ribbon.name')
  16. vals = self._prepare_ribbon_format_vals()
  17. return name_tmpl.format(**vals)
  18. @api.model
  19. def get_environment_ribbon(self):
  20. """
  21. This method returns the ribbon data from ir config parameters
  22. :return: dictionary
  23. """
  24. ir_config_model = self.env['ir.config_parameter']
  25. name = self._prepare_ribbon_name()
  26. return {
  27. 'name': name,
  28. 'color': ir_config_model.get_param('ribbon.color'),
  29. 'background_color': ir_config_model.get_param(
  30. 'ribbon.background.color'),
  31. }