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.2 KiB

  1. # Copyright 2017 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo 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'].sudo().get_param(
  15. 'ribbon.name')
  16. vals = self._prepare_ribbon_format_vals()
  17. return name_tmpl and name_tmpl.format(**vals) or name_tmpl
  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.sudo().get_param('ribbon.color'),
  29. 'background_color': ir_config_model.sudo().get_param(
  30. 'ribbon.background.color'),
  31. }