calendar.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # -*- encoding: utf-8 -*-
  2. ########################################################################
  3. #
  4. # @authors: Ignacio Ibeas <ignacio@acysos.com>
  5. # Daniel Pascal <daniel@acysos.com>
  6. # Copyright (C) 2013 Acysos S.L.
  7. #
  8. #This program is free software: you can redistribute it and/or modify
  9. #it under the terms of the GNU General Public License as published by
  10. #the Free Software Foundation, either version 3 of the License, or
  11. #(at your option) any later version.
  12. #
  13. # This module is GPLv3 or newer and incompatible
  14. # with OpenERP SA "AGPL + Private Use License"!
  15. #
  16. #This program is distributed in the hope that it will be useful,
  17. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. #GNU General Public License for more details.
  20. #
  21. #You should have received a copy of the GNU General Public License
  22. #along with this program. If not, see http://www.gnu.org/licenses.
  23. ########################################################################
  24. from openerp import models, fields, api, _
  25. import openerp.addons.decimal_precision as dp
  26. import time
  27. class CalendarEvent(models.Model):
  28. _inherit = 'calendar.event'
  29. top_id = fields.Many2one('real.estate.top', 'Top', required=False)
  30. @api.onchange('top_id')
  31. def onchange_top_id(self):
  32. if self.top_id:
  33. name = self.top_id.name + '-' + self.top_id.address
  34. if self.top_id.number != False:
  35. name += ' ' + self.top_id.number
  36. if self.top_id.floor != False:
  37. name += ' ' + self.top_id.floor
  38. if self.top_id.stair != False:
  39. name += ' ' + self.top_id.stair
  40. self.location = name