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.

26 lines
952 B

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Therp BV <http://therp.nl>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from dateutil.rrule import YEARLY, rrule
  5. from openerp import api, fields, models
  6. from openerp.addons.field_rrule.field_rrule import FieldRRule,\
  7. SerializableRRuleSet
  8. class ResPartner(models.Model):
  9. _inherit = 'res.partner'
  10. @api.depends('rrule')
  11. def _compute_rrule_representation(self):
  12. for this in self:
  13. if not this.rrule:
  14. this.rrule_representation = 'You did not fill in rules yet'
  15. continue
  16. this.rrule_representation = 'First 5 dates: %s\n%s' % (
  17. ', '.join(map(str, this.rrule[:5])),
  18. this.rrule,
  19. )
  20. rrule = FieldRRule('RRule', default=SerializableRRuleSet(rrule(YEARLY)))
  21. rrule_representation = fields.Text(
  22. string='RRule representation', compute=_compute_rrule_representation)