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.

69 lines
2.2 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. ###################################################################################
  2. #
  3. # Copyright (C) 2018 MuK IT GmbH
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU Affero General Public License as
  7. # published by the Free Software Foundation, either version 3 of the
  8. # License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Affero General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. ###################################################################################
  19. import logging
  20. from odoo import api, models, fields
  21. from odoo.addons.muk_fields_lobject.fields.lobject import LargeObject
  22. _logger = logging.getLogger(__name__)
  23. class Store(models.Model):
  24. _name = 'muk_converter.store'
  25. _description = 'Converter Store'
  26. #----------------------------------------------------------
  27. # Database
  28. #----------------------------------------------------------
  29. name = fields.Char(
  30. compute="_compute_name",
  31. string="Name",
  32. store=True)
  33. used_date = fields.Datetime(
  34. string="Used on",
  35. default=fields.Datetime.now)
  36. checksum = fields.Char(
  37. string="Checksum",
  38. required=True)
  39. format = fields.Char(
  40. string="Format",
  41. required=True)
  42. content_fname = fields.Char(
  43. string="Filename",
  44. required=True)
  45. content = LargeObject(
  46. string="Data",
  47. required=True)
  48. #----------------------------------------------------------
  49. # Read
  50. #----------------------------------------------------------
  51. @api.depends('checksum', 'content_fname')
  52. def _compute_name(self):
  53. for record in self:
  54. record.name = "%s (%s)" % (record.content_fname, record.checksum)