Skip to content

Commit

Permalink
[ADD] mail_server_user
Browse files Browse the repository at this point in the history
Added test scripts

Updated test scripts
  • Loading branch information
ByteMeAsap committed Nov 30, 2024
1 parent fb34dbb commit 914939d
Show file tree
Hide file tree
Showing 18 changed files with 718 additions and 0 deletions.
82 changes: 82 additions & 0 deletions mail_server_user/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
=====================
Email Server For User
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f4f4347f0f16244f1af534d28eec9d0e38bfc4a37b39fa6ddfe410939e91b128
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/16.0/mail_server_user
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_server_user
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Allows users to add their own outgoing mail server from the user preferences.

**Table of contents**

.. contents::
:local:

Usage
=====

#. There's a **Setup Outgoing Email Server** button in **User Preferences**,from where you can
configure your own mail server.Make sure that the **From Filtering** and the **Username** on the outgoing email server is set as your email if its supposed to be used only for your emails.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_server_user%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Onestein

Contributors
~~~~~~~~~~~~

* `Onestein <https://www.onestein.eu>`__

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/social <https://github.com/OCA/social/tree/16.0/mail_server_user>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions mail_server_user/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions mail_server_user/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Onestein B.V.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Email Server For User",
"summary": "Allows users to add their own outgoing mail server from the user preferences.",
"version": "16.0.1.0.0",
"category": "Social Network",
"website": "https://github.com/OCA/social",
"author": ("Onestein, " "Odoo Community Association (OCA)"),
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": ["base", "mail"],
"data": [
"security/ir.model.access.csv",
"security/res_groups.xml",
"views/res_users_view.xml",
],
}
2 changes: 2 additions & 0 deletions mail_server_user/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import ir_mail_server
from . import res_users
12 changes: 12 additions & 0 deletions mail_server_user/models/ir_mail_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 Onestein B.V.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models


class IrMailServer(models.Model):
_inherit = "ir.mail_server"

smtp_user = fields.Char(groups="base.group_system,base.group_user")
smtp_pass = fields.Char(groups="base.group_system,base.group_user")
smtp_ssl_certificate = fields.Binary(groups="base.group_system,base.group_user")
smtp_ssl_private_key = fields.Binary(groups="base.group_system,base.group_user")
28 changes: 28 additions & 0 deletions mail_server_user/models/res_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 Onestein B.V.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models


class ResUsers(models.Model):
_inherit = "res.users"

def setup_outgoing_mail_server(self):
self.ensure_one()
ir_mail_server_id = self.env["ir.mail_server"].search([], limit=1)
if ir_mail_server_id and self.email:
# Make sure that from_filter and smtp_user is set to user's email
ir_mail_server_id.write(
{"from_filter": self.email, "smtp_user": self.email}
)
return {
"type": "ir.actions.act_window",
"res_model": "ir.mail_server",
"name": "Setup Outgoing Mail Server",
"target": "new",
"views": [(False, "form")],
"res_id": ir_mail_server_id.id,
"context": {
"default_from_filter": self.email,
"default_smtp_user": self.email,
},
}
1 change: 1 addition & 0 deletions mail_server_user/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `Onestein <https://www.onestein.eu>`__
1 change: 1 addition & 0 deletions mail_server_user/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allows users to add their own outgoing mail server from the user preferences.
2 changes: 2 additions & 0 deletions mail_server_user/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#. There's a **Setup Outgoing Email Server** button in **User Preferences**,from where you can
configure your own mail server.Make sure that the **From Filtering** and the **Username** on the outgoing email server is set as your email if its supposed to be used only for your emails.
2 changes: 2 additions & 0 deletions mail_server_user/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_ir_mail_server_user,access_ir_mail_server_user,base.model_ir_mail_server,base.group_user,1,1,1,1
49 changes: 49 additions & 0 deletions mail_server_user/security/res_groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<odoo>
<record model="res.groups" id="group_ir_mail_server_user">
<field name="name">Access Outgoing Mail Server</field>
<field name="category_id" ref="base.module_category_hidden" />
</record>

<record id="base.group_system" model="res.groups">
<field
name="implied_ids"
eval="[(4, ref('mail_server_user.group_ir_mail_server_user'))]"
/>
</record>

<record id="ir_mail_server_user_rule" model="ir.rule">
<field name="name">ir.mail.server.user.rule</field>
<field name="model_id" ref="base.model_ir_mail_server" />
<field name="domain_force">
['|','|',('from_filter', '=', user.email),('create_uid','=',user.id),('smtp_user', '=', user.email)]
</field>
<field
name="groups"
eval="[
Command.link(ref('mail_server_user.group_ir_mail_server_user'))
]"
/>
<field name="perm_read" eval="True" />
<field name="perm_write" eval="True" />
<field name="perm_create" eval="True" />
<field name="perm_unlink" eval="True" />
</record>

<record id="ir_mail_server_group_system_rule" model="ir.rule">
<field name="name">ir.mail.server.group_system.rule</field>
<field name="model_id" ref="base.model_ir_mail_server" />
<field name="domain_force">
[(1,'=',1)]
</field>
<field
name="groups"
eval="[
Command.link(ref('base.group_system'))
]"
/>
<field name="perm_read" eval="True" />
<field name="perm_write" eval="True" />
<field name="perm_create" eval="True" />
<field name="perm_unlink" eval="True" />
</record>
</odoo>
Binary file added mail_server_user/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 914939d

Please sign in to comment.