Skip to content

Commit

Permalink
T0709 Add communication snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
ecino committed Feb 29, 2024
1 parent 577f8f9 commit b390618
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions partner_communication/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"views/ir_actions_view.xml",
"views/download_print_wizard_view.xml",
"views/settings_view.xml",
"views/communication_snippet_view.xml",
"data/default_communication.xml",
"data/queue_job.xml",
],
Expand Down
1 change: 1 addition & 0 deletions partner_communication/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
communication_attachment,
communication_config,
communication_job,
communication_snippet,
email,
ir_actions,
ir_attachment,
Expand Down
8 changes: 8 additions & 0 deletions partner_communication/models/communication_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,14 @@ def download_data(self):
)
return action

@api.model
def get_snippet(self, snippet_name):
return (
self.env["communication.snippet"]
.search([("name", "=", snippet_name)])
.snippet_text
)

##########################################################################
# PRIVATE METHODS #
##########################################################################
Expand Down
19 changes: 19 additions & 0 deletions partner_communication/models/communication_snippet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from odoo import fields, models


class CommunicationSnippet(models.Model):
_name = "communication.snippet"
_description = "Communication Snippet"

name = fields.Char(required=True, index=True)
snippet_text = fields.Html(required=True, translate=True)

def action_edit_snippet(self):
self.ensure_one()
return {
"type": "ir.actions.act_window",
"res_model": self._name,
"res_id": self.id,
"view_mode": "form",
"target": "current",
}
1 change: 1 addition & 0 deletions partner_communication/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ access_partner_communication_change_text_wizard,access_partner_communication_cha
access_partner_communication_generate_wizard,access_partner_communication_generate_wizard,model_partner_communication_generate_wizard,base.group_user,1,1,1,0
access_partner_communication_download_print_wizard,access_partner_communication_download_print_wizard,model_partner_communication_download_print_job_wizard,base.group_user,1,0,1,0
access_partner_communication_default_config,access_partner_communication_default_config,model_partner_communication_default_config,base.group_user,1,1,1,1
access_communication_snippets,Full access on communication_snippets,model_partner_communication_snippets,base.group_user,1,1,1,1
38 changes: 38 additions & 0 deletions partner_communication/views/communication_snippet_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<odoo>
<record model="ir.ui.view" id="communication_snippet_form">
<field name="name">communication.snippet.form</field>
<field name="model">communication.snippet</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" />
<field name="snippet_text" />
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="communication_snippet_tree">
<field name="name">communication.snippet.tree</field>
<field name="model">communication.snippet</field>
<field name="arch" type="xml">
<tree editable="top">
<field name="name" />
<field name="snippet_text" />
<button
name="action_edit_snippet"
type="object"
string="Edit"
icon="fa-external-link"
/>
</tree>
</field>
</record>
<menuitem
id="communication_snippet_menu"
name="Communication Snippet"
parent="partner_communication.menu_communication_config"
sequence="10"
/>
</odoo>

0 comments on commit b390618

Please sign in to comment.