[IMP] Factorize cleaning of records
parent
bcc698d158
commit
7d8c4905da
|
@ -28,7 +28,7 @@
|
|||
'category': 'Generic Modules/Others',
|
||||
'summary': 'This module allows to create configurable calendars.',
|
||||
'author': ('Agile Business Group, '
|
||||
'Alejandro Santana <alejandrosantana@anubia.es>, '
|
||||
'Alejandro Santana, '
|
||||
'Odoo Community Association (OCA)'),
|
||||
'website': 'http://www.agilebg.com',
|
||||
'license': 'AGPL-3',
|
||||
|
|
|
@ -54,16 +54,22 @@ class SuperCalendarConfigurator(models.Model):
|
|||
string='Lines',
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def generate_calendar_records(self):
|
||||
configurator_ids = self.search([])
|
||||
def _clear_super_calendar_records(self):
|
||||
""" Remove old super_calendar records """
|
||||
super_calendar_pool = self.env['super.calendar']
|
||||
|
||||
# Remove old records
|
||||
super_calendar_ids = super_calendar_pool.search([])
|
||||
super_calendar_ids.unlink()
|
||||
|
||||
@api.multi
|
||||
def generate_calendar_records(self):
|
||||
""" At every CRON execution, every 'super calendar' data is deleted
|
||||
and regenerated again. """
|
||||
|
||||
# Remove old records
|
||||
self._clear_super_calendar_records()
|
||||
|
||||
# Rebuild all calendar records
|
||||
configurator_ids = self.search([])
|
||||
for configurator in configurator_ids:
|
||||
for line in configurator.line_ids:
|
||||
self._generate_record_from_line(configurator, line)
|
||||
|
|
Loading…
Reference in New Issue