95 lines
4.8 KiB
Python
Executable File
95 lines
4.8 KiB
Python
Executable File
from odoo import fields, models, _
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class DssAdvertisefieldsCreateFromTemplateWizard(models.TransientModel):
|
|
_name = "dss.advertisefields.create.from.template.wizard"
|
|
_description = "Werbefelder aus Vorlage erstellen"
|
|
|
|
display_template_id = fields.Many2one(
|
|
'dss.display.templates',
|
|
string='Vorlage',
|
|
required=True,
|
|
)
|
|
project_id = fields.Many2one(
|
|
'dss.projects',
|
|
string='Neues Projekt',
|
|
required=True,
|
|
)
|
|
|
|
def action_create_fields(self):
|
|
self.ensure_one()
|
|
|
|
template_fields = self.env['dss.advertisefields.templates'].search([
|
|
('displaytemplate', '=', self.display_template_id.id)
|
|
])
|
|
if not template_fields:
|
|
raise ValidationError(_("Für die gewählte Vorlage wurden keine Werbefelder gefunden."))
|
|
|
|
create_vals = []
|
|
project_identifier = self.project_id.projectid or self.project_id.id
|
|
for template_field in template_fields:
|
|
feldname = template_field.feldname or template_field.templatefeldname
|
|
create_vals.append({
|
|
'feldname': feldname,
|
|
'auto_feldname': f"{project_identifier}_{feldname}",
|
|
'project': self.project_id.id,
|
|
'display': template_field.display,
|
|
'color_used': template_field.color_used,
|
|
'color_unused': template_field.color_unused,
|
|
'mediastructure': template_field.mediastructure.id,
|
|
'is_btn': template_field.is_btn,
|
|
'btn_displaytemplate': self.display_template_id.id,
|
|
'btn_fromtemplate': template_field.id,
|
|
'btn_pos_x': template_field.btn_pos_x,
|
|
'btn_pos_y': template_field.btn_pos_y,
|
|
'btn_pos_w': template_field.btn_pos_w,
|
|
'btn_pos_h': template_field.btn_pos_h,
|
|
'btn_name': template_field.btn_name,
|
|
'btn_image': template_field.btn_image,
|
|
'btn_fieldname': template_field.btn_fieldname,
|
|
'btn_visible': template_field.btn_visible,
|
|
'btn_active': template_field.btn_active,
|
|
'btn_action_inactive': template_field.btn_action_inactive,
|
|
'btn_action_active': template_field.btn_action_active,
|
|
'btn_playlist_zuordnung': template_field.btn_playlist_zuordnung,
|
|
'btn_gallery_rows': template_field.btn_gallery_rows,
|
|
'btn_gallery_cols': template_field.btn_gallery_cols,
|
|
'btn_gallery_prv_w': template_field.btn_gallery_prv_w,
|
|
'btn_gallery_prv_h': template_field.btn_gallery_prv_h,
|
|
'btn_has_timer': template_field.btn_has_timer,
|
|
'btn_has_timer_time': template_field.btn_has_timer_time,
|
|
'btn_editable': template_field.btn_editable,
|
|
'btn_special_actionimage': template_field.btn_special_actionimage,
|
|
'btn_special_actionimage_x': template_field.btn_special_actionimage_x,
|
|
'btn_special_actionimage_y': template_field.btn_special_actionimage_y,
|
|
'btn_special_actionimage_w': template_field.btn_special_actionimage_w,
|
|
'btn_special_actionimage_h': template_field.btn_special_actionimage_h,
|
|
'btn_special_actionimage_time': template_field.btn_special_actionimage_time,
|
|
'btn_text_1_visible': template_field.btn_text_1_visible,
|
|
'btn_text_2_visible': template_field.btn_text_2_visible,
|
|
'btn_text_3_visible': template_field.btn_text_3_visible,
|
|
'btn_text_4_visible': template_field.btn_text_4_visible,
|
|
'btn_text_1_pos_x': template_field.btn_text_1_pos_x,
|
|
'btn_text_1_pos_y': template_field.btn_text_1_pos_y,
|
|
'btn_text_2_pos_x': template_field.btn_text_2_pos_x,
|
|
'btn_text_2_pos_y': template_field.btn_text_2_pos_y,
|
|
'btn_text_3_pos_x': template_field.btn_text_3_pos_x,
|
|
'btn_text_3_pos_y': template_field.btn_text_3_pos_y,
|
|
'btn_text_4_pos_x': template_field.btn_text_4_pos_x,
|
|
'btn_text_4_pos_y': template_field.btn_text_4_pos_y,
|
|
'btn_text_1_font': template_field.btn_text_1_font,
|
|
'btn_text_2_font': template_field.btn_text_2_font,
|
|
'btn_text_3_font': template_field.btn_text_3_font,
|
|
'btn_text_4_font': template_field.btn_text_4_font,
|
|
})
|
|
|
|
created_fields = self.env['dss.advertisefields'].create(create_vals)
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': _('Erstellte Werbefelder'),
|
|
'res_model': 'dss.advertisefields',
|
|
'view_mode': 'tree,form',
|
|
'domain': [('id', 'in', created_fields.ids)],
|
|
}
|