mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-24 09:32:00 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
from . import mail_compose_message
|
||||
from . import automation_configuration_test
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
# Copyright 2024 Dixmit
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AutomationConfigurationTest(models.TransientModel):
|
||||
|
||||
_name = "automation.configuration.test"
|
||||
_description = "Test automation configuration"
|
||||
|
||||
configuration_id = fields.Many2one("automation.configuration", required=True)
|
||||
model = fields.Char(related="configuration_id.model")
|
||||
resource_ref = fields.Reference(
|
||||
selection="_selection_target_model",
|
||||
readonly=False,
|
||||
required=True,
|
||||
store=True,
|
||||
compute="_compute_resource_ref",
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _selection_target_model(self):
|
||||
return [
|
||||
(model.model, model.name)
|
||||
for model in self.env["ir.model"]
|
||||
.sudo()
|
||||
.search([("is_mail_thread", "=", True)])
|
||||
]
|
||||
|
||||
@api.depends("model")
|
||||
def _compute_resource_ref(self):
|
||||
for record in self:
|
||||
if record.model and record.model in self.env:
|
||||
res = self.env[record.model].search([], limit=1)
|
||||
record.resource_ref = "%s,%s" % (record.model, res.id)
|
||||
else:
|
||||
record.resource_ref = None
|
||||
|
||||
def test_record(self):
|
||||
return self.configuration_id._create_record(
|
||||
self.resource_ref, is_test=True
|
||||
).get_formview_action()
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2024 Dixmit
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="automation_configuration_test_form_view">
|
||||
<field name="model">automation.configuration.test</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Test configuration">
|
||||
<sheet>
|
||||
|
||||
<div class="oe_title">
|
||||
<h2><field
|
||||
name="resource_ref"
|
||||
required="1"
|
||||
options="{'hide_model': True}"
|
||||
/></h2>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
On tests, mails will not be sent, but templates will be generated and actions will be executed.
|
||||
</div>
|
||||
<group>
|
||||
<field name="configuration_id" invisible="1" />
|
||||
<field name="model" invisible="1" />
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button
|
||||
name="test_record"
|
||||
string="Test"
|
||||
class="btn-primary"
|
||||
type="object"
|
||||
/>
|
||||
<button string="Cancel" class="btn-default" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="automation_configuration_test_act_window">
|
||||
<field name="name">Test Configuration</field>
|
||||
<field name="res_model">automation.configuration.test</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="context">{'default_configuration_id': active_id}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2024 Dixmit
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MailComposeMessage(models.TransientModel):
|
||||
|
||||
_inherit = "mail.compose.message"
|
||||
|
||||
automation_record_step_id = fields.Many2one("automation.record.step")
|
||||
|
||||
def get_mail_values(self, res_ids):
|
||||
result = super().get_mail_values(res_ids)
|
||||
if self.automation_record_step_id:
|
||||
for res_id in res_ids:
|
||||
result[res_id][
|
||||
"automation_record_step_id"
|
||||
] = self.automation_record_step_id.id
|
||||
return result
|
||||
Loading…
Add table
Add a link
Reference in a new issue