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.

108 lines
3.3 KiB

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # mis_builder module for Odoo, Management Information System Builder
  5. # Copyright (C) 2014-2015 ACSONE SA/NV (<http://acsone.eu>)
  6. #
  7. # This file is a part of mis_builder
  8. #
  9. # mis_builder is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU Affero General Public License v3 or later
  11. # as published by the Free Software Foundation, either version 3 of the
  12. # License, or (at your option) any later version.
  13. #
  14. # mis_builder is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU Affero General Public License v3 or later for more details.
  18. #
  19. # You should have received a copy of the GNU Affero General Public License
  20. # v3 or later along with this program.
  21. # If not, see <http://www.gnu.org/licenses/>.
  22. #
  23. ##############################################################################
  24. from openerp import api, fields, models, exceptions
  25. class MisReportKpi(models.Model):
  26. _inherit='mis.report.kpi'
  27. @api.depends('kpi_style')
  28. def calc_css_style(self):
  29. css_attributes = [
  30. ('font-style', self.kpi_style.font_style),
  31. ('font-weight', self.kpi_style.font_weight),
  32. ('font-size', self.kpi_style.font_size),
  33. ('color', self.kpi_style.color),
  34. ('background-color', self.kpi_style.background_color),
  35. ('indent-level', str(self.kpi_style.indent_level))
  36. ]
  37. css_list = [
  38. x[0] + ':' + x[1] for x in css_attributes if x[1]
  39. ]
  40. self.default_css_style = ';'.join(css_item for css_item in css_list)
  41. # Adding Attributes to default_css_style
  42. default_css_style = fields.Char(compute=calc_css_style, store=True)
  43. kpi_style = fields.Many2one(
  44. string="Default CSS style for KPI",
  45. comodel_name="mis.report.kpi.style",
  46. required=True
  47. )
  48. class MisReportKpiStyle(models.Model):
  49. _name = 'mis.report.kpi.style'
  50. # TODO use WEB WIdget color picker
  51. name = fields.Char(string='style name', required=True)
  52. @api.depends('indent_level')
  53. def check_positive_val(self):
  54. return self.indent_level > 0
  55. _font_style_selection = [
  56. ('normal', 'Normal'),
  57. ('italic', 'Italic'),
  58. ]
  59. _font_weight_selection = [
  60. ('nornal', 'Normal'),
  61. ('bold', 'Bold'),
  62. ]
  63. _font_size_selection = [
  64. ('medium', ''),
  65. ('xx-small', 'xx-small'),
  66. ('x-small', 'x-small'),
  67. ('small', 'small'),
  68. ('large', 'large'),
  69. ('x-large', 'x-large'),
  70. ('xx-large', 'xx-large'),
  71. ]
  72. color = fields.Char(
  73. required=True,
  74. help='Line color in valid RGB code (from #000000 to #FFFFFF)',
  75. )
  76. background_color = fields.Char(
  77. required=True,
  78. help='Line color in valid RGB code (from #000000 to #FFFFFF)'
  79. )
  80. font_style = fields.Selection(
  81. selection=_font_style_selection,
  82. )
  83. font_weight = fields.Selection(
  84. selection=_font_weight_selection
  85. )
  86. font_size = fields.Selection(
  87. selection=_font_size_selection
  88. )
  89. indent_level = fields.Integer()