[FIX] Factorize and clean
parent
4694c8ca46
commit
b57f68a1b0
|
@ -39,7 +39,7 @@ def _models_get(self):
|
||||||
return [(model.model, model.name) for model in model_ids]
|
return [(model.model, model.name) for model in model_ids]
|
||||||
|
|
||||||
|
|
||||||
class super_calendar_configurator(models.Model):
|
class SuperCalendarConfigurator(models.Model):
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
_name = 'super.calendar.configurator'
|
_name = 'super.calendar.configurator'
|
||||||
|
|
||||||
|
@ -66,10 +66,16 @@ class super_calendar_configurator(models.Model):
|
||||||
# Rebuild all calendar records
|
# Rebuild all calendar records
|
||||||
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._logger.info('Calendar generated')
|
||||||
|
return True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _generate_record_from_line(self, configurator, line):
|
||||||
|
super_calendar_pool = self.env['super.calendar']
|
||||||
current_pool = self.env[line.name.model]
|
current_pool = self.env[line.name.model]
|
||||||
domain = line.domain and safe_eval(line.domain) or []
|
domain = line.domain and safe_eval(line.domain) or []
|
||||||
current_record_ids = current_pool.search(domain)
|
current_record_ids = current_pool.search(domain)
|
||||||
|
|
||||||
for cur_rec in current_record_ids:
|
for cur_rec in current_record_ids:
|
||||||
f_user = line.user_field_id and line.user_field_id.name
|
f_user = line.user_field_id and line.user_field_id.name
|
||||||
f_descr = (line.description_field_id and
|
f_descr = (line.description_field_id and
|
||||||
|
@ -132,11 +138,9 @@ class super_calendar_configurator(models.Model):
|
||||||
'model_id': line.name.id,
|
'model_id': line.name.id,
|
||||||
}
|
}
|
||||||
super_calendar_pool.create(super_calendar_values)
|
super_calendar_pool.create(super_calendar_values)
|
||||||
self._logger.info('Calendar generated')
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class super_calendar_configurator_line(models.Model):
|
class SuperCalendarConfiguratorLine(models.Model):
|
||||||
_name = 'super.calendar.configurator.line'
|
_name = 'super.calendar.configurator.line'
|
||||||
|
|
||||||
name = fields.Many2one(
|
name = fields.Many2one(
|
||||||
|
@ -196,7 +200,7 @@ class super_calendar_configurator_line(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class super_calendar(models.Model):
|
class SuperCalendar(models.Model):
|
||||||
_name = 'super.calendar'
|
_name = 'super.calendar'
|
||||||
|
|
||||||
name = fields.Char(
|
name = fields.Char(
|
||||||
|
|
|
@ -76,7 +76,6 @@
|
||||||
<tree string="Calendar">
|
<tree string="Calendar">
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="date_start"/>
|
<field name="date_start"/>
|
||||||
<!--<field name="date_stop"/>-->
|
|
||||||
<field name="duration"/>
|
<field name="duration"/>
|
||||||
<field name="user_id"/>
|
<field name="user_id"/>
|
||||||
<field name="configurator_id"/>
|
<field name="configurator_id"/>
|
||||||
|
@ -95,7 +94,6 @@
|
||||||
<group>
|
<group>
|
||||||
<field name="name" readonly="1"/>
|
<field name="name" readonly="1"/>
|
||||||
<field name="date_start" readonly="1"/>
|
<field name="date_start" readonly="1"/>
|
||||||
<!--<field name="date_stop" readonly="1"/>-->
|
|
||||||
<field name="duration" readonly="1"/>
|
<field name="duration" readonly="1"/>
|
||||||
<field name="user_id" readonly="1"/>
|
<field name="user_id" readonly="1"/>
|
||||||
<field name="configurator_id" readonly="1"/>
|
<field name="configurator_id" readonly="1"/>
|
||||||
|
|
Loading…
Reference in New Issue