577 lines
26 KiB
Python
577 lines
26 KiB
Python
import ast
|
|
import datetime
|
|
import json
|
|
import re
|
|
import uuid
|
|
import logging
|
|
import base64
|
|
import subprocess
|
|
import tempfile
|
|
import easywebdav
|
|
import os
|
|
import os.path
|
|
|
|
|
|
from odoo import api, fields, models, _
|
|
from odoo import tools
|
|
from odoo.exceptions import ValidationError
|
|
from datetime import date
|
|
from datetime import datetime
|
|
from dateutil.relativedelta import relativedelta
|
|
from pyffmpeg import FFmpeg
|
|
from tuya_iot import TuyaOpenAPI, TUYA_LOGGER
|
|
from tuya_connector import TuyaOpenAPI, TUYA_LOGGER
|
|
import sys
|
|
|
|
TUYA_LOGGER.setLevel(logging.DEBUG)
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class dsscontractads(models.Model):
|
|
|
|
def _default_work_state(self):
|
|
ds = self.env['dss.workstate'].search([('statusname', '=', 'Neu')], limit=1).id
|
|
_logger.debug(ds)
|
|
return ds
|
|
|
|
def _default_work_state_color(self):
|
|
ds = self.env['dss.workstate'].search([('statusname', '=', 'Neu')], limit=1).color
|
|
_logger.info(ds)
|
|
return ds
|
|
|
|
def _default_todo_state(self):
|
|
ds = self.env['dss.todostate'].search([('statusnr', '=', '0')], limit=1).id
|
|
if not ds: ds = 1
|
|
_logger.debug(ds)
|
|
# ds =
|
|
return ds
|
|
|
|
@api.model
|
|
def create(self, vals):
|
|
result = super().create(vals)
|
|
resstr = result.uuid
|
|
_logger.info(resstr)
|
|
for n_record in result:
|
|
resstr = n_record.uuid
|
|
_logger.info(resstr)
|
|
n_record.date_create = date.today()
|
|
n_record.user_create = self.env.user.name
|
|
allads = n_record.contract.ads
|
|
_logger.info(allads)
|
|
if allads != False:
|
|
for ad in allads:
|
|
ad.ad_is_lastpos = False
|
|
n_record.ad_is_lastpos = True
|
|
contract = n_record.contract
|
|
contract.ads_last_ad = n_record
|
|
return result
|
|
|
|
# @api.depends('need_media')
|
|
# def _getmedialist(self):
|
|
# mlist = []
|
|
# mlist = self.env['dss.mediarelations'].search([('ad','=',self.id)])
|
|
# if mlist != False:
|
|
# _logger.info('AD Need_Medias A_'+str(self)+' - Computed Medias '+str(mlist))
|
|
# self.need_media = mlist.ids
|
|
# else:
|
|
# self.need_media = False
|
|
|
|
_name = "dss.ads"
|
|
_description = "DigitalSignage Werbekampagnen Phasen"
|
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
|
# _inherit = ['mail.activity.mixin']
|
|
# 'mail.thread','mail.activity.mixin'
|
|
_rec_name = "adname"
|
|
# _inherit = ['mail.thread', 'mail.activity.mixin']
|
|
uuid = fields.Char(default=lambda self: self._default_uuid(), required=True, readonly=True, copy=False,
|
|
string='UUID')
|
|
aduuid = fields.Char(related='uuid')
|
|
|
|
date_create = fields.Date('Erstellungsdatum', default=lambda self: self._default_create_date())
|
|
date_lastedit = fields.Date('Änderungsdatum')
|
|
user_create = fields.Char('Erstellungsuser', default=lambda self: self._default_create_user())
|
|
user_lastedit = fields.Char('Änderungsuser')
|
|
# uuid = fields.Char('UUID', required=True, translate=True)
|
|
adname = fields.Char('Kampagnenname', required=True, tracking=True)
|
|
adtype = fields.Selection(
|
|
[('MAIN', 'Ersteinrichtung'), ('KCHN', 'Änderung durch Kunde'), ('LCHN', 'Änderung durch Logumedia'),
|
|
('SONS', 'Sonstige Änderung')], tracking=True)
|
|
adpos = fields.Integer('Reihenfolge', default=lambda self: self._default_adpos(),
|
|
tracking=True)
|
|
ad_is_lastpos = fields.Boolean('Letzte Aktion', tracking=True)
|
|
|
|
start_date = fields.Date('gew. Ausstrahl.Begin', tracking=True)
|
|
end_date = fields.Date('gew. Ausstrahl.Ende', tracking=True)
|
|
|
|
contract = fields.Many2one('dss.contracts', store=True, tracking=True)
|
|
contract_id = fields.Char(related='contract.contract_id')
|
|
contract_name = fields.Char(related='contract.contract_name')
|
|
contract_need_media = fields.Many2many(related='contract.need_media', tracking=True)
|
|
|
|
project = fields.Many2one('dss.projects', string='Project', store=True, tracking=True)
|
|
project_id = fields.Integer(related='project.projectid', string='Project ID')
|
|
|
|
parent_ad = fields.Many2one('dss.ads', string='UrsprungsWerbung', store=True)
|
|
parent_ad_uuid = fields.Char(related='parent_ad.uuid')
|
|
description = fields.Text('Beschreibung')
|
|
amount = fields.Float('Extrakosten', tracking=True)
|
|
order = fields.Integer('Reihenfolge', tracking=True)
|
|
|
|
# need_media = fields.Many2many('dss.mediarelations','ad',string='Medien')
|
|
need_media = fields.One2many('dss.mediarelations', 'ad', string='Medien')
|
|
|
|
work_state = fields.Many2one('dss.workstate', default=_default_work_state, tracking=True)
|
|
work_state_color = fields.Char(related='work_state.color')
|
|
work_state_text = fields.Char(related='work_state.statusname')
|
|
work_state_info = fields.Char('Zusatzinfo')
|
|
|
|
ad_state = fields.Many2one('dss.adstate', tracking=True)
|
|
ad_state_color = fields.Char(related='ad_state.color')
|
|
ad_state_text = fields.Char(related='ad_state.statusname')
|
|
ad_state_func = fields.Selection(related='ad_state.func')
|
|
|
|
todo_state = fields.Many2one('dss.todostate', default=_default_todo_state,
|
|
tracking=True)
|
|
todo_state_color = fields.Char(related='todo_state.color')
|
|
todo_state_text = fields.Char(related='todo_state.statusname')
|
|
todo_state_info = fields.Char('Zusatzinfo', tracking=True)
|
|
todo_state_until = fields.Date('Abarbeiten bis', tracking=True)
|
|
|
|
cloud_add_directory = fields.Char('Cloud KundenKampagnen Ordner', tracking=True)
|
|
|
|
date_zuarbeit = fields.Date(string='Zuarbeit Datum', help='Zuarbeit gesendet am', tracking=True)
|
|
date_korrekturabzug = fields.Date(string='K.Abzug Datum', help='Korrekturabzug gesendet am')
|
|
date_korrekturfreigabe = fields.Date(string='K.Freigabe Datum', help='Korrekturfreigabe erhalten am',
|
|
tracking=True)
|
|
date_korrekturfreigabe_frist = fields.Date(string='K.Freigabe bis Datum', help='Korrekturfreigabe sollte bis .... erfolgen')
|
|
freigabe_durch_ablauf = fields.Boolean(string='Zeitablauf',help='Freigabe wurde durch Zeitablauf erreicht ?', tracking=True)
|
|
|
|
@api.model
|
|
def _default_uuid(self):
|
|
return str(uuid.uuid4())
|
|
|
|
def _default_create_date(self):
|
|
return str(date.today())
|
|
|
|
def _default_create_user(self):
|
|
return str(self.env.user.name)
|
|
|
|
def _default_adpos(self):
|
|
pos = self.env['dss.ads'].search_count([('contract_id', '=', self.contract.id)]) + 1
|
|
return str(pos)
|
|
|
|
@api.onchange('ad_state')
|
|
def _onchange_ad_state(self):
|
|
for record in self:
|
|
if record.ad_is_lastpos == True:
|
|
contract = record.contract
|
|
contract.ads_last_state = record.ad_state
|
|
# mtyp = self.env['dss.adstructures'].search([("uuid","=",str(record.mediastructure.uuid))])
|
|
# buildmediarelations(self)
|
|
self.date_lastedit = str(date.today())
|
|
|
|
# self.mediastructure = mtyp
|
|
|
|
def pyaction_view_ad_details(self):
|
|
action = self.env['ir.actions.act_window'].with_context({'default_adid': self.id})._for_xml_id(
|
|
'DigitalSignage.action_dss_ads_view')
|
|
# action['display_name'] = self.ad_name
|
|
# action['domain'] = '[["projectid","=","4"]]'
|
|
# context = action['context'].replace('', str(self.id))
|
|
# context = ast.literal_eval(context)
|
|
# context.update({
|
|
# 'create': self.active,
|
|
# 'active_test': self.active
|
|
# })
|
|
# action['context'] = context
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'view_type': 'form',
|
|
'view_mode': 'form,tree',
|
|
'res_model': 'dss.ads',
|
|
'target': 'current',
|
|
'context': '',
|
|
'res_id': self.id,
|
|
'display_name': ' ' + self.adname,
|
|
'domain': ''
|
|
}
|
|
|
|
return action
|
|
|
|
def pydoviewallads(self):
|
|
action = self.env['ir.actions.act_window'].with_context({'default_adid': self.id})._for_xml_id(
|
|
'DigitalSignage.act_dss_ads_view_full')
|
|
action['display_name'] = self.contract_name
|
|
# action['domain'] = '[["projectid","=","4"]]'
|
|
# context = action['context'].replace('', str(self.id))
|
|
# context = ast.literal_eval(context)
|
|
# context.update({
|
|
# 'create': self.active,
|
|
# 'active_test': self.active
|
|
# })
|
|
# action['context'] = context
|
|
# return {
|
|
# 'type': 'ir.actions.act_window',
|
|
# 'view_type':'form',
|
|
# 'view_mode':'form,tree',
|
|
# 'res_model':'dss.ads',
|
|
# 'target':'current',
|
|
# 'context':'',
|
|
# 'res_id':kampagne.id,
|
|
# 'display_name' : 'Werbekampagne '+kampagne.adname,
|
|
# 'domain':'[("contract","=","context[active_id]")]'
|
|
# }
|
|
# return action
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'view_type': 'kanban',
|
|
'view_mode': 'kanban',
|
|
'res_model': 'dss.ads',
|
|
'target': 'current',
|
|
'context': '{"group_by":["parent_ad"]}',
|
|
# 'res_id':self.parent_ad,
|
|
'display_name': 'Übersicht für ' + self.adname,
|
|
'domain': [("contract", "=", self.contract.id)]
|
|
}
|
|
|
|
def pydonewad(self):
|
|
for n_record in self:
|
|
resstr = n_record.uuid
|
|
_logger.info(resstr)
|
|
allads = n_record.contract.ads
|
|
_logger.info(allads)
|
|
abort = False
|
|
if allads != False:
|
|
for ad in allads:
|
|
if ad.ad_state.func != 'FIN':
|
|
abort = True
|
|
if abort == False:
|
|
defadstate = self.env['dss.adstate'].search([('func', '=', 'STD')], limit=1).id
|
|
if not defadstate:
|
|
defadstate = 1
|
|
if self.ad_state.func == 'STD':
|
|
parent_id = self.id
|
|
else:
|
|
parent_id = self.parent_ad.id
|
|
newkampagne = self.env['dss.ads'].create({'contract': self.contract.id, 'project': self.project.id,
|
|
'adname': 'AD_' + self.contract.contract_auto_name + ' ' + str(
|
|
date.today()), 'parent_ad': parent_id, 'adtype': 'KCHN',
|
|
'ad_state': defadstate})
|
|
_logger.info('C_' + str(self.id) + ' Kampagne erzeugt : ' + str(newkampagne))
|
|
_logger.info('Prüfe Medien : C_' + str(self.id) + 'K_' + str(newkampagne.id))
|
|
|
|
mediaids = []
|
|
for feld in self.contract.werbe_feld_selected:
|
|
for media in feld.mediastructure.medias:
|
|
if not media:
|
|
_logger.info('Prüfe Medien : C_' + str(self.contract.id) + 'K_' + str(
|
|
newkampagne.id) + ' Kein Medium in MedienStructur von F_' + str(feld.id) + 'M_' + str(
|
|
media.id))
|
|
else:
|
|
newmedia = self.env['dss.mediarelations'].create(
|
|
{'field': feld.id, 'contract': self.contract.id, 'project': self.project.id,
|
|
'field_uuid': feld.uuid, 'ad': newkampagne.id, 'relname': media.medianame,
|
|
'mediatype': media.id})
|
|
_logger.info('Prüfe Medien : C_' + str(self.contract.id) + 'K_' + str(
|
|
newkampagne.id) + ' setze Vertrag für Medium : ' + str(newmedia.contract) + '/' + str(
|
|
newmedia.ad))
|
|
mediaids.append(newmedia.id)
|
|
newkampagne.write({'need_media': [(6, 0, mediaids)]})
|
|
_logger.info('Click auf Werbekampagne : C_' + str(self.contract.id) + 'A_' + str(
|
|
newkampagne.id) + ' setze Media ')
|
|
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'view_type': 'form',
|
|
'view_mode': 'form,tree',
|
|
'res_model': 'dss.ads',
|
|
'target': 'current',
|
|
'context': '',
|
|
'res_id': newkampagne.id,
|
|
'display_name': 'Änderung zur Werbekampagne ' + newkampagne.parent_ad.adname,
|
|
'domain': '[("id","=","context[newkampagne.id]")]'
|
|
}
|
|
else:
|
|
raise ValidationError(
|
|
_("Kann neue Aktualisierung erst anlegen wenn alle vorherigen Schritte beendet wurden !"))
|
|
|
|
def setStandardText(self, tid):
|
|
text = self.env['dss.texts'].search([('text_id', '=', tid)], limit=1)
|
|
if text:
|
|
self.write({'description': text.description})
|
|
|
|
|
|
class dsscontractads(models.Model):
|
|
|
|
def _default_work_state(self):
|
|
ds = self.env['dss.workstate'].search([('statusname', '=', 'Neu')], limit=1).id
|
|
_logger.debug(ds)
|
|
return ds
|
|
|
|
def _default_work_state_color(self):
|
|
ds = self.env['dss.workstate'].search([('statusname', '=', 'Neu')], limit=1).color
|
|
_logger.info(ds)
|
|
return ds
|
|
|
|
def _default_todo_state(self):
|
|
ds = self.env['dss.todostate'].search([('statusnr', '=', '0')], limit=1).id
|
|
if not ds: ds = 1
|
|
_logger.debug(ds)
|
|
# ds =
|
|
return ds
|
|
|
|
@api.model
|
|
def create(self, vals):
|
|
result = super().create(vals)
|
|
resstr = result.uuid
|
|
_logger.info(resstr)
|
|
for n_record in result:
|
|
resstr = n_record.uuid
|
|
_logger.info(resstr)
|
|
n_record.date_create = date.today()
|
|
n_record.user_create = self.env.user.name
|
|
allads = n_record.contract.ads
|
|
_logger.info(allads)
|
|
if allads != False:
|
|
for ad in allads:
|
|
ad.ad_is_lastpos = False
|
|
n_record.ad_is_lastpos = True
|
|
contract = n_record.contract
|
|
contract.ads_last_ad = n_record
|
|
return result
|
|
|
|
# @api.depends('need_media')
|
|
# def _getmedialist(self):
|
|
# mlist = []
|
|
# mlist = self.env['dss.mediarelations'].search([('ad','=',self.id)])
|
|
# if mlist != False:
|
|
# _logger.info('AD Need_Medias A_'+str(self)+' - Computed Medias '+str(mlist))
|
|
# self.need_media = mlist.ids
|
|
# else:
|
|
# self.need_media = False
|
|
|
|
_name = "dss.ads"
|
|
_description = "DigitalSignage Werbekampagnen Phasen"
|
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
|
# _inherit = ['mail.activity.mixin']
|
|
# 'mail.thread','mail.activity.mixin'
|
|
_rec_name = "adname"
|
|
# _inherit = ['mail.thread', 'mail.activity.mixin']
|
|
uuid = fields.Char(default=lambda self: self._default_uuid(), required=True, readonly=True, copy=False,
|
|
string='UUID')
|
|
aduuid = fields.Char(related='uuid')
|
|
|
|
date_create = fields.Date('Erstellungsdatum', default=lambda self: self._default_create_date())
|
|
date_lastedit = fields.Date('Änderungsdatum')
|
|
user_create = fields.Char('Erstellungsuser', default=lambda self: self._default_create_user())
|
|
user_lastedit = fields.Char('Änderungsuser')
|
|
# uuid = fields.Char('UUID', required=True, translate=True)
|
|
adname = fields.Char('Kampagnenname', required=True, tracking=True)
|
|
adtype = fields.Selection(
|
|
[('MAIN', 'Ersteinrichtung'), ('KCHN', 'Änderung durch Kunde'), ('LCHN', 'Änderung durch Logumedia'),
|
|
('SONS', 'Sonstige Änderung')], tracking=True)
|
|
adpos = fields.Integer('Reihenfolge', default=lambda self: self._default_adpos(),
|
|
tracking=True)
|
|
ad_is_lastpos = fields.Boolean('Letzte Aktion', tracking=True)
|
|
|
|
start_date = fields.Date('gew. Ausstrahl.Begin', tracking=True)
|
|
end_date = fields.Date('gew. Ausstrahl.Ende', tracking=True)
|
|
|
|
contract = fields.Many2one('dss.contracts', store=True, tracking=True)
|
|
contract_id = fields.Char(related='contract.contract_id')
|
|
contract_name = fields.Char(related='contract.contract_name')
|
|
contract_need_media = fields.Many2many(related='contract.need_media', tracking=True)
|
|
|
|
project = fields.Many2one('dss.projects', string='Project', store=True, tracking=True)
|
|
project_id = fields.Integer(related='project.projectid', string='Project ID')
|
|
|
|
parent_ad = fields.Many2one('dss.ads', string='UrsprungsWerbung', store=True)
|
|
parent_ad_uuid = fields.Char(related='parent_ad.uuid')
|
|
description = fields.Text('Beschreibung')
|
|
amount = fields.Float('Extrakosten', tracking=True)
|
|
order = fields.Integer('Reihenfolge', tracking=True)
|
|
|
|
# need_media = fields.Many2many('dss.mediarelations','ad',string='Medien')
|
|
need_media = fields.One2many('dss.mediarelations', 'ad', string='Medien')
|
|
|
|
work_state = fields.Many2one('dss.workstate', default=_default_work_state, tracking=True)
|
|
work_state_color = fields.Char(related='work_state.color')
|
|
work_state_text = fields.Char(related='work_state.statusname')
|
|
work_state_info = fields.Char('Zusatzinfo')
|
|
|
|
ad_state = fields.Many2one('dss.adstate', tracking=True)
|
|
ad_state_color = fields.Char(related='ad_state.color')
|
|
ad_state_text = fields.Char(related='ad_state.statusname')
|
|
ad_state_func = fields.Selection(related='ad_state.func')
|
|
|
|
todo_state = fields.Many2one('dss.todostate', default=_default_todo_state,
|
|
tracking=True)
|
|
todo_state_color = fields.Char(related='todo_state.color')
|
|
todo_state_text = fields.Char(related='todo_state.statusname')
|
|
todo_state_info = fields.Char('Zusatzinfo', tracking=True)
|
|
todo_state_until = fields.Date('Abarbeiten bis', tracking=True)
|
|
|
|
cloud_add_directory = fields.Char('Cloud KundenKampagnen Ordner', tracking=True)
|
|
|
|
date_zuarbeit = fields.Date(string='Zuarbeit Datum', help='Zuarbeit gesendet am',
|
|
tracking=True)
|
|
date_korrekturabzug = fields.Date(string='K.Abzug Datum', help='Korrekturabzug gesendet am',
|
|
track_visibility='onchange', tracking=True)
|
|
date_korrekturfreigabe = fields.Date(string='K.Freigabe Datum', help='Korrekturfreigabe erhalten am',
|
|
track_visibility='onchange', tracking=True)
|
|
|
|
@api.model
|
|
def _default_uuid(self):
|
|
return str(uuid.uuid4())
|
|
|
|
def _default_create_date(self):
|
|
return str(date.today())
|
|
|
|
def _default_create_user(self):
|
|
return str(self.env.user.name)
|
|
|
|
def _default_adpos(self):
|
|
pos = self.env['dss.ads'].search_count([('contract_id', '=', self.contract.id)]) + 1
|
|
return str(pos)
|
|
|
|
@api.onchange('ad_state')
|
|
def _onchange_ad_state(self):
|
|
for record in self:
|
|
if record.ad_is_lastpos == True:
|
|
contract = record.contract
|
|
contract.ads_last_state = record.ad_state
|
|
# mtyp = self.env['dss.adstructures'].search([("uuid","=",str(record.mediastructure.uuid))])
|
|
# buildmediarelations(self)
|
|
self.date_lastedit = str(date.today())
|
|
|
|
# self.mediastructure = mtyp
|
|
|
|
def pyaction_view_ad_details(self):
|
|
action = self.env['ir.actions.act_window'].with_context({'default_adid': self.id})._for_xml_id(
|
|
'DigitalSignage.action_dss_ads_view')
|
|
# action['display_name'] = self.ad_name
|
|
# action['domain'] = '[["projectid","=","4"]]'
|
|
# context = action['context'].replace('', str(self.id))
|
|
# context = ast.literal_eval(context)
|
|
# context.update({
|
|
# 'create': self.active,
|
|
# 'active_test': self.active
|
|
# })
|
|
# action['context'] = context
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'view_type': 'form',
|
|
'view_mode': 'form,tree',
|
|
'res_model': 'dss.ads',
|
|
'target': 'current',
|
|
'context': '',
|
|
'res_id': self.id,
|
|
'display_name': ' ' + self.adname,
|
|
'domain': ''
|
|
}
|
|
|
|
return action
|
|
|
|
def pydoviewallads(self):
|
|
action = self.env['ir.actions.act_window'].with_context({'default_adid': self.id})._for_xml_id(
|
|
'DigitalSignage.act_dss_ads_view_full')
|
|
action['display_name'] = self.contract_name
|
|
# action['domain'] = '[["projectid","=","4"]]'
|
|
# context = action['context'].replace('', str(self.id))
|
|
# context = ast.literal_eval(context)
|
|
# context.update({
|
|
# 'create': self.active,
|
|
# 'active_test': self.active
|
|
# })
|
|
# action['context'] = context
|
|
# return {
|
|
# 'type': 'ir.actions.act_window',
|
|
# 'view_type':'form',
|
|
# 'view_mode':'form,tree',
|
|
# 'res_model':'dss.ads',
|
|
# 'target':'current',
|
|
# 'context':'',
|
|
# 'res_id':kampagne.id,
|
|
# 'display_name' : 'Werbekampagne '+kampagne.adname,
|
|
# 'domain':'[("contract","=","context[active_id]")]'
|
|
# }
|
|
# return action
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'view_type': 'kanban',
|
|
'view_mode': 'kanban',
|
|
'res_model': 'dss.ads',
|
|
'target': 'current',
|
|
'context': '{"group_by":["parent_ad"]}',
|
|
# 'res_id':self.parent_ad,
|
|
'display_name': 'Übersicht für ' + self.adname,
|
|
'domain': [("contract", "=", self.contract.id)]
|
|
}
|
|
|
|
def pydonewad(self):
|
|
for n_record in self:
|
|
resstr = n_record.uuid
|
|
_logger.info(resstr)
|
|
allads = n_record.contract.ads
|
|
_logger.info(allads)
|
|
abort = False
|
|
if allads != False:
|
|
for ad in allads:
|
|
if ad.ad_state.func != 'FIN':
|
|
abort = True
|
|
if abort == False:
|
|
defadstate = self.env['dss.adstate'].search([('func', '=', 'STD')], limit=1).id
|
|
if not defadstate:
|
|
defadstate = 1
|
|
if self.ad_state.func == 'STD':
|
|
parent_id = self.id
|
|
else:
|
|
parent_id = self.parent_ad.id
|
|
newkampagne = self.env['dss.ads'].create({'contract': self.contract.id, 'project': self.project.id,
|
|
'adname': 'AD_' + self.contract.contract_auto_name + ' ' + str(
|
|
date.today()), 'parent_ad': parent_id, 'adtype': 'KCHN',
|
|
'ad_state': defadstate})
|
|
_logger.info('C_' + str(self.id) + ' Kampagne erzeugt : ' + str(newkampagne))
|
|
_logger.info('Prüfe Medien : C_' + str(self.id) + 'K_' + str(newkampagne.id))
|
|
|
|
mediaids = []
|
|
for feld in self.contract.werbe_feld_selected:
|
|
for media in feld.mediastructure.medias:
|
|
if not media:
|
|
_logger.info('Prüfe Medien : C_' + str(self.contract.id) + 'K_' + str(
|
|
newkampagne.id) + ' Kein Medium in MedienStructur von F_' + str(feld.id) + 'M_' + str(
|
|
media.id))
|
|
else:
|
|
newmedia = self.env['dss.mediarelations'].create(
|
|
{'field': feld.id, 'contract': self.contract.id, 'project': self.project.id,
|
|
'field_uuid': feld.uuid, 'ad': newkampagne.id, 'relname': media.medianame,
|
|
'mediatype': media.id})
|
|
_logger.info('Prüfe Medien : C_' + str(self.contract.id) + 'K_' + str(
|
|
newkampagne.id) + ' setze Vertrag für Medium : ' + str(newmedia.contract) + '/' + str(
|
|
newmedia.ad))
|
|
mediaids.append(newmedia.id)
|
|
newkampagne.write({'need_media': [(6, 0, mediaids)]})
|
|
_logger.info('Click auf Werbekampagne : C_' + str(self.contract.id) + 'A_' + str(
|
|
newkampagne.id) + ' setze Media ')
|
|
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'view_type': 'form',
|
|
'view_mode': 'form,tree',
|
|
'res_model': 'dss.ads',
|
|
'target': 'current',
|
|
'context': '',
|
|
'res_id': newkampagne.id,
|
|
'display_name': 'Änderung zur Werbekampagne ' + newkampagne.parent_ad.adname,
|
|
'domain': '[("id","=","context[newkampagne.id]")]'
|
|
}
|
|
else:
|
|
raise ValidationError(
|
|
_("Kann neue Aktualisierung erst anlegen wenn alle vorherigen Schritte beendet wurden !"))
|
|
|
|
def setStandardText(self, tid):
|
|
text = self.env['dss.texts'].search([('text_id', '=', tid)], limit=1)
|
|
if text:
|
|
self.write({'description': text.description})
|
|
|