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.

78 lines
2.8 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Author: Nicolas Bessi. Copyright Camptocamp SA
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. ##############################################################################
  20. from openerp.osv import orm, fields
  21. from openerp import tools
  22. class ResCompany(orm.Model):
  23. _inherit = 'res.company'
  24. def _get_logo_secondary(self, cr, uid, ids, name, args, context=None):
  25. result = dict.fromkeys(ids, False)
  26. for obj in self.browse(cr, uid, ids, context=context):
  27. result[obj.id] = tools.image_get_resized_images(obj.logo_secondary)
  28. return result
  29. def _set_logo_secondary(self, cr, uid, id, name, value, args, context=None):
  30. return self.write(
  31. cr, uid, [id],
  32. {'image': tools.image_resize_image_big(value)},
  33. context=context
  34. )
  35. def _has_logo_secondary(self, cr, uid, ids, name, args, context=None):
  36. result = {}
  37. for obj in self.browse(cr, uid, ids, context=context):
  38. result[obj.id] = obj.logo_secondary != False
  39. return result
  40. _columns = {
  41. 'name_secondary': fields.char('Secondary name', size=128),
  42. 'logo_secondary': fields.binary("Logo Secondary"),
  43. 'image_medium': fields.function(
  44. _get_logo_secondary,
  45. fnct_inv=_set_logo_secondary,
  46. string="Medium-sized logo secondary",
  47. type="binary",
  48. multi="_get_logo_secondary",
  49. store={
  50. _inherit: (
  51. lambda self, cr, uid, ids, c={}:
  52. ids, ['logo_secondary'], 10
  53. ),
  54. }
  55. ),
  56. 'image_small': fields.function(
  57. _get_logo_secondary,
  58. fnct_inv=_set_logo_secondary,
  59. string="Small-sized logo secondary",
  60. type="binary",
  61. multi="_get_logo_secondary",
  62. store={
  63. _inherit: (
  64. lambda self, cr, uid, ids, c={}:
  65. ids, ['image'], 10),
  66. },
  67. ),
  68. 'has_logo_secondary': fields.function(
  69. _has_logo_secondary, type="boolean"
  70. ),
  71. }