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.

37 lines
1.1 KiB

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