[IMP] Factorize cleaning of records
parent
bcc698d158
commit
7d8c4905da
|
@ -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',
|
||||||
|
|
|
@ -54,16 +54,22 @@ class SuperCalendarConfigurator(models.Model):
|
||||||
string='Lines',
|
string='Lines',
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
def _clear_super_calendar_records(self):
|
||||||
def generate_calendar_records(self):
|
""" Remove old super_calendar records """
|
||||||
configurator_ids = self.search([])
|
|
||||||
super_calendar_pool = self.env['super.calendar']
|
super_calendar_pool = self.env['super.calendar']
|
||||||
|
|
||||||
# Remove old records
|
|
||||||
super_calendar_ids = super_calendar_pool.search([])
|
super_calendar_ids = super_calendar_pool.search([])
|
||||||
super_calendar_ids.unlink()
|
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
|
# 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…
Reference in New Issue