mirror of
https://github.com/bringout/oca-mrp.git
synced 2026-04-21 00:52:04 +02:00
Initial commit: OCA Mrp packages (117 packages)
This commit is contained in:
commit
277e84fd7a
4403 changed files with 395154 additions and 0 deletions
|
|
@ -0,0 +1,11 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import res_company
|
||||
|
||||
# WARNING: Order of imports matters on this module, so don't put res_company
|
||||
# below the other modules since it will lead to a missing column error when
|
||||
# the module is initialized for the first time since there are fields with
|
||||
# default values wich refer to this new res.company field.
|
||||
from . import event
|
||||
from . import event_mail
|
||||
from . import event_type
|
||||
from . import res_config_settings
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright 2017 Tecnativa - Sergio Teruel <sergio.teruel@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import Command, api, fields, models
|
||||
|
||||
|
||||
class EventEvent(models.Model):
|
||||
_inherit = "event.event"
|
||||
|
||||
@api.model
|
||||
def _default_event_mail_template_id(self):
|
||||
return self.env.company.event_mail_template_id
|
||||
|
||||
event_mail_template_id = fields.Many2one(
|
||||
comodel_name="event.mail.template",
|
||||
string="Mail Template Scheduler",
|
||||
default=_default_event_mail_template_id,
|
||||
)
|
||||
|
||||
@api.depends("event_mail_template_id")
|
||||
def _compute_event_mail_ids(self):
|
||||
records = self.filtered("event_mail_template_id")
|
||||
without_template = self - records
|
||||
for event in records:
|
||||
command = [(5, 0)] + [
|
||||
Command.create(line._prepare_event_mail_values())
|
||||
for line in event.event_mail_template_id.scheduler_template_ids
|
||||
]
|
||||
event.event_mail_ids = command
|
||||
return super(EventEvent, without_template)._compute_event_mail_ids()
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
# Copyright 2017 Tecnativa - Sergio Teruel <sergio.teruel@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class EventMailSchedulerTemplate(models.Model):
|
||||
_name = "event.mail.scheduler.template"
|
||||
_inherit = "event.mail"
|
||||
_description = "Event mail scheduler template"
|
||||
|
||||
event_id = fields.Many2one(required=False)
|
||||
event_mail_template_id = fields.Many2one(
|
||||
comodel_name="event.mail.template",
|
||||
string="Event Mail Template",
|
||||
required=True,
|
||||
ondelete="cascade",
|
||||
)
|
||||
|
||||
def _prepare_event_mail_values(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
"notification_type": self.notification_type,
|
||||
"interval_nbr": self.interval_nbr,
|
||||
"interval_unit": self.interval_unit,
|
||||
"interval_type": self.interval_type,
|
||||
"template_ref": f"{self.template_ref._name},{self.template_ref.id}",
|
||||
}
|
||||
|
||||
|
||||
class EventMailTemplate(models.Model):
|
||||
_name = "event.mail.template"
|
||||
_description = "Scheduling templates for events"
|
||||
|
||||
@api.model
|
||||
def _default_scheduler_template_ids(self):
|
||||
return [
|
||||
{
|
||||
"notification_type": "mail",
|
||||
"interval_unit": "now",
|
||||
"interval_type": "after_sub",
|
||||
"template_ref": f"mail.template, {self.env.ref('event.event_subscription').id}",
|
||||
},
|
||||
{
|
||||
"notification_type": "mail",
|
||||
"interval_nbr": 10,
|
||||
"interval_unit": "days",
|
||||
"interval_type": "before_event",
|
||||
"template_ref": f"mail.template, {self.env.ref('event.event_reminder').id}",
|
||||
},
|
||||
]
|
||||
|
||||
name = fields.Char()
|
||||
scheduler_template_ids = fields.One2many(
|
||||
comodel_name="event.mail.scheduler.template",
|
||||
inverse_name="event_mail_template_id",
|
||||
string="Mail Schedule",
|
||||
default=_default_scheduler_template_ids,
|
||||
)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2019 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import Command, models
|
||||
|
||||
|
||||
class EventType(models.Model):
|
||||
_inherit = "event.type"
|
||||
|
||||
def default_get(self, fields_list):
|
||||
res = super().default_get(fields_list)
|
||||
event_mail_template_id = self.env.company.event_mail_template_id
|
||||
if event_mail_template_id:
|
||||
res.update(
|
||||
{
|
||||
"event_type_mail_ids": [
|
||||
Command.create(line._prepare_event_mail_values())
|
||||
for line in event_mail_template_id.scheduler_template_ids
|
||||
]
|
||||
}
|
||||
)
|
||||
return res
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# Copyright 2019 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
event_mail_template_id = fields.Many2one(
|
||||
comodel_name="event.mail.template",
|
||||
string="Mail Template",
|
||||
)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Copyright 2016 Tecnativa - Sergio Teruel <sergio.teruel@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
event_mail_template_id = fields.Many2one(
|
||||
related="company_id.event_mail_template_id",
|
||||
comodel_name="event.mail.template",
|
||||
string="Mail Template",
|
||||
readonly=False,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue