mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] add pms_automated_mails model and views
This commit is contained in:
@@ -77,6 +77,7 @@
|
||||
"views/res_company_views.xml",
|
||||
"views/traveller_report_template.xml",
|
||||
"wizards/wizard_split_join_swap_reservation.xml",
|
||||
"views/pms_automated_mails_views.xml",
|
||||
"wizards/wizard_massive_changes.xml",
|
||||
"wizards/wizard_advanced_filters.xml",
|
||||
],
|
||||
|
||||
@@ -46,3 +46,4 @@ from . import account_bank_statement
|
||||
from . import account_journal
|
||||
from . import pms_availability
|
||||
from . import res_partner_id_number
|
||||
from . import pms_automated_mails
|
||||
|
||||
74
pms/models/pms_automated_mails.py
Normal file
74
pms/models/pms_automated_mails.py
Normal file
@@ -0,0 +1,74 @@
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
class PmsAutomatedMails(models.Model):
|
||||
_name = 'pms.automated.mails'
|
||||
_description = 'Automatic Mails'
|
||||
|
||||
name = fields.Char(
|
||||
string="Name"
|
||||
)
|
||||
|
||||
pms_property_id = fields.Many2one(
|
||||
string="Property",
|
||||
comodel_name="pms.property"
|
||||
)
|
||||
|
||||
automated_actions_id = fields.Many2one(
|
||||
string="Automated Actions",
|
||||
comodel_name="base.automation"
|
||||
)
|
||||
|
||||
time = fields.Integer(
|
||||
string="Time",
|
||||
required=True
|
||||
)
|
||||
|
||||
time_type = fields.Selection(
|
||||
string="Time Range",
|
||||
selection=[
|
||||
("minutes", "Minutes"),
|
||||
("hour", "Hour"),
|
||||
("day", "Days"),
|
||||
("month", "Months")
|
||||
],
|
||||
default="day",
|
||||
required=True
|
||||
)
|
||||
template_id = fields.Many2one(
|
||||
string="Template",
|
||||
comodel_name="mail.template",
|
||||
required=True
|
||||
)
|
||||
|
||||
reservation_date_fields_id = fields.Many2one(
|
||||
string="Action",
|
||||
comodel_name="ir.model.fields",
|
||||
domain="[('model', '=', 'pms.reservation'),('ttype', 'in', ('date', 'datetime'))]"
|
||||
)
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
name = vals.get("name")
|
||||
model_id = self.env["ir.model"].search([("name", "=", "Reservation")])
|
||||
action_server_vals = {
|
||||
"name": name,
|
||||
"state": "email",
|
||||
"usage": "ir_cron",
|
||||
"model_id": model_id.id,
|
||||
}
|
||||
action_server = self.env["ir.actions.server"].create(action_server_vals)
|
||||
model_field = vals.get("reservation_date_fields_id")
|
||||
time = vals.get("time")
|
||||
date_range_type = vals.get("time_type")
|
||||
template_id = vals.get("template_id")
|
||||
automated_actions_vals = {
|
||||
"action_server_id": action_server.id,
|
||||
"trigger": "on_time",
|
||||
"filter_domain": [("checkin", "<", "2021-12-31")],
|
||||
"trg_date_id": model_field.id,
|
||||
"trg_date_range": time,
|
||||
"trg_date_range_type": date_range_type,
|
||||
"template_id": template_id
|
||||
}
|
||||
self.env["base.automation"].create(automated_actions_vals)
|
||||
return super(PmsAutomatedMails, self).create(vals)
|
||||
@@ -60,3 +60,4 @@ user_access_wizard_payment_folio,user_access_wizard_payment_folio,model_wizard_p
|
||||
user_access_wizard_folio_changes,user_access_wizard_folio_changes,model_wizard_folio_changes,pms.group_pms_user,1,1,1,1
|
||||
user_access_pms_folio_portal,user_access_pms_folio_portal,model_pms_folio,base.group_portal,1,0,0,0
|
||||
user_access_pms_reservation_portal,user_access_pms_reservation_portal,model_pms_reservation,base.group_portal,1,0,0,0
|
||||
user_access_pms_automated_mails,user_access_pms_automated_mails,model_pms_automated_mails,pms.group_pms_user,1,1,1,1
|
||||
|
||||
|
58
pms/views/pms_automated_mails_views.xml
Normal file
58
pms/views/pms_automated_mails_views.xml
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="pms_automated_mails_view">
|
||||
<field name="name">pms.automated_mails_view_form</field>
|
||||
<field name="model">pms.automated.mails</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Automated Mails" class="pt-1">
|
||||
<sheet>
|
||||
<div class="col-5">
|
||||
<label for="name"/>
|
||||
<group>
|
||||
<h2><field name="name"/></h2>
|
||||
</group>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-5">
|
||||
<group>
|
||||
<field name="template_id"/>
|
||||
<field name="reservation_date_fields_id"/>
|
||||
</group>
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<group>
|
||||
<field name="time"/>
|
||||
<field name="time_type"/>
|
||||
</group>
|
||||
</div>
|
||||
</div>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_automated_mails_tree" model="ir.ui.view">
|
||||
<field name="name">pms.automated.mails.tree</field>
|
||||
<field name="model">pms.automated.mails</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Automated Mails">
|
||||
<field name="name"/>
|
||||
<field name="time"/>
|
||||
<field name="time_type"/>
|
||||
<field name="template_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="open_pms_automated_mails_tree">
|
||||
<field name="name">Automated Mails</field>
|
||||
<field name="res_model">pms.automated.mails</field>
|
||||
<field name="view_id" ref="view_automated_mails_tree"/>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Automated Mails"
|
||||
id="menu_pms_automated_mails"
|
||||
action="open_pms_automated_mails_tree"
|
||||
sequence="40"
|
||||
parent="pms.pms_configuration_menu"
|
||||
/>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user