Browse Source

[IMP] Factorize cleaning of records

pull/139/head
Alejandro Santana 10 years ago
parent
commit
7d8c4905da
  1. 2
      super_calendar/__openerp__.py
  2. 14
      super_calendar/models/super_calendar.py

2
super_calendar/__openerp__.py

@ -28,7 +28,7 @@
'category': 'Generic Modules/Others', 'category': 'Generic Modules/Others',
'summary': 'This module allows to create configurable calendars.', 'summary': 'This module allows to create configurable calendars.',
'author': ('Agile Business Group, ' 'author': ('Agile Business Group, '
'Alejandro Santana <alejandrosantana@anubia.es>, '
'Alejandro Santana, '
'Odoo Community Association (OCA)'), 'Odoo Community Association (OCA)'),
'website': 'http://www.agilebg.com', 'website': 'http://www.agilebg.com',
'license': 'AGPL-3', 'license': 'AGPL-3',

14
super_calendar/models/super_calendar.py

@ -54,16 +54,22 @@ class SuperCalendarConfigurator(models.Model):
string='Lines', string='Lines',
) )
def _clear_super_calendar_records(self):
""" Remove old super_calendar records """
super_calendar_pool = self.env['super.calendar']
super_calendar_ids = super_calendar_pool.search([])
super_calendar_ids.unlink()
@api.multi @api.multi
def generate_calendar_records(self): def generate_calendar_records(self):
configurator_ids = self.search([])
super_calendar_pool = self.env['super.calendar']
""" At every CRON execution, every 'super calendar' data is deleted
and regenerated again. """
# Remove old records # Remove old records
super_calendar_ids = super_calendar_pool.search([])
super_calendar_ids.unlink()
self._clear_super_calendar_records()
# Rebuild all calendar records # Rebuild all calendar records
configurator_ids = self.search([])
for configurator in configurator_ids: for configurator in configurator_ids:
for line in configurator.line_ids: for line in configurator.line_ids:
self._generate_record_from_line(configurator, line) self._generate_record_from_line(configurator, line)

Loading…
Cancel
Save