Skip to content
Extraits de code Groupes Projets
Valider 0df01337 rédigé par Juliana's avatar Juliana
Parcourir les fichiers

Ajout nom tache automatique

parent dbde2791
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -2,7 +2,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
from datetime import datetime, date, time, timedelta
from datetime import datetime, timedelta
class NymphProject(models.Model):
_name = "project.project"
......@@ -22,9 +23,10 @@ class NymphProject(models.Model):
access = fields.Boolean("Conditions d'accessibilité")
path_drive = fields.Char("Lien Drive")
## CRON de vérification Zone Validée
# CRON de vérification Zone Validée
def _cron_project_zone(self):
projects = self.env['project.project'].search([('zone_etude','=', False)],)
projects = self.env['project.project'].search([
('zone_etude', '=', False)])
print ("projets", str(projects))
for p in projects:
body = '<li>Projet : '+p.name+'</li>'
......@@ -33,13 +35,15 @@ class NymphProject(models.Model):
'body': body,
}
message = self.env['mail.message'].create({'message_type': "notification",
"subtype": 1, # subject type
'body': body,
'subject': "Message subject",
'needaction_partner_ids': [(p.user_id.partner_id.id)],
# partner to whom you send notification
})
# message = self.env['mail.message'].create(
# {
# 'message_type': "notification",
# "subtype": 1, # subject type
# 'body': body,
# 'subject': "Message subject",
# 'needaction_partner_ids': [(p.user_id.partner_id.id)],
# # partner to whom you send notification
# })
p.message_post(
body=body_html,
subject='Zone étude',
......@@ -50,22 +54,37 @@ class NymphProject(models.Model):
res_id=p.id
)
class NymphProjectTaskType(models.Model):
_inherit = 'project.task.type'
case_default = fields.Boolean(string='Default step')
class NymphProjectTask(models.Model):
_inherit = 'project.task'
@api.model
def default_get(self, fields_list):
result = super(NymphProjectTask, self).default_get(fields_list)
project_id = self.env['project.project'].browse(
self.env.context['default_project_id'])
result['name'] = project_id.name
return result
type_task = fields.Selection([
('bureau', 'Bureau'),
('terrain', 'Terrain'),
('reunion', 'Réunion'),
], string='Type de tâche')
moment = fields.Selection([('diurne', 'Diurne'), ('nocturne', 'Nocturne')], string="Moment tâche")
moment = fields.Selection([
('diurne', 'Diurne'),
('nocturne', 'Nocturne')], string="Moment tâche")
period_id = fields.Many2one('project.period', string='Période')
date_start = fields.Datetime(string='Starting Date', default=fields.Datetime.now, index=True, copy=False)
date_start = fields.Datetime(
string='Starting Date',
default=fields.Datetime.now,
index=True, copy=False)
date_end = fields.Datetime(string='Ending Date', index=True, copy=False)
@api.model
......@@ -84,25 +103,27 @@ class NymphProjectTask(models.Model):
self.date_end = self.period_id.date_end
self.date_deadline = self.period_id.date_end.date()
## CRON sur Tasks deadline
# CRON sur Tasks deadline
def _cron_tasks_todo(self):
tasks = self.env['project.task'].search([('date_deadline','<', datetime.now().date() +timedelta(days=15))],)
tasks = self.env['project.task'].search([
('date_deadline', '<', datetime.now().date() + timedelta(days=15))])
for p in tasks:
print ("task", str(p.name))
print ("date", str(p.date_deadline))
responsable = p.user_id.partner_id.id
# responsable = p.user_id.partner_id.id
body = '<li>Tâche: '+p.name+'</li>'
body += '<li>Deadline: '+str(p.date_deadline)+'</li>'
body_html = "<div><b>%(title)s</b> : %(body)s</div>" % {
'title': "Tâche à effectuer avant la deadline",
'body': body,
}
message = self.env['mail.message'].create({'message_type': "notification",
"subtype": 1, # subject type
'body': body,
'subject': "Message subject",
'needaction_partner_ids': [(p.user_id.partner_id.id)],
})
# message = self.env['mail.message'].create({
# 'message_type': "notification",
# "subtype": 1, # subject type
# 'body': body,
# 'subject': "Message subject",
# 'needaction_partner_ids': [(p.user_id.partner_id.id)],
# })
p.message_post(
body=body_html,
subject='Tâches restantes à effectuer',
......@@ -113,6 +134,7 @@ class NymphProjectTask(models.Model):
res_id=p.id
)
class NymphProjectPeriod(models.Model):
_name = 'project.period'
_description = "Période projet"
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter