Compare commits

...

No commits in common. '14.0' and '13.0-mail_multi_website-publish' have entirely different histories.

  1. 2
      .DINAR/build-date.txt
  2. 5
      .DINAR/config.yaml
  3. 19
      .DINAR/image/src/addons.yaml
  4. 3
      .eslintrc.yml
  5. 145
      .github/workflows/DINAR-PORT.yml
  6. 5
      .github/workflows/DINAR-pr.yml
  7. 91
      .gitignore
  8. 3
      .isort.cfg
  9. 84
      .pre-commit-config.yaml
  10. 3
      .pylintrc
  11. 2
      .pylintrc-mandatory
  12. 47
      .travis.yml
  13. 23
      LICENSE
  14. 12
      README.md
  15. 1
      build-date.txt
  16. 49
      email_headers/README.md
  17. 32
      email_headers/__init__.py
  18. 41
      email_headers/__manifest__.py
  19. 14
      email_headers/data/ir_config_parameter_data.xml
  20. 9
      email_headers/migrations/12.0.1.2.0/post-migration.py
  21. 21
      email_headers/models/__init__.py
  22. 585
      email_headers/models/mail.py
  23. 1
      email_headers/tests/__init__.py
  24. 353
      email_headers/tests/test_email.py
  25. 22
      email_headers/views/ir_mail_server_views.xml
  26. 29
      mail_all/README.rst
  27. 1
      mail_all/__init__.py
  28. 30
      mail_all/__manifest__.py
  29. 9
      mail_all/doc/changelog.rst
  30. 19
      mail_all/doc/index.rst
  31. 70
      mail_all/i18n/de.po
  32. 69
      mail_all/i18n/es.po
  33. 64
      mail_all/i18n/mail_all.pot
  34. 35
      mail_all/i18n/sl.po
  35. BIN
      mail_all/images/1.jpg
  36. BIN
      mail_all/static/description/1.png
  37. BIN
      mail_all/static/description/2.png
  38. BIN
      mail_all/static/description/icon.png
  39. 84
      mail_all/static/description/index.html
  40. 3
      mail_all/static/src/css/mail_all.css
  41. 50
      mail_all/static/src/js/mail_all.js
  42. 33
      mail_all/static/src/js/test_mail_all.js
  43. 27
      mail_all/static/src/xml/menu.xml
  44. 3
      mail_all/tests/__init__.py
  45. 27
      mail_all/tests/test_js.py
  46. 21
      mail_all/views/templates.xml
  47. 25
      mail_archives/README.rst
  48. 0
      mail_archives/__init__.py
  49. 17
      mail_archives/__manifest__.py
  50. 11
      mail_archives/doc/changelog.rst
  51. 20
      mail_archives/doc/index.rst
  52. 36
      mail_archives/i18n/de.po
  53. 35
      mail_archives/i18n/es.po
  54. 30
      mail_archives/i18n/mail_archives.pot
  55. 35
      mail_archives/i18n/sl.po
  56. BIN
      mail_archives/images/1.jpg
  57. BIN
      mail_archives/static/description/1.png
  58. BIN
      mail_archives/static/description/2.png
  59. BIN
      mail_archives/static/description/icon.png
  60. 84
      mail_archives/static/description/index.html
  61. 3
      mail_archives/static/src/css/archives.css
  62. 91
      mail_archives/static/src/js/archives.js
  63. 24
      mail_archives/static/src/xml/menu.xml
  64. 1
      mail_archives/tests/__init__.py
  65. 31
      mail_archives/tests/test_js.py
  66. 21
      mail_archives/views/templates.xml
  67. 34
      mail_base/README.rst
  68. 2
      mail_base/__init__.py
  69. 16
      mail_base/__manifest__.py
  70. 1
      mail_base/controllers/__init__.py
  71. 15
      mail_base/controllers/main.py
  72. 22
      mail_base/doc/changelog.rst
  73. 18
      mail_base/doc/index.rst
  74. 31
      mail_base/i18n/de.po
  75. 29
      mail_base/i18n/es.po
  76. 29
      mail_base/i18n/it.po
  77. 29
      mail_base/i18n/pt.po
  78. 29
      mail_base/i18n/pt_BR.po
  79. 29
      mail_base/i18n/ru.po
  80. 31
      mail_base/i18n/sl.po
  81. 29
      mail_base/models.py
  82. BIN
      mail_base/static/description/icon.png
  83. 1418
      mail_base/static/lib/base.js
  84. 1
      mail_base/tests/__init__.py
  85. 17
      mail_base/tests/test_default.py
  86. 14
      mail_base/views/templates.xml
  87. 8
      mail_check_immediately/README.rst
  88. 1
      mail_check_immediately/__init__.py
  89. 15
      mail_check_immediately/__manifest__.py
  90. 4
      mail_check_immediately/doc/changelog.rst
  91. 80
      mail_check_immediately/models.py
  92. BIN
      mail_check_immediately/static/description/icon.png
  93. 49
      mail_check_immediately/static/description/index.html
  94. BIN
      mail_check_immediately/static/description/issue.png
  95. BIN
      mail_check_immediately/static/description/screenshot.png
  96. 60
      mail_check_immediately/static/src/js/main.js
  97. 29
      mail_check_immediately/static/src/xml/main.xml
  98. 16
      mail_check_immediately/views.xml
  99. 48
      mail_fix_553/README.rst
  100. 1
      mail_fix_553/__init__.py

2
.DINAR/build-date.txt

@ -1 +1 @@
new repo readme files
October 11, 2020

5
.DINAR/config.yaml

@ -13,3 +13,8 @@ addons:
server_wide_modules:
- web
repo_readme:
addons:
- mail_to
- mail_multi_website

19
.DINAR/image/src/addons.yaml

@ -1 +1,20 @@
# see https://github.com/Tecnativa/doodba#optodoocustomsrcaddonsyaml
---
ENV:
DEFAULT_REPO_PATTERN: https://github.com/OCA/{}.git
web:
- "*"
---
ENV:
DEFAULT_REPO_PATTERN: https://github.com/itpp-labs/{}.git
access-addons:
- "*"
misc-addons:
- "*"
website-addons:
- "*"

3
.eslintrc.yml

@ -15,7 +15,6 @@ globals:
odoo: readonly
openerp: readonly
Promise: readonly
owl: readonly
# Styling is handled by Prettier, so we only need to enable AST rules;
# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890
@ -102,7 +101,6 @@ rules:
no-obj-calls: warn
no-octal-escape: warn
no-octal: warn
no-param-reassign: off
no-path-concat: warn
no-process-env: warn
no-process-exit: warn
@ -151,7 +149,6 @@ rules:
require-yield: warn
sort-imports: warn
spaced-comment: [error, always]
space-before-function-paren: ["warn", {"anonymous": "always", "named": "never"}]
strict: [error, function]
use-isnan: error
valid-jsdoc:

145
.github/workflows/DINAR-PORT.yml

@ -1,145 +0,0 @@
# Copyright 2020 IT Projects Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "Port module"
on:
issues:
types:
- opened
- reopened
jobs:
port:
runs-on: ubuntu-latest
if: "startsWith(github.event.issue.title, 'DINAR-PORT ')"
steps:
- name: Post link
uses: KeisukeYamashita/create-comment@v1
with:
comment:
"Porting is started. Check logs: https://github.com/${{ github.repository
}}/actions/runs/${{ github.run_id }}"
- name: Checkout DINAR
uses: actions/checkout@v2
with:
path: DINAR
repository: itpp-labs/DINAR-fork
ref: master
- uses: actions/setup-python@v2
with:
python-version: "3.7.x"
- name: Install python tools
run: |
pip install plumbum pre-commit git-aggregator
- name: Check Python Version
run:
echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >>
$GITHUB_ENV
- name: Analyze request
env:
TITLE: ${{ github.event.issue.title }}
run: |
# sets environment variables that available in next steps via $ {{ env.PORT_... }} notation
python DINAR/workflow-files/analyze_port_trigger.py "$TITLE"
- name: Checkout Repo
uses: actions/checkout@v2
with:
path: REPO
fetch-depth: 0
ref: ${{ env.PORT_TO_BRANCH }}
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('REPO/.pre-commit-config.yaml') }}
- name: Copy module to new branch
run: |
git config --global user.email "itpp-bot@users.noreply.github.com"
git config --global user.name "Mitchell Admin"
cd REPO
if [ ! -d ${{ env.PORT_MODULE }} ]
then
# apply original commit history
if ! git format-patch --keep-subject --stdout origin/${{ env.PORT_TO_BRANCH }}..origin/${{ env.PORT_FROM_BRANCH }} -- ${{ env.PORT_MODULE }} | git am -3 --keep
then
# git am failed
git am --abort
# just copy source
git checkout origin/${{ env.PORT_FROM_BRANCH }} -- ${{ env.PORT_MODULE }}
git commit -m ":tada:${{ env.PORT_FROM_BRANCH_TAGS }} ${{ env.PORT_MODULE }}
previous commits history: https://github.com/${{ github.repository }}/commits/${{ env.PORT_FROM_BRANCH }}/${{ env.PORT_MODULE }}
> Made via .github/workflows/DINAR-PORT.yml"
fi
fi
- name: make OCA/odoo-module-migrator
run: |
gitaggregate -c DINAR/workflow-files/odoo-module-migrator-mix.yml
pip install -e ./odoo-module-migrator
- name: apply OCA/odoo-module-migrator
run: |
LOG_FILE=../odoo-module-migrator.logs
cd REPO
odoo-module-migrate \
--modules ${{ env.PORT_MODULE }} \
--init-version-name ${{ env.PORT_FROM_BRANCH }} \
--target-version-name ${{ env.PORT_TO_BRANCH }} \
--no-commit \
--no-pre-commit \
2> $LOG_FILE || true
cat $LOG_FILE
# remove colors
sed -r -i "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" $LOG_FILE
# escape character
# TODO: update KeisukeYamashita/create-comment to support reading comment's body from file
echo 'MIGRATOR_LOGS<<EOF' >> $GITHUB_ENV
cat $LOG_FILE >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
git add -A
git commit -m ":arrow_up:${{ env.PORT_TO_BRANCH_TAGS }} OCA/odoo-module-migrator
close #${{ github.event.issue.number }}
> Made via .github/workflows/DINAR-PORT.yml"
- name: pre-commit
run: |
cd REPO
pre-commit run --files $(find ${{ env.PORT_MODULE }} -type f) || true
git add -A
git commit -m ":rainbow: pre-commit
> Made via .github/workflows/DINAR-PORT.yml" || echo "pre-commit: no changes"
- name: PR
uses: peter-evans/create-pull-request@v3
id: cpr
with:
path: REPO
# GITHUB_TOKEN would not trigger PR checks
token: ${{ secrets.DINAR_TOKEN }}
branch: ${{ env.PORT_TO_BRANCH }}-${{ env.PORT_MODULE }}
title: "[${{ env.PORT_TO_BRANCH }}] ${{ env.PORT_MODULE }}"
body: |
Made by [DINAR](https://github.com/itpp-labs/DINAR#readme) by request in #${{ github.event.issue.number }}
- name: Post logs
uses: KeisukeYamashita/create-comment@v1
with:
number: ${{ steps.cpr.outputs.pull-request-number }}
comment: |
[Migrator](https://github.com/OCA/odoo-module-migrator/)'s [logs](https://github.com/${{ github.repository
}}/actions/runs/${{ github.run_id }}):
```
${{ env.MIGRATOR_LOGS }}
```

5
.github/workflows/DINAR-pr.yml

@ -94,10 +94,7 @@ jobs:
run: |
cd REPO
git fetch origin ${{ github.event.pull_request.base.ref }}
echo "CHANGED FILES:"
git diff --name-only --no-ext-diff FETCH_HEAD..HEAD -- .
echo "RUN PRE-COMMIT:"
pre-commit run --show-diff-on-failure --color=always --show-diff-on-failure --files $(git diff --name-only --no-ext-diff FETCH_HEAD..HEAD -- .)
pre-commit run --show-diff-on-failure --color=always --show-diff-on-failure --files $(git diff --name-only --no-ext-diff -z ${{ github.event.pull_request.base.ref }}..HEAD)
tests:
name: "Quick Tests"

91
.gitignore

@ -0,0 +1,91 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
*.pyc
*~
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# IPython Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# dotenv
.env
# virtualenv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject

3
.isort.cfg

@ -9,5 +9,4 @@ line_length=88
known_odoo=odoo
known_odoo_addons=odoo.addons
sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER
default_section=THIRDPARTY
known_third_party=
known_third_party=Crypto,mock,requests,werkzeug

84
.pre-commit-config.yaml

@ -12,7 +12,6 @@ exclude: |
(LICENSE.*|COPYING.*)
default_language_version:
python: python3
node: "14.13.0"
repos:
- repo: https://github.com/myint/autoflake
rev: v1.4
@ -20,21 +19,26 @@ repos:
- id: autoflake
args: ["-i", "--ignore-init-module-imports"]
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.1.2
- repo: https://github.com/prettier/prettier
rev: "1.19.1"
hooks:
- id: prettier
name: prettier + plugin-xml
# TODO Avoid awebdeveloper/pre-commit-prettier if possible
# HACK https://github.com/prettier/prettier/issues/7407
- repo: https://github.com/awebdeveloper/pre-commit-prettier
rev: v0.0.1
hooks:
- id: prettier
name: prettier xml plugin
additional_dependencies:
- "prettier@2.1.2"
- "@prettier/plugin-xml@0.12.0"
args:
- --plugin=@prettier/plugin-xml
- "prettier@1.19.1"
- "@prettier/plugin-xml@0.7.2"
files: \.xml$
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.8.1
rev: v6.8.0
hooks:
- id: eslint
verbose: true
@ -46,10 +50,10 @@ repos:
hooks:
- id: trailing-whitespace
# exclude autogenerated files
exclude: /README\.rst$
exclude: /README\.rst$|\.pot?$
- id: end-of-file-fixer
# exclude autogenerated files
exclude: /README\.rst$
exclude: /README\.rst$|\.pot?$
- id: debug-statements
- id: fix-encoding-pragma
args: ["--remove"]
@ -57,55 +61,47 @@ repos:
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
# exclude files where underlines are not distinguishable from merge conflicts
exclude: /README\.rst$|^docs/.*\.rst$
- id: check-symlinks
- id: check-xml
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/PyCQA/pylint
rev: pylint-2.5.3
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
name: flake8 except __init__.py
exclude: /__init__\.py$
additional_dependencies: ["flake8-bugbear==19.8.0"]
- id: flake8
name: flake8 only __init__.py
args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py
files: /__init__\.py$
additional_dependencies: ["flake8-bugbear==19.8.0"]
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.3.1
hooks:
- id: pylint
name: pylint with optional checks
args: ["--rcfile=.pylintrc", "--exit-zero"]
verbose: true
additional_dependencies: &pylint_deps
- pylint-odoo==3.5.0
additional_dependencies: ["pylint-odoo==3.1.0"]
- id: pylint
name: pylint with mandatory checks
args: ["--rcfile=.pylintrc-mandatory"]
additional_dependencies: *pylint_deps
additional_dependencies: ["pylint-odoo==3.1.0"]
- repo: https://github.com/asottile/pyupgrade
rev: v1.26.2
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
- repo: https://github.com/acsone/setuptools-odoo
rev: 2.6.0
hooks:
- id: setuptools-odoo-make-default
- id: setuptools-odoo-get-requirements
args:
- --output
- requirements.txt
- --header
- "# generated from manifests external_dependencies"
- repo: https://gitlab.com/PyCQA/flake8
rev: 3.8.3
hooks:
- id: flake8
name: flake8 except __init__.py
exclude: /__init__\.py$
additional_dependencies: ["flake8-bugbear==20.1.4"]
- id: flake8
name: flake8 only __init__.py
args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py
files: /__init__\.py$
additional_dependencies: ["flake8-bugbear==20.1.4"]
- repo: https://github.com/PyCQA/isort
rev: 5.5.1
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
name: isort except __init__.py
args:
- --settings=.
exclude: /__init__\.py$
- repo: https://github.com/acsone/setuptools-odoo
rev: 2.5.10
hooks:
- id: setuptools-odoo-make-default

3
.pylintrc

@ -8,7 +8,7 @@ manifest_required_authors=IT Projects Labs
manifest_required_keys=license
manifest_deprecated_keys=description,active
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3,MIT,Other OSI approved licence,OPL-1
valid_odoo_versions=14.0
valid_odoo_versions=13.0
[MESSAGES CONTROL]
disable=all
@ -45,6 +45,7 @@ enable=anomalous-backslash-in-string,
method-inverse,
method-required-super,
method-search,
missing-import-error,
missing-manifest-dependency,
openerp-exception-warning,
pointless-statement,

2
.pylintrc-mandatory

@ -8,7 +8,7 @@ manifest_required_authors=IT Projects Labs
manifest_required_keys=license
manifest_deprecated_keys=description,active
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3,MIT,Other OSI approved licence,OPL-1
valid_odoo_versions=14.0
valid_odoo_versions=13.0
[MESSAGES CONTROL]
disable=all

47
.travis.yml

@ -0,0 +1,47 @@
language: python
python:
- "3.6"
#dist: trusty
sudo: false
cache: pip
addons:
# odoo 12.0+ uses command "INSERT ... ON CONFLICT ...", which is available in 9.5+ only
postgresql: "9.5"
apt:
packages:
- expect-dev # provides unbuffer utility
- python-lxml # because pip installation is slow
env:
global:
- VERSION="13.0" TESTS="0" LINT_CHECK="0" UNIT_TEST="0"
- PYLINT_ODOO_JSLINTRC="/home/travis/maintainer-quality-tools/travis/cfg/.jslintrc"
matrix:
- LINT_CHECK="1"
- CHECK_TAGS="1"
- TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1"
- TESTS="1" ODOO_REPO="OCA/OCB"
install:
- pip install anybox.testing.openerp
- git clone https://github.com/it-projects-llc/maintainer-quality-tools.git
${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
script:
- travis_run_tests
after_success:
- travis_after_tests_success
notifications:
email: false
webhooks:
on_failure: change
urls:
- "https://ci.it-projects.info/travis/on_failure/change"

23
LICENSE

@ -0,0 +1,23 @@
The MIT License (MIT)
Copyright 2020 IT-Projects Labs
Copyright 2015-2020 IT-Projects LLC
Copyright 2014-2015 Ivan Yelizariev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

12
README.md

@ -1,13 +1,9 @@
[![help@itpp.dev](https://itpp.dev/images/infinity-readme.png)](mailto:help@itpp.dev)
# [14.0] Odoo Mail Addons
# [13.0] Odoo Mail Addons
:open_file_folder: Get a **.zip** file with all needed dependencies:
:star: Star this repo if you **like** it!
:heart: [Sponsor us](https://patreon.com/itpp) if you **love** it!
:heavy_check_mark: [email_headers](https://apps.odoo.com/apps/modules/13.0/email_headers/)
<br/>:heavy_check_mark: [mail_multi_website](https://apps.odoo.com/apps/modules/13.0/mail_multi_website/)
<br/>:heavy_check_mark: [mail_to](https://apps.odoo.com/apps/modules/13.0/mail_to/)
Other Addons
============

1
build-date.txt

@ -0,0 +1 @@
April 3, 2020

49
email_headers/README.md

@ -0,0 +1,49 @@
# Robust Mails
This module is used to improve email deliverability and make sure that replies find
their way to the correct thread in Odoo.
Options:
- Force the `From` and `Reply-To` addresses of outgoing email
- Generate a thread-specific `Reply-To` address for outgoing emails so that losing the
headers used to identify the correct thread won't be a problem any more.
## Gotcha
To make the automatic bounce message work when using thread-specific `Reply-To`
addresses, you should define the actual catchall alias in a system parameter called
`mail.catchall.alias.custom` and change the `mail.catchall.alias` to something
completely random that will never be used, or alternatively remove it.
The reason is this: when Odoo is looking for a route for an incoming email that has lost
its headers, it won't check whether the email was sent to `catchall@whatever.com` but
instead it will see if the local part of that address contains the word `catchall`. And
this isn't a good thing when the address is something like
`catchall+123abc@whatever.com`. That's why we had to skip the default catchall
evaluation and redo it in a later phase.
## Database-specific Settings
| Setting | Purpose | Default value |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------- |
| email_headers.strip_mail_message_ids | Office 365 emails may add whitespaces before the Message-Id's. This feature removes them. | "True" |
| email_headers.prioritize_replyto_over_headers | When "True", Odoo will prioritize the (unique) Reply-To address of an incoming email and only then look at the `References` and `In-Reply-To` headers. | "True" |
| mail.catchall.alias | The default catchall alias. See "Gotcha" for more information. | "catchall" |
| mail.catchall.alias.custom | The new catchall alias setting. See "Gotcha" for more information. Will be set automatically upon module installation. | mail.catchall.alias value |
## Debugging
### Decode and decrypt a message id
```python
from odoo.addons.email_headers.models.mail import decode_msg_id
decode_msg_id(<encrypted and base32/64 encoded message database id>, self.env)
```
### Encrypt and encode a message id
```python
from odoo.addons.email_headers.models.mail import encode_msg_id
encode_msg_id(<message database id>, self.env)
```

32
email_headers/__init__.py

@ -0,0 +1,32 @@
##############################################################################
#
# Author: Avoin.Systems
# Copyright 2017 Avoin.Systems
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# noinspection PyUnresolvedReferences
from . import models
from odoo import SUPERUSER_ID, api
def set_catchall_alias(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
icp = env["ir.config_parameter"]
custom_alias = icp.get_param("mail.catchall.alias.custom")
if not custom_alias:
original_alias = icp.get_param("mail.catchall.alias", "catchall")
icp.set_param("mail.catchall.alias.custom", original_alias)
icp.set_param("mail.catchall.alias", "Use mail.catchall.alias.custom")

41
email_headers/__manifest__.py

@ -0,0 +1,41 @@
##############################################################################
#
# Author: Avoin.Systems
# Copyright 2017 Avoin.Systems
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# noinspection PyStatementEffect
{
"name": "Robust Mails",
"version": "13.0.1.2.0",
"license": "AGPL-3",
"summary": """
Adds fields on outgoing email server that allows you to better control the
outgoing email headers and Reply-To addresses.
""",
"data": ["data/ir_config_parameter_data.xml", "views/ir_mail_server_views.xml"],
"author": "Avoin.Systems",
"website": "https://avoin.systems",
"category": "Email",
"depends": ["mail"],
"external_dependencies": {
"python": ["Crypto.Cipher.AES"], # pip3 install pycryptodome
"bin": [],
},
"installable": True,
"post_init_hook": "set_catchall_alias",
}

14
email_headers/data/ir_config_parameter_data.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="prioritize_replyto_over_headers" model="ir.config_parameter">
<field name="key">email_headers.prioritize_replyto_over_headers</field>
<field name="value">True</field>
</record>
<!-- The original field was called just strip_message_ids, but since
it's manually set in some production databases, it's risky to
define here. It might break a database upgrade. -->
<record id="strip_mail_message_ids" model="ir.config_parameter">
<field name="key">email_headers.strip_mail_message_ids</field>
<field name="value">True</field>
</record>
</odoo>

9
email_headers/migrations/12.0.1.2.0/post-migration.py

@ -0,0 +1,9 @@
def migrate(cr, version):
if not version:
return
cr.execute(
"UPDATE ir_mail_server "
"SET reply_to_method = 'alias' "
"WHERE reply_to_alias IS TRUE"
)

21
email_headers/models/__init__.py

@ -0,0 +1,21 @@
##############################################################################
#
# Author: Avoin.Systems
# Copyright 2018 Avoin.Systems
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# noinspection PyUnresolvedReferences
from . import mail

585
email_headers/models/mail.py

@ -0,0 +1,585 @@
##############################################################################
#
# Author: Avoin.Systems
# Copyright 2018 Avoin.Systems
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import base64
import binascii
import logging
import random
import re
import string
from email.message import Message
from email.utils import formataddr, parseaddr
from Crypto.Cipher import AES
from odoo import api, fields, models, tools
from odoo.tools import frozendict
from odoo.addons.base.models.ir_mail_server import encode_rfc2822_address_header
_logger = logging.getLogger(__name__)
MESSAGE_PREFIX = "msg-"
def random_string(length):
return "".join(
random.choice(string.ascii_lowercase + string.digits) for _ in range(length)
)
def get_key(env):
return env["ir.config_parameter"].get_param("database.secret", "noneedtobestrong")[
:16
]
def get_cipher(env):
return AES.new(
get_key(env).encode("utf-8"), mode=AES.MODE_CBC, iv=b"veryverysecret81"
)
def encode_msg_id(msg_id, env):
id_padded = "%016d" % msg_id
encrypted = get_cipher(env).encrypt(id_padded.encode("utf-8"))
return base64.b32encode(encrypted).decode("utf-8")
# Remove in Odoo 14
def encode_msg_id_legacy(msg_id, env):
id_padded = "%016d" % msg_id
encrypted = get_cipher(env).encrypt(id_padded.encode("utf-8"))
return base64.urlsafe_b64encode(encrypted).decode("utf-8")
def decode_msg_id(encoded_encrypted_id, env):
try:
# Some email clients don't respect the original Reply-To address case
# and might make them lowercase. Make the encoded ID uppercase.
encrypted = base64.b32decode(encoded_encrypted_id.encode("utf-8").upper())
except binascii.Error:
# Fall back to base64, which was used by the previous versions.
# This can be removed in Odoo 14.
try:
encrypted = base64.urlsafe_b64decode(encoded_encrypted_id.encode("utf-8"))
except binascii.Error:
_logger.error(
"Unable to decode the message ID. The input value "
"is invalid and cannot be decoded. "
"Encoded value: {}".format(encoded_encrypted_id)
)
raise
try:
id_str = get_cipher(env).decrypt(encrypted).decode("utf-8")
except UnicodeDecodeError:
_logger.error(
"Unable to decrypt the message ID. The input value "
"probably wasn't encrypted with the same key. Encoded "
"value: {}".format(encoded_encrypted_id)
)
raise
return int(id_str)
class MailServer(models.Model):
_inherit = "ir.mail_server"
reply_to_method = fields.Selection(
[("default", "Odoo Default"), ("alias", "Alias"), ("msg_id", "Message ID")],
"Reply-To Method",
default="default",
help="Odoo Default: Don't add any unique identifiers into the\n"
"Reply-To address.\n"
"\n"
"Alias: Find or generate an email alias for the Reply-To field of\n "
"every outgoing message so the responses will be automatically \n"
"routed to the correct thread even if the email client (Yes, \n"
"I'm looking at you, Microsoft Outlook) decides to drop the \n"
"References, In-Reply-To and Message-ID fields.\n\n"
"The alias will then be used to generate a RFC 5233 sub-address\n"
"using the Force From Address field as a base, eg.\n"
"odoo@mycompany.fi would become odoo+adf9bacd98732@mycompany.fi\n"
"\n"
"Note that this method has a flaw: if the headers have dropped\n"
"and Odoo can't connect the reply to any message in the thread,\n"
"it will automatically connect it to the first message in the \n"
"thread which often is an internal note and the reply will also\n"
"be marked as an internal note even when it should be a comment."
"\n\n"
"Message ID: Include a prefix and the message ID in encrypted\n"
"and base32 encoded format in the Reply-To\n"
"address to that Odoo will be able to directly connect the\n"
"reply to the original message. Note that in this mode the\n"
"Reply-To address has a priority over References and\n"
"In-Reply-To headers.",
)
force_email_reply_to = fields.Char("Force Reply-To Address",)
force_email_reply_to_name = fields.Char("Force Reply-To Name",)
force_email_reply_to_domain = fields.Char("Force Reply-To Domain",)
force_email_from = fields.Char("Force From Address",)
force_email_sender = fields.Char("Force Sender Address",)
prioritize_reply_to_over_msgid = fields.Boolean(
"Prioritize Reply-To Over Email Headers",
default=True,
help="If this field is selected, the unique Reply-To address "
"generated by the Message ID method will be prioritized "
"over the email headers (default Odoo behavior) in incoming "
"emails. This is recommended when the Reply-To method is set to "
"Message ID.",
)
headers_example = fields.Text(
"Example Headers", compute="_compute_headers_example", store=False,
)
# TODO Implement field input validators
def _get_reply_to_address(self, alias, original_from_name):
self.ensure_one()
force_email_from = encode_rfc2822_address_header(self.force_email_from)
# Split the From address
from_address = force_email_from.split("@")
reply_to_addr = "{alias}@{domain}".format(
alias=alias if alias else from_address[0],
domain=self.force_email_reply_to_domain or from_address[1],
)
if self.force_email_reply_to_name:
reply_to = formataddr((self.force_email_reply_to_name, reply_to_addr))
elif original_from_name:
reply_to = formataddr((original_from_name, reply_to_addr))
else:
reply_to = reply_to_addr
return encode_rfc2822_address_header(reply_to)
@api.depends(
"force_email_sender",
"force_email_reply_to",
"force_email_reply_to_domain",
"force_email_from",
"force_email_reply_to_name",
"reply_to_method",
)
def _compute_headers_example(self):
for server in self:
example = []
if server.force_email_sender:
example.append("Sender: {}".format(server.force_email_sender))
if server.force_email_reply_to:
example.append("Reply-To: {}".format(server.force_email_reply_to))
elif server.force_email_from and server.reply_to_method != "default":
reply_to_pair = server.force_email_from.split("@")
if server.reply_to_method == "alias":
token = "{}+1d278g1082bca"
elif server.reply_to_method == "msg_id":
token = "{}+" + MESSAGE_PREFIX + "p2IxKkfEKugl16juheTT0g=="
else:
token = "INVALID"
_logger.error(
"Invalid reply_to_method found: " + server.reply_to_method
)
# noinspection PyProtectedMember
reply_to = server._get_reply_to_address(
token.format(reply_to_pair[0]), "Original From Person"
)
example.append("Reply-To: {}".format(reply_to))
else:
example.append("Reply-To: Odoo default")
if server.force_email_from:
example.append(
"From: {}".format(
formataddr(("Original From Person", server.force_email_from))
)
)
else:
example.append("From: Odoo default")
server.headers_example = "\n".join(example)
@api.model
def send_email(
self,
message,
mail_server_id=None,
smtp_server=None,
smtp_port=None,
smtp_user=None,
smtp_password=None,
smtp_encryption=None,
smtp_debug=False,
smtp_session=None,
):
# Get SMTP Server Details from Mail Server
mail_server = None
if mail_server_id:
mail_server = self.sudo().browse(mail_server_id)
elif not smtp_server:
mail_server = self.sudo().search([], order="sequence", limit=1)
# Note that Odoo already has the ability to use a fixed From address
# by settings "email_from" in the Odoo settings. This is however a
# secondary option and here email_from always overrides that.
if mail_server.force_email_from:
original_from_name = parseaddr(message["From"])[0]
force_email_from = encode_rfc2822_address_header(
mail_server.force_email_from
)
del message["From"]
message["From"] = formataddr((original_from_name, force_email_from))
if mail_server.reply_to_method == "alias":
# Find or create an email alias
alias = self.find_or_create_alias(force_email_from.split("@"))
# noinspection PyProtectedMember
reply_to = mail_server._get_reply_to_address(alias, original_from_name,)
del message["Reply-To"]
message["Reply-To"] = reply_to
elif mail_server.reply_to_method == "msg_id":
odoo_msg_id = message.get("Message-Id")
if odoo_msg_id:
# The message_id isn't unique. Prefer the one that has a
# model set and only pick the first record. Odoo does
# almost the same thing in mail.thread.message_route().
odoo_msg = (
self.sudo()
.env["mail.message"]
.search(
[("message_id", "=", odoo_msg_id)], order="model", limit=1
)
)
encrypted_id = encode_msg_id(odoo_msg.id, self.env)
# noinspection PyProtectedMember
reply_to = mail_server._get_reply_to_address(
"{}+{}{}".format(
force_email_from.split("@")[0], MESSAGE_PREFIX, encrypted_id
),
original_from_name,
)
_logger.info(
'Generated a new reply-to address "{}" for '
'Message-Id "{}".'.format(reply_to, odoo_msg_id)
)
del message["Reply-To"]
message["Reply-To"] = reply_to
else:
_logger.warning(
"Couldn't get Message-Id from the message {}. The "
"reply might not find its way to the correct thread.".format(
message.as_string()
)
)
if mail_server.force_email_reply_to:
del message["Reply-To"]
message["Reply-To"] = encode_rfc2822_address_header(
mail_server.force_email_reply_to
)
if mail_server.force_email_sender:
del message["Sender"]
message["Sender"] = encode_rfc2822_address_header(
mail_server.force_email_sender
)
return super(MailServer, self).send_email(
message,
mail_server_id,
smtp_server,
smtp_port,
smtp_user,
smtp_password,
smtp_encryption,
smtp_debug,
smtp_session,
)
def find_or_create_alias(self, from_address):
record_id, record_model_name = self.resolve_record()
if not record_id or not record_model_name:
# Can't create an alias if we don't know the related record
return False
if record_model_name not in self.env:
_logger.error(
"Unable to find or create an alias for outgoing "
"email: invalid_model name {}.".format(record_model_name)
)
return False
# Find an alias
alias_model_id = (
self.env["ir.model"].search([("model", "=", record_model_name)]).id
)
# noinspection PyPep8Naming
Alias = self.env["mail.alias"]
existing_aliases = Alias.search(
[
("alias_model_id", "=", alias_model_id),
(
"alias_name",
"like",
"{from_address}+".format(from_address=from_address[0]),
),
("alias_force_thread_id", "=", record_id),
("alias_contact", "=", "everyone"), # TODO: check from record
]
)
if existing_aliases:
return existing_aliases[0].alias_name
# Create a new alias
alias = Alias.create(
{
"alias_model_id": alias_model_id,
"alias_name": "{from_address}+{random_string}".format(
from_address=from_address[0], random_string=random_string(8)
),
"alias_force_thread_id": record_id,
"alias_contact": "everyone",
}
)
return alias.alias_name
def resolve_record(self):
ctx = self.env.context
# Don't ever use active_id or active_model from the context here.
# It might not be the one that you expect. Go ahead and try, open
# a sales order, go to the related purchase order and send the PO.
record_id = ctx.get("default_res_id")
record_model_name = ctx.get("default_model")
# If incoming_routes isn't enough, we can use ctx['incoming_to'] to
# find a alias directly without active_id and active_model_name.
routes = ctx.get("incoming_routes", [])
if (not record_id or not record_model_name) and routes and len(routes) > 0:
route = routes[0]
record_model_name = route[0]
record_id = route[1]
return record_id, record_model_name
@api.model
def encrypt_message_id(self, message_id):
"""
A helper encryption method for debugging mail delivery issues.
:param message_id: The id of the `mail.message`
:return: The id of the `mail.message` encrypted and base64 encoded
"""
return encode_msg_id(message_id, self.env)
@api.model
def decrypt_message_id(self, encrypted_id):
"""
A helper decryption method for debugging mail delivery issues.
:param encrypted_id: The encrypted and base64 encoded id of
the `mail.message` to be decrypted
:return: The id of the `mail.message`
"""
return decode_msg_id(encrypted_id, self.env)
class MailThread(models.AbstractModel):
_inherit = "mail.thread"
"""
The process for incoming emails goes something like this:
1. message_process (processing the incoming message)
2. message_parse (parsing the email message)
3. message_route (decides how to route the email)
4. message_route_process (executes the route)
5. message_post (posts the message to a thread)
"""
@api.model
def message_parse(self, message, save_original=False):
email_to = tools.decode_message_header(message, "To")
email_to_localpart = (tools.email_split(email_to) or [""])[0].split("@", 1)[0]
config_params = self.env["ir.config_parameter"].sudo()
# Check if the To part contains the prefix and a base32/64 encoded string
# Remove the "24," part when migrating to Odoo 14.
prefix_in_to = email_to_localpart and re.search(
r".*" + MESSAGE_PREFIX + "(?P<odoo_id>.{24,32}$)", email_to_localpart
)
prioritize_replyto_over_headers = config_params.get_param(
"email_headers.prioritize_replyto_over_headers", "True"
)
prioritize_replyto_over_headers = (
True if prioritize_replyto_over_headers != "False" else False
)
# If the msg prefix part is found in the To part, find the parent
# message and inject the Message-Id to the In-Reply-To part and
# remove References because it by default takes priority over
# In-Reply-To. We want the unique Reply-To address have the priority.
if prefix_in_to and prioritize_replyto_over_headers:
message_id_encrypted = prefix_in_to.group("odoo_id")
try:
message_id = decode_msg_id(message_id_encrypted, self.env)
parent_id = self.env["mail.message"].browse(message_id)
if parent_id:
# See unit test test_reply_to_method_msg_id_priority
del message["References"]
del message["In-Reply-To"]
message["In-Reply-To"] = parent_id.message_id
else:
_logger.warning(
"Received an invalid mail.message database id in incoming "
"email sent to {}. The email type (comment, note) might "
"be wrong.".format(email_to)
)
except UnicodeDecodeError:
_logger.warning(
"Unique Reply-To address of an incoming email couldn't be "
"decrypted. Falling back to default Odoo behavior."
)
res = super(MailThread, self).message_parse(message, save_original)
strip_message_id = config_params.get_param(
"email_headers.strip_mail_message_ids", "True"
)
strip_message_id = True if strip_message_id != "False" else False
if not strip_message_id == "True":
return res
# When Odoo compares message_id to the one stored in the database when determining
# whether or not the incoming message is a reply to another one, the message_id search
# parameter is stripped before the search. But Odoo does not do anything of the sort when
# a message is created, meaning if some email software (for example Outlook,
# for no particular reason) includes anything strippable at the start of the Message-Id,
# any replies to that message in the future will not find their way correctly, as the
# search yields nothing.
#
# Example of what happened before. The first one is the original Message-Id, and thus also
# the ID that gets stored on the mail.message as the `message_id`
# '\r\n <AM6PR05MB4933DE6BCAD68A037185EBCFFBAF0@AM6PR05MB4933.eurprd05.prod.outlook.com>'
# But when trying to find this message, Odoo takes the above message_id and strips it,
# which results in:
# '<AM6PR05MB4933DE6BCAD68A037185EBCFFBAF0@AM6PR05MB4933.eurprd05.prod.outlook.com>'
# And then the search is done for an exact match, which will fail.
#
# Odoo doesn't, so we must strip the message_ids before they are stored in the database
mail_message_id = res.get("message_id", "")
if mail_message_id:
mail_message_id = mail_message_id.strip()
res["message_id"] = mail_message_id
return res
@api.model
def message_route_process(self, message, message_dict, routes):
ctx = self.env.context.copy()
ctx["incoming_routes"] = routes
ctx["incoming_to"] = message_dict.get("to")
self.env.context = frozendict(ctx)
return super(MailThread, self).message_route_process(
message, message_dict, routes
)
@api.model
def message_route(
self, message, message_dict, model=None, thread_id=None, custom_values=None
):
# NOTE! If you're going to backport this module to Odoo 11 or Odoo 10,
# you will have to create the mail_bounce_catchall email template
# because it was introduced only in Odoo 12.
if not isinstance(message, Message):
raise TypeError("message must be an " "email.message.Message at this point")
try:
route = super(MailThread, self).message_route(
message, message_dict, model, thread_id, custom_values
)
except ValueError:
# If the headers that connect the incoming message to a thread in
# Odoo have disappeared at some point and the message was sent to
# the catchall address (with a sub-addressing suffix), we will
# skip the default catchall check and perform it here for
# mail.catchall.alias.custom. We do this because the alias check
# if done AFTER the catchall check by default and it may cause
# Odoo to send a bounce message to the sender who sent the email to
# the correct thread-specific address.
catchall_alias = (
self.env["ir.config_parameter"]
.sudo()
.get_param("mail.catchall.alias.custom")
)
email_to = tools.decode_message_header(message, "To")
email_to_localpart = (
(tools.email_split(email_to) or [""])[0].split("@", 1)[0].lower()
)
message_id = message.get("Message-Id")
email_from = tools.decode_message_header(message, "From")
# check it does not directly contact catchall
if catchall_alias and catchall_alias in email_to_localpart:
_logger.info(
"Routing mail from %s to %s with Message-Id %s: "
"direct write to catchall, bounce",
email_from,
email_to,
message_id,
)
body = self.env.ref("mail.mail_bounce_catchall").render(
{"message": message}, engine="ir.qweb"
)
self._routing_create_bounce_email(
email_from, body, message, reply_to=self.env.user.company_id.email
)
return []
else:
raise
return route

1
email_headers/tests/__init__.py

@ -0,0 +1 @@
from . import test_email

353
email_headers/tests/test_email.py

@ -0,0 +1,353 @@
# No need to translate tests
# pylint: disable=translation-required
from email.message import EmailMessage
import mock
import odoo
from odoo import SUPERUSER_ID
from odoo.tests import TransactionCase
from odoo.addons.base.models.ir_mail_server import IrMailServer
from ..models.mail import (
MESSAGE_PREFIX,
encode_msg_id,
encode_msg_id_legacy,
random_string,
)
@odoo.tests.tagged("post_install", "-at_install")
class TestEmail(TransactionCase):
def setUp(self):
super(TestEmail, self).setUp()
self.partner = self.env["res.partner"].create({"name": "Test Dude"})
self.partner2 = self.env["res.partner"].create({"name": "Dudette"})
self.demo_user = self.env.ref("base.user_demo")
self.subtype_comment = self.env.ref("mail.mt_comment")
self.subtype_note = self.env.ref("mail.mt_note")
self.MailMessage = self.env["mail.message"]
self.ConfigParam = self.env["ir.config_parameter"]
# Create server configuration
self.outgoing_server = self.env["ir.mail_server"].create(
{
"name": "Outgoing SMTP Server for Unit Tests",
"sequence": 1,
"smtp_host": "localhost",
"smtp_port": "9999",
"smtp_encryption": "none",
"smtp_user": "doesnt",
"smtp_pass": "exist",
"reply_to_method": "msg_id",
"force_email_reply_to_domain": "example.com",
"force_email_from": "odoo@example.com",
}
)
@staticmethod
def create_email_message():
message = EmailMessage()
message[
"Content-Type"
] = 'multipart/mixed; boundary="===============2590914155756834027=="'
message["MIME-Version"] = "1.0"
message[
"Message-Id"
] = "<CAD-eYi=a264_3DcrYSDU5yc_fwYoHonZ3H+{}@mail.gmail.com>".format(
random_string(6)
)
message["Subject"] = "1"
message["From"] = "Miku Laitinen <miku@avoin.systems>"
message["Reply-To"] = "YourCompany Eurooppa <sales@avoin.onmicrosoft.com>"
message["To"] = '"Erik N. French" <ErikNFrench@armyspy.com>'
message["Date"] = "Mon, 06 May 2019 14:16:38 -0000"
return message
def test_reply_to_method_msg_id(self):
# Make administrator follow the partner
self.partner.message_subscribe([self.env.user.partner_id.id])
# Send a message to the followers of the partner
thread_msg = self.partner.with_user(self.demo_user).message_post(
body="dummy message.", message_type="comment", subtype="mail.mt_comment"
)
# Make sure the message headers look right.. or not
# mail_msg = thread_msg.notification_ids[0]
# Get the encoded message address
encoded_msg_id = encode_msg_id(thread_msg.id, self.env)
# Try to read an incoming email
message = self.create_email_message()
del message["To"]
message["To"] = '"Erik N. French" <ErikNFrench+{}{}@armyspy.com>'.format(
MESSAGE_PREFIX, encoded_msg_id
)
thread_id = self.env["mail.thread"].message_process(
model=False, message=message.as_string()
)
self.assertEqual(
thread_msg.res_id,
thread_id,
"The incoming email wasn't connected to the correct thread",
)
# Make sure the message is a comment
incoming_msg1 = self.MailMessage.search(
[("message_id", "=", message["Message-Id"])]
)
self.assertEqual(
incoming_msg1.message_type,
"email",
"The incoming message was created as a type {} instead of a email.".format(
incoming_msg1.message_type
),
)
self.assertEqual(
incoming_msg1.subtype_id,
self.subtype_comment,
"The incoming message was created as a subtype {} instead of a comment.".format(
incoming_msg1.subtype_id
),
)
# Try to read another incoming email
message = self.create_email_message()
del message["To"]
message["To"] = '"Erik N. French" <ErikNFrench+{}HURDURLUR@armyspy.com>'.format(
MESSAGE_PREFIX
)
message["In-Reply-To"] = thread_msg.message_id
thread_id = self.env["mail.thread"].message_process(
model=False, message=message.as_string()
)
self.assertEqual(
thread_msg.res_id,
thread_id,
"The incoming email wasn't connected to the correct thread",
)
# Make sure the message is a comment
incoming_msg2 = self.MailMessage.search(
[("message_id", "=", message["Message-Id"])]
)
self.assertEqual(
incoming_msg2.message_type,
"email",
"The incoming message was created as a type {} instead of a email.".format(
incoming_msg2.message_type
),
)
self.assertEqual(
incoming_msg2.subtype_id,
self.subtype_comment,
"The incoming message was created as a subtype {} instead of a comment.".format(
incoming_msg2.subtype_id
),
)
def test_reply_to_method_msg_id_priority(self):
"""
In this test we will inject the wrong Message-Id to the incoming
email messages References-header and see if Odoo will prioritize
the custom Reply-To address over the References-header. It should.
:return:
"""
# Make administrator follow the partner
self.partner.message_subscribe([self.env.user.partner_id.id])
# Send a message to the followers of the partner
thread_msg = self.partner.with_user(self.demo_user).message_post(
body="dummy message X.", message_type="comment", subtype="mail.mt_comment"
)
# Get the encoded message address
encoded_msg_id = encode_msg_id(thread_msg.id, self.env)
# Send another message to the followers of the partner
thread_msg2 = self.partner2.with_user(self.demo_user).message_post(
body="dummy message X.", message_type="comment", subtype="mail.mt_comment"
)
# Try to read an incoming email
message = self.create_email_message()
del message["To"]
del message["References"]
message["To"] = '"Erik N. French" <ErikNFrench+{}{}@armyspy.com>'.format(
MESSAGE_PREFIX, encoded_msg_id
)
# Inject the wrong References
message["References"] = thread_msg2.message_id
thread_id = self.env["mail.thread"].message_process(
model=False, message=message.as_string()
)
self.assertEqual(
thread_msg.res_id,
thread_id,
"The incoming email wasn't connected to the correct thread",
)
def test_reply_to_method_msg_id_notification(self):
# Make administrator follow the partner
self.partner2.message_subscribe([self.env.user.partner_id.id])
# Send a message to the followers of the partner
thread_msg = self.partner2.with_user(self.demo_user).message_post(
body="dummy message 2.", message_type="comment", subtype="mail.mt_note"
)
# Get the encoded message address
encoded_msg_id = encode_msg_id(thread_msg.id, self.env)
# Try to read an incoming email
message = self.create_email_message()
del message["To"]
message["To"] = '"Erik N. French" <ErikNFrench+{}{}@armyspy.com>'.format(
MESSAGE_PREFIX, encoded_msg_id
)
thread_id = self.env["mail.thread"].message_process(
model=False, message=message.as_string()
)
self.assertEqual(
thread_msg.res_id,
thread_id,
"The incoming email wasn't connected to the correct thread",
)
# Make sure the message is a note
incoming_msg1 = self.MailMessage.search(
[("message_id", "=", message["Message-Id"])]
)
self.assertEqual(
incoming_msg1.message_type,
"email",
"The incoming message was created as a type {} instead of a email.".format(
incoming_msg1.message_type
),
)
self.assertEqual(
incoming_msg1.subtype_id,
self.subtype_note,
"The incoming message was created as a subtype {} instead of a note.".format(
incoming_msg1.subtype_id
),
)
def test_reply_to_method_msg_id_legacy(self):
# REMOVE this test when porting to Odoo 14
# Make administrator follow the partner
self.partner2.message_subscribe([self.env.user.partner_id.id])
# Send a message to the followers of the partner
thread_msg = self.partner2.with_user(self.demo_user).message_post(
body="dummy message 2.", message_type="comment", subtype="mail.mt_note"
)
# Get the encoded message address
encoded_msg_id = encode_msg_id_legacy(thread_msg.id, self.env)
# Try to read an incoming email
message = self.create_email_message()
del message["To"]
message["To"] = '"Erik N. French" <ErikNFrench+{}{}@armyspy.com>'.format(
MESSAGE_PREFIX, encoded_msg_id
)
thread_id = self.env["mail.thread"].message_process(
model=False, message=message.as_string()
)
self.assertEqual(
thread_msg.res_id,
thread_id,
"The incoming email wasn't connected to the correct thread",
)
def test_reply_to_method_msg_id_lowercase(self):
# Make administrator follow the partner
self.partner2.message_subscribe([self.env.user.partner_id.id])
# Send a message to the followers of the partner
thread_msg = self.partner2.with_user(self.demo_user).message_post(
body="dummy message 2.", message_type="comment", subtype="mail.mt_note"
)
# Get the encoded message address
encoded_msg_id = encode_msg_id(thread_msg.id, self.env).lower()
# Try to read an incoming email
message = self.create_email_message()
del message["To"]
message["To"] = '"Erik N. French" <ErikNFrench+{}{}@armyspy.com>'.format(
MESSAGE_PREFIX, encoded_msg_id
)
thread_id = self.env["mail.thread"].message_process(
model=False, message=message.as_string()
)
self.assertEqual(
thread_msg.res_id,
thread_id,
"The incoming email wasn't connected to the correct thread",
)
def test_outgoing_msg_id(self):
# Make administrator follow the partner
self.partner2.message_subscribe([SUPERUSER_ID])
with mock.patch.object(IrMailServer, "send_email") as send_email:
# Send a message to the followers of the partner
thread_msg = self.partner2.with_user(self.demo_user).message_post(
body="dummy message 3.",
message_type="comment",
subtype="mail.mt_comment",
)
# Get the encoded message address
encoded_msg_id = encode_msg_id(thread_msg.id, self.env)
self.assertTrue(
send_email.called,
"IrMailServer.send_email wasn't called when sending outgoing email",
)
message = send_email.call_args[0][0]
reply_to_address = "{}{}@{}".format(
MESSAGE_PREFIX,
encoded_msg_id,
self.outgoing_server.force_email_reply_to_domain,
)
# Make sure the subaddress is correct in the Reply-To field
self.assertIn(
reply_to_address,
message["Reply-To"],
"Reply-To address didn't contain the correct subaddress",
)
# Make sure the author name is in the Reply-To field
self.assertIn(
thread_msg.author_id.name,
message["Reply-To"],
"Reply-To address didn't contain the author name",
)
self.assertIn(
self.outgoing_server.force_email_from,
message["From"],
"From address didn't contain the configure From-address",
)

22
email_headers/views/ir_mail_server_views.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- FORM: ir.mail.server -->
<record id="ir_mail_server_form_email_headers" model="ir.ui.view">
<field name="name">ir.mail_server.form.email.headers</field>
<field name="model">ir.mail_server</field>
<field name="inherit_id" ref="base.ir_mail_server_form" />
<field name="arch" type="xml">
<xpath expr="//group[last()]" position="after">
<group name="advanced" string="Smart Headers">
<field name="force_email_sender" />
<field name="force_email_reply_to" />
<field name="force_email_reply_to_name" />
<field name="force_email_reply_to_domain" />
<field name="force_email_from" />
<field name="reply_to_method" />
<field name="headers_example" />
</group>
</xpath>
</field>
</record>
</odoo>

29
mail_all/README.rst

@ -0,0 +1,29 @@
.. image:: https://itpp.dev/images/infinity-readme.png
:alt: Tested and maintained by IT Projects Labs
:target: https://itpp.dev
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: https://opensource.org/licenses/MIT
:alt: License: MIT
===================
Show all messages
===================
Adds ``Discuss / All`` menu, that shows all messages accessible by current user.
Questions?
==========
To get an assistance on this module contact us by email :arrow_right: help@itpp.dev
Contributors
============
* Pavel Romanchenko <apps@it-projects.info>
===================
Odoo Apps Store: https://apps.odoo.com/apps/modules/13.0/mail_all/
Tested on `Odoo 11.0 <https://github.com/odoo/odoo/commit/69c0e6be96563187c09c3748daa61347f7e29360>`_

1
mail_all/__init__.py

@ -0,0 +1 @@
# License MIT (https://opensource.org/licenses/MIT).

30
mail_all/__manifest__.py

@ -0,0 +1,30 @@
# Copyright 2016-2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2017-2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License MIT (https://opensource.org/licenses/MIT).
{
"name": "Show all messages",
"summary": """Checkout all messages where you have access""",
"category": "Discuss",
# "live_test_url": "",
"images": ["images/1.jpg"],
"version": "13.0.1.0.1",
"application": False,
"author": "IT-Projects LLC, Pavel Romanchenko",
"support": "apps@itpp.dev",
"website": "https://it-projects.info",
"license": "Other OSI approved licence", # MIT
"price": 40.00,
"currency": "EUR",
"depends": ["mail"],
"external_dependencies": {"python": [], "bin": []},
"data": ["views/templates.xml"],
"qweb": ["static/src/xml/menu.xml"],
"demo": [],
"post_load": None,
"pre_init_hook": None,
"post_init_hook": None,
"uninstall_hook": None,
"installable": False,
"auto_install": False,
}

9
mail_all/doc/changelog.rst

@ -0,0 +1,9 @@
`1.0.1`
-------
- **Fix:** Incorrect counter
`1.0.0`
-------
- Init version

19
mail_all/doc/index.rst

@ -0,0 +1,19 @@
===================
Show all messages
===================
Installation
============
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
Configuration
=============
This module does not require special configuration.
Usage
=====
* Open menu ``Discuss / All messages``
* You see all messages

70
mail_all/i18n/de.po

@ -0,0 +1,70 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_all
#
# Translators:
# Dawid Runowski <dawrun@outlook.com>, 2019
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Dawid Runowski <dawrun@outlook.com>, 2019\n"
"Language-Team: German (https://www.transifex.com/it-projects-llc/teams/76080/"
"de/)\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/mail_all.js:23
#, fuzzy, python-format
msgid "All Messages"
msgstr "Alle Nachrichten"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/xml/menu.xml:10
#, python-format
msgid "All messages"
msgstr "Alle Nachrichten"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:23
#, python-format
msgid "Check that All Messages are opened"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:17
#, python-format
msgid "Click to enter menu discuss"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:13
#, python-format
msgid "Click to open app list"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/xml/menu.xml:20
#, python-format
msgid "No messages"
msgstr "Keine Nachrichten"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:20
#, fuzzy, python-format
msgid "Open All Messages"
msgstr "Alle Nachrichten"

69
mail_all/i18n/es.po

@ -0,0 +1,69 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_all
#
# Translators:
# Randall Castro <rcastro@treintaycinco.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-21 23:07+0000\n"
"PO-Revision-Date: 2018-04-21 23:07+0000\n"
"Last-Translator: Randall Castro <rcastro@treintaycinco.com>, 2018\n"
"Language-Team: Spanish (https://www.transifex.com/it-projects-llc/"
"teams/76080/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/mail_all.js:23
#, fuzzy, python-format
msgid "All Messages"
msgstr "Todos los mensajes"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/xml/menu.xml:10
#, python-format
msgid "All messages"
msgstr "Todos los mensajes"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:23
#, python-format
msgid "Check that All Messages are opened"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:17
#, python-format
msgid "Click to enter menu discuss"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:13
#, python-format
msgid "Click to open app list"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/xml/menu.xml:20
#, python-format
msgid "No messages"
msgstr "Sin mensajes"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:20
#, fuzzy, python-format
msgid "Open All Messages"
msgstr "Todos los mensajes"

64
mail_all/i18n/mail_all.pot

@ -0,0 +1,64 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_all
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/mail_all.js:23
#, python-format
msgid "All Messages"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/xml/menu.xml:10
#, python-format
msgid "All messages"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:23
#, python-format
msgid "Check that All Messages are opened"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:17
#, python-format
msgid "Click to enter menu discuss"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:13
#, python-format
msgid "Click to open app list"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/xml/menu.xml:18
#, python-format
msgid "No messages"
msgstr ""
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/test_mail_all.js:20
#, python-format
msgid "Open All Messages"
msgstr ""

35
mail_all/i18n/sl.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_all
#
# Translators:
# Matjaz Mozetic <m.mozetic@matmoz.si>, 2019
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Matjaz Mozetic <m.mozetic@matmoz.si>, 2019\n"
"Language-Team: Slovenian (https://www.transifex.com/it-projects-llc/teams/76080/sl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/js/mail_all.js:49
#: code:addons/mail_all/static/src/xml/menu.xml:7
#, python-format
msgid "All messages"
msgstr "Vsa sporočila"
#. module: mail_all
#. openerp-web
#: code:addons/mail_all/static/src/xml/menu.xml:15
#, python-format
msgid "No messages"
msgstr "Ni sporočil"

BIN
mail_all/images/1.jpg

After

Width: 334  |  Height: 171  |  Size: 11 KiB

BIN
mail_all/static/description/1.png

After

Width: 300  |  Height: 270  |  Size: 15 KiB

BIN
mail_all/static/description/2.png

After

Width: 765  |  Height: 400  |  Size: 22 KiB

BIN
mail_all/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 2.1 KiB

84
mail_all/static/description/index.html

@ -0,0 +1,84 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Show all messages</h2>
<h3 class="oe_slogan">Checkout all messages where you have access</h3>
</div>
<div class="oe_span6">
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" src="1.png"/>
</div>
</div>
<div class="oe_span6">
<p class="oe_mt32">
The module adds usual menu.
</p>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<p class="oe_mt32">
This menu shows all messages.
</p>
</div>
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" src="2.png"/>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span8">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:apps@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:apps@it-projects.info">apps@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
<li><a href="https://m.me/itprojectsllc" target="_blank">https://m.me/itprojectsllc <i class="fa fa-facebook-square"></i></a></li>
<li>skype@it-projects.info <i class="fa fa-skype"></i></li>
</ul>
</div>
<div class="oe_span4">
<div class="stamp" style="width:200px;">
<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(6deg);
-o-transform: rotate(6deg);
-moz-transform: rotate(6deg);
-ms-transform: rotate(6deg);">
Tested on Odoo<br/>12.0 community
</div>
<!--<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
-ms-transform: rotate(-3deg);">
Tested on Odoo<br/>12.0 enterprise
</div>-->
</div>
</div>
</div>
</section>

3
mail_all/static/src/css/mail_all.css

@ -0,0 +1,3 @@
.o_channel_name.mail_all i {
margin-right: 4px;
}

50
mail_all/static/src/js/mail_all.js

@ -0,0 +1,50 @@
/* # Copyright 2016-2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2017-2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License MIT (https://opensource.org/licenses/MIT). */
odoo.define("mail_all.all", function(require) {
"use strict";
var core = require("web.core");
var Manager = require("mail.Manager");
var Mailbox = require("mail.model.Mailbox");
var _t = core._t;
Manager.include({
_updateMailboxesFromServer: function(data) {
this._super(data);
if (
!_.find(this.getThreads(), function(th) {
return th.getID() === "mailbox_channel_all";
})
) {
this._addMailbox({
id: "channel_all",
name: _t("All Messages"),
mailboxCounter: 0,
});
}
},
_makeMessage: function(data) {
var message = this._super(data);
message._addThread("mailbox_channel_all");
return message;
},
});
Mailbox.include({
_getThreadDomain: function() {
if (this._id === "mailbox_channel_all") {
return [];
}
return this._super();
},
});
return {
Manager: Manager,
Mailbox: Mailbox,
};
});

33
mail_all/static/src/js/test_mail_all.js

@ -0,0 +1,33 @@
/* # Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License MIT (https://opensource.org/licenses/MIT). */
odoo.define("mail_all.tour", function(require) {
"use strict";
var tour = require("web_tour.tour");
var core = require("web.core");
var _t = core._t;
var steps = [
{
trigger: 'a.full[href="#"]',
content: _t("Click to open app list"),
position: "bottom",
},
{
trigger: 'a.dropdown-item.o_app:contains("Discuss")',
content: _t("Click to enter menu discuss"),
position: "bottom",
},
{
content: _t("Open All Messages"),
trigger: ".o_channel_name.mail_all",
},
{
content: _t("Check that All Messages are opened"),
trigger:
".o_mail_discuss_title_main.o_mail_mailbox_title_all.o_mail_discuss_item.o_active",
},
];
tour.register("tour_mail_all", {test: true, url: "/web"}, steps);
});

27
mail_all/static/src/xml/menu.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--# Copyright 2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License MIT (https://opensource.org/licenses/MIT). -->
<template>
<!--Inherit Sidebar and add All messages menu item after Starred -->
<t t-extend="mail.discuss.Sidebar">
<t t-jquery="div[data-thread-id=mailbox_starred]" t-operation="after">
<div
t-attf-class="o_mail_discuss_title_main o_mail_mailbox_title_all o_mail_discuss_item #{(activeThreadID == 'channel_all') ? 'o_active': ''}"
data-thread-id="mailbox_channel_all"
>
<span class="o_channel_name mail_all"> <i
class="fa fa-database"
/> All messages </span>
</div>
</t>
</t>
<!--Add message about empty all messages page-->
<t t-extend="mail.widget.Thread.Empty">
<t t-jquery="t:last" t-operation="after">
<t t-if="thread.getID() === 'mailbox_channel_all'">
<div class="o_thread_title">No messages</div>
</t>
</t>
</t>
</template>

3
mail_all/tests/__init__.py

@ -0,0 +1,3 @@
# License MIT (https://opensource.org/licenses/MIT).
from . import test_js

27
mail_all/tests/test_js.py

@ -0,0 +1,27 @@
# Copyright 2016 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2016 manawi <https://it-projects.info/team/manawi>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License MIT (https://opensource.org/licenses/MIT).
import odoo.tests
@odoo.tests.common.at_install(True)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
def test_01_mail_all(self):
# needed because tests are run before the module is marked as
# installed. In js web will only load qweb coming from modules
# that are returned by the backend in module_boot. Without
# this you end up with js, css but no qweb.
self.env["ir.module.module"].search(
[("name", "=", "mail_all")], limit=1
).state = "installed"
link = "/web#action=%s" % self.ref("mail.action_discuss")
self.phantom_js(
link,
"odoo.__DEBUG__.services['web_tour.tour'].run('tour_mail_all', 1000)",
"odoo.__DEBUG__.services['web_tour.tour'].tours.tour_mail_all.ready",
login="admin",
)

21
mail_all/views/templates.xml

@ -0,0 +1,21 @@
<?xml version="1.0" ?>
<!--# Copyright 2016 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License MIT (https://opensource.org/licenses/MIT). -->
<odoo>
<template
id="mail_all_assets_backend"
name="mail_all_assets_backend"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<link rel="stylesheet" href="/mail_all/static/src/css/mail_all.css" />
<script src="/mail_all/static/src/js/mail_all.js" type="text/javascript" />
<script
src="/mail_all/static/src/js/test_mail_all.js"
type="text/javascript"
/>
</xpath>
</template>
</odoo>

25
mail_archives/README.rst

@ -0,0 +1,25 @@
.. image:: https://itpp.dev/images/infinity-readme.png
:alt: Tested and maintained by IT Projects Labs
:target: https://itpp.dev
===============
Mail Archives
===============
Adds Archive menu, which shows sent/received messages
Questions?
==========
To get an assistance on this module contact us by email :arrow_right: help@itpp.dev
Contributors
============
* Pavel Romanchenko <apps@it-projects.info>
===================
Odoo Apps Store: https://apps.odoo.com/apps/modules/13.0/mail_archives/
Tested on `Odoo 12.0 <https://github.com/odoo/odoo/commit/c423e5fe047a66517a60b68874e18dc5c3697787>`_

0
mail_archives/__init__.py

17
mail_archives/__manifest__.py

@ -0,0 +1,17 @@
{
"name": "Mail archives",
"summary": """Adds menu to find old messages""",
"category": "Discuss",
"images": ["images/1.jpg"],
"version": "13.0.1.0.1",
"author": "IT-Projects LLC, Pavel Romanchenko",
"support": "apps@itpp.dev",
"website": "https://it-projects.info",
"license": "Other OSI approved licence", # MIT
"price": 40.00,
"currency": "EUR",
"depends": ["mail"],
"data": ["views/templates.xml"],
"qweb": ["static/src/xml/menu.xml"],
"installable": False,
}

11
mail_archives/doc/changelog.rst

@ -0,0 +1,11 @@
`1.0.1`
-------
- **Fix:** Mails from channels were not downloaded automatically
- **Fix:** Fetching mails from another threads
- **Fix:** Incorrect counter
`1.0.0`
-------
- Init version

20
mail_archives/doc/index.rst

@ -0,0 +1,20 @@
==============
Mail Archives
==============
Installation
============
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
Configuration
=============
This module does not require special configuration.
Usage
=====
* Open ``Discuss``.
* Click ``Archive``.
* Sent/received messages are displayed.

36
mail_archives/i18n/de.po

@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_archives
#
# Translators:
# Dawid Runowski <dawrun@outlook.com>, 2019
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Dawid Runowski <dawrun@outlook.com>, 2019\n"
"Language-Team: German (https://www.transifex.com/it-projects-llc/teams/76080/"
"de/)\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mail_archives
#. openerp-web
#: code:addons/mail_archives/static/src/js/archives.js:20
#: code:addons/mail_archives/static/src/xml/menu.xml:8
#, python-format
msgid "Archive"
msgstr "Archiv"
#. module: mail_archives
#. openerp-web
#: code:addons/mail_archives/static/src/xml/menu.xml:18
#, python-format
msgid "Archive is empty"
msgstr "Archiv ist leer"

35
mail_archives/i18n/es.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_archives
#
# Translators:
# Randall Castro <rcastro@treintaycinco.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-21 23:07+0000\n"
"PO-Revision-Date: 2018-04-21 23:07+0000\n"
"Last-Translator: Randall Castro <rcastro@treintaycinco.com>, 2018\n"
"Language-Team: Spanish (https://www.transifex.com/it-projects-llc/"
"teams/76080/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mail_archives
#. openerp-web
#: code:addons/mail_archives/static/src/js/archives.js:20
#: code:addons/mail_archives/static/src/xml/menu.xml:8
#, python-format
msgid "Archive"
msgstr "Archivo"
#. module: mail_archives
#. openerp-web
#: code:addons/mail_archives/static/src/xml/menu.xml:18
#, python-format
msgid "Archive is empty"
msgstr "Archivo está vacío"

30
mail_archives/i18n/mail_archives.pot

@ -0,0 +1,30 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_archives
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: mail_archives
#. openerp-web
#: code:addons/mail_archives/static/src/js/archives.js:21
#: code:addons/mail_archives/static/src/xml/menu.xml:8
#, python-format
msgid "Archive"
msgstr ""
#. module: mail_archives
#. openerp-web
#: code:addons/mail_archives/static/src/xml/menu.xml:16
#, python-format
msgid "Archive is empty"
msgstr ""

35
mail_archives/i18n/sl.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_archives
#
# Translators:
# Matjaz Mozetic <m.mozetic@matmoz.si>, 2019
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Matjaz Mozetic <m.mozetic@matmoz.si>, 2019\n"
"Language-Team: Slovenian (https://www.transifex.com/it-projects-llc/teams/76080/sl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
#. module: mail_archives
#. openerp-web
#: code:addons/mail_archives/static/src/js/archives.js:68
#: code:addons/mail_archives/static/src/xml/menu.xml:7
#, python-format
msgid "Archive"
msgstr "Arhiv"
#. module: mail_archives
#. openerp-web
#: code:addons/mail_archives/static/src/xml/menu.xml:15
#, python-format
msgid "Archive is empty"
msgstr "Arhiv je prazen"

BIN
mail_archives/images/1.jpg

After

Width: 334  |  Height: 171  |  Size: 18 KiB

BIN
mail_archives/static/description/1.png

After

Width: 300  |  Height: 270  |  Size: 24 KiB

BIN
mail_archives/static/description/2.png

After

Width: 765  |  Height: 400  |  Size: 40 KiB

BIN
mail_archives/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 2.1 KiB

84
mail_archives/static/description/index.html

@ -0,0 +1,84 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Look up old mails</h2>
<h3 class="oe_slogan">Browse archived mails like in odoo 8</h3>
</div>
<div class="oe_span6">
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" src="1.png"/>
</div>
</div>
<div class="oe_span6">
<p class="oe_mt32">
The module adds usual menu.
</p>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<p class="oe_mt32">
This menu shows archive messages, i.e. ones you sent or received.
</p>
</div>
<div class="oe_row_img oe_centered">
<img class="oe_picture oe_screenshot" src="2.png"/>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span8">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:apps@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:apps@it-projects.info">apps@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
<li><a href="https://m.me/itprojectsllc" target="_blank">https://m.me/itprojectsllc <i class="fa fa-facebook-square"></i></a></li>
<li>skype@it-projects.info <i class="fa fa-skype"></i></li>
</ul>
</div>
<div class="oe_span4">
<div class="stamp" style="width:200px;">
<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(6deg);
-o-transform: rotate(6deg);
-moz-transform: rotate(6deg);
-ms-transform: rotate(6deg);">
Tested on Odoo<br/>12.0 community
</div>
<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(-7deg);
-o-transform: rotate(-7deg);
-moz-transform: rotate(-7deg);
-ms-transform: rotate(-7deg);">
Tested on Odoo<br/>12.0 enterprise
</div>
</div>
</div>
</div>
</section>

3
mail_archives/static/src/css/archives.css

@ -0,0 +1,3 @@
.o_channel_name.mail_archives i {
margin-right: 4px;
}

91
mail_archives/static/src/js/archives.js

@ -0,0 +1,91 @@
odoo.define("mail_archives.archives", function(require) {
"use strict";
var core = require("web.core");
var session = require("web.session");
var Manager = require("mail.Manager");
var Mailbox = require("mail.model.Mailbox");
var SearchableThread = require("mail.model.SearchableThread");
var _t = core._t;
Manager.include({
_updateMailboxesFromServer: function(data) {
this._super(data);
if (
!_.find(this.getThreads(), function(th) {
return th.getID() === "mailbox_channel_archive";
})
) {
this._addMailbox({
id: "channel_archive",
name: _t("Archive"),
mailboxCounter: 0,
});
}
},
});
SearchableThread.include({
_fetchMessages: function(pDomain, loadMore) {
var self = this;
if (this._id !== "mailbox_channel_archive") {
return this._super(pDomain, loadMore);
}
// This is a copy-paste from super method
var domain = this._getThreadDomain();
var cache = this._getCache(pDomain);
if (pDomain) {
domain = domain.concat(pDomain || []);
}
if (loadMore) {
var minMessageID = cache.messages[0].getID();
domain = [["id", "<", minMessageID]].concat(domain);
}
return this._rpc({
model: "mail.message",
method: "message_fetch",
args: [domain],
kwargs: this._getFetchMessagesKwargs(),
}).then(function(messages) {
// Except this function. It adds the required thread to downloaded messages
_.each(messages, function(m) {
m.channel_ids.push("mailbox_channel_archive");
});
if (!cache.allHistoryLoaded) {
cache.allHistoryLoaded = messages.length < self._FETCH_LIMIT;
}
cache.loaded = true;
_.each(messages, function(message) {
self.call("mail_service", "addMessage", message, {
silent: true,
domain: pDomain,
});
});
cache = self._getCache(pDomain || []);
return cache.messages;
});
},
});
Mailbox.include({
_getThreadDomain: function() {
if (this._id === "mailbox_channel_archive") {
return [
"|",
"|",
["partner_ids", "in", [session.partner_id]],
["author_id", "in", [session.partner_id]],
["channel_ids.channel_partner_ids", "in", [session.partner_id]],
];
}
return this._super();
},
});
return {
Manager: Manager,
Mailbox: Mailbox,
};
});

24
mail_archives/static/src/xml/menu.xml

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<template>
<!--Inherit Sidebar and add Archive menu item after Starred -->
<t t-extend="mail.discuss.Sidebar">
<t t-jquery="div[data-thread-id=mailbox_starred]" t-operation="after">
<div
t-attf-class="o_mail_discuss_title_main o_mail_discuss_item #{(activeThreadID == 'channel_archive') ? 'o_active': ''}"
data-thread-id="mailbox_channel_archive"
>
<span class="o_channel_name mail_archives"> <i
class="fa fa-archive"
/> Archive </span>
</div>
</t>
</t>
<!--Add message about empty archive page-->
<t t-extend="mail.widget.Thread.Empty">
<t t-jquery="t:last" t-operation="after">
<t t-if="thread.getID() === 'mailbox_channel_archive'">
<div class="o_thread_title">Archive is empty</div>
</t>
</t>
</t>
</template>

1
mail_archives/tests/__init__.py

@ -0,0 +1 @@
from . import test_js

31
mail_archives/tests/test_js.py

@ -0,0 +1,31 @@
from werkzeug import url_encode
import odoo.tests
@odoo.tests.common.at_install(True)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
def test_01_mail_archives(self):
# needed because tests are run before the module is marked as
# installed. In js web will only load qweb coming from modules
# that are returned by the backend in module_boot. Without
# this you end up with js, css but no qweb.
self.env["ir.module.module"].search(
[("name", "=", "mail_archives")], limit=1
).state = "installed"
# wait till page loaded and then click and wait again
code = """
setTimeout(function () {
console.log($(".mail_archives").length && 'ok' || 'error');
}, 3000);
"""
link = "/web#%s" % url_encode({"action": "mail.action_discuss"})
self.phantom_js(
link,
code,
"odoo.__DEBUG__.services['web_tour.tour'].tours.mail_tour.ready",
login="admin",
)

21
mail_archives/views/templates.xml

@ -0,0 +1,21 @@
<?xml version="1.0" ?>
<openerp>
<data>
<template
id="res_partner_mails_count_assets_backend"
name="res_partner_mails_count_assets_backend"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<link
rel="stylesheet"
href="/mail_archives/static/src/css/archives.css"
/>
<script
src="/mail_archives/static/src/js/archives.js"
type="text/javascript"
/>
</xpath>
</template>
</data>
</openerp>

34
mail_base/README.rst

@ -0,0 +1,34 @@
.. image:: https://itpp.dev/images/infinity-readme.png
:alt: Tested and maintained by IT Projects Labs
:target: https://itpp.dev
===========
Mail Base
===========
* makes built-in mail js features extendable.
* handles ``search_default_*`` parameters in context.
* fixes toggling left bar
* fixes Recipients field. Out-of-box this field could be empty.
One can say, that the module do this todo from `addons/mail/static/src/js/chat_manager.js <https://github.com/odoo/odoo/blob/9.0/addons/mail/static/src/js/chat_manager.js#L57>`__
// to do: move this to mail.utils
Note. Due to odoo restrictions, module makes mail initialization again. That is browser loads emoji and other chat data twice. This is the only way to make Mail feature extendable.
Questions?
==========
To get an assistance on this module contact us by email :arrow_right: help@itpp.dev
Contributors
============
* Pavel Romanchenko <apps@it-projects.info>
===================
Odoo Apps Store: https://apps.odoo.com/apps/modules/11.0/mail_base/
Tested on `Odoo 11.0 <https://github.com/odoo/odoo/commit/ecbf7aa4714479229658d14cce28fa00376ed390>`_

2
mail_base/__init__.py

@ -0,0 +1,2 @@
from . import models
from . import controllers

16
mail_base/__manifest__.py

@ -0,0 +1,16 @@
{
"name": "Mail Base",
"summary": """Makes Mail extendable""",
"category": "Discuss",
"images": [],
"version": "13.0.1.0.2",
"author": "IT-Projects LLC, Pavel Romanchenko",
"support": "apps@itpp.dev",
"website": "https://it-projects.info",
"license": "Other OSI approved licence", # MIT
"price": 9.00,
"currency": "EUR",
"depends": ["base", "mail"],
"data": ["views/templates.xml"],
"installable": False,
}

1
mail_base/controllers/__init__.py

@ -0,0 +1 @@
from . import main

15
mail_base/controllers/main.py

@ -0,0 +1,15 @@
from odoo.http import request
from odoo.addons.bus.controllers.main import BusController
class MailChatController(BusController):
# -----------------------------
# Extends BUS Controller Poll
# -----------------------------
def _poll(self, dbname, channels, last, options):
if request.session.uid:
channels.append((request.db, "mail_base.mail_sent"))
return super(MailChatController, self)._poll(dbname, channels, last, options)

22
mail_base/doc/changelog.rst

@ -0,0 +1,22 @@
`1.0.4`
-------
**FIX**: issue related to clear cache
`1.0.3`
-------
**FIX**: error on clicking messages preview after sending new message
`1.0.2`
-------
- **FIX**: fixed an error with unsubscribing from channel or closing dialog window
`1.0.1`
-------
- **FIX**: clear messages cache on sending message via Mail Composer. Otherwise Sent, Arhives menus will have new message until user refresh whole web page
`1.0.0`
-------
- Init version

18
mail_base/doc/index.rst

@ -0,0 +1,18 @@
=========================
Mail Base
=========================
Installation
============
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
Configuration
=============
This module does not require special configuration.
Usage
=====
* To use this module you need either install module that depends on it or create new module.

31
mail_base/i18n/de.po

@ -0,0 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_base
#
# Translators:
# Dawid Runowski <dawrun@outlook.com>, 2019
# Ermin Trevisan <trevi@twanda.com>, 2019
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2017-11-28 13:59+0000\n"
"Last-Translator: Ermin Trevisan <trevi@twanda.com>, 2019\n"
"Language-Team: German (https://www.transifex.com/it-projects-llc/teams/76080/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Assistent für die Email-Gestaltung"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_message
msgid "Message"
msgstr "Nachricht"

29
mail_base/i18n/es.po

@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_base
#
# Translators:
# Randall Castro <rcastro@treintaycinco.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-21 23:07+0000\n"
"PO-Revision-Date: 2018-04-21 23:07+0000\n"
"Last-Translator: Randall Castro <rcastro@treintaycinco.com>, 2018\n"
"Language-Team: Spanish (https://www.transifex.com/it-projects-llc/teams/76080/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Asistente para composición de correo"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_message
msgid "Message"
msgstr "Mensaje"

29
mail_base/i18n/it.po

@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_base
#
# Translators:
# Translation Bot <i18n-bot@it-projects.info>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-17 20:20+0000\n"
"PO-Revision-Date: 2017-07-17 20:20+0000\n"
"Last-Translator: Translation Bot <i18n-bot@it-projects.info>, 2017\n"
"Language-Team: Italian (https://www.transifex.com/it-projects-llc/teams/76080/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: it\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Componi Email"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_message
msgid "Message"
msgstr "Messaggio"

29
mail_base/i18n/pt.po

@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_base
#
# Translators:
# Translation Bot <i18n-bot@it-projects.info>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-21 00:05+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Translation Bot <i18n-bot@it-projects.info>, 2018\n"
"Language-Team: Portuguese (https://www.transifex.com/it-projects-llc/teams/76080/pt/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: pt\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Assistente de composição de Email"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_message
msgid "Message"
msgstr "Mensagem"

29
mail_base/i18n/pt_BR.po

@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_base
#
# Translators:
# Translation Bot <i18n-bot@it-projects.info>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-21 00:05+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Translation Bot <i18n-bot@it-projects.info>, 2018\n"
"Language-Team: Portuguese (Brazil) (https://www.transifex.com/it-projects-llc/teams/76080/pt_BR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: pt_BR\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Assistente de Composição de Email"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_message
msgid "Message"
msgstr "Mensagem"

29
mail_base/i18n/ru.po

@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_base
#
# Translators:
# Ivan Yelizariev <yelizariev@it-projects.info>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-28 14:34+0000\n"
"PO-Revision-Date: 2017-07-28 14:34+0000\n"
"Last-Translator: Ivan Yelizariev <yelizariev@it-projects.info>, 2017\n"
"Language-Team: Russian (https://www.transifex.com/it-projects-llc/teams/76080/ru/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: ru\n"
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_compose_message
msgid "Email composition wizard"
msgstr ""
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_message
msgid "Message"
msgstr "Сообщение"

31
mail_base/i18n/sl.po

@ -0,0 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_base
#
# Translators:
# Translation Bot <i18n-bot@it-projects.info>, 2017
# Matjaz Mozetic <m.mozetic@matmoz.si>, 2019
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2017-11-28 13:59+0000\n"
"Last-Translator: Matjaz Mozetic <m.mozetic@matmoz.si>, 2019\n"
"Language-Team: Slovenian (https://www.transifex.com/it-projects-llc/teams/76080/sl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Čarovnik za sestavljanje sporočil"
#. module: mail_base
#: model:ir.model,name:mail_base.model_mail_message
msgid "Message"
msgstr "Sporočilo"

29
mail_base/models.py

@ -0,0 +1,29 @@
from odoo import models
class MailMessage(models.Model):
_inherit = "mail.message"
def write(self, values):
if values.get("needaction_partner_ids"):
if not values.get("partner_ids"):
values["partner_ids"] = []
for triplet in values.get("needaction_partner_ids"):
if triplet[0] == 6:
for i in triplet[2]:
values["partner_ids"].append((4, i, False))
return super(MailMessage, self).write(values)
class MailComposer(models.TransientModel):
_inherit = "mail.compose.message"
def send_mail(self, auto_commit=False):
res = super(MailComposer, self).send_mail(auto_commit=auto_commit)
notification = {}
self.env["bus.bus"].sendone(
(self._cr.dbname, "mail_base.mail_sent"), notification
)
return res

BIN
mail_base/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 2.1 KiB

1418
mail_base/static/lib/base.js
File diff suppressed because it is too large
View File

1
mail_base/tests/__init__.py

@ -0,0 +1 @@
from . import test_default

17
mail_base/tests/test_default.py

@ -0,0 +1,17 @@
import odoo.tests
@odoo.tests.common.at_install(False)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
def test_01_mail_base(self):
# wait till page loaded
code = """
setTimeout(function () {
console.log('ok');
}, 1000);
"""
link = "/web#action=%s" % self.ref("mail.mail_channel_action_client_chat")
self.phantom_js(
link, code, "odoo.__DEBUG__.services['mail_base.base']", login="admin"
)

14
mail_base/views/templates.xml

@ -0,0 +1,14 @@
<?xml version="1.0" ?>
<openerp>
<data>
<template
id="mail_base_assets_backend"
name="mail_base_assets_backend"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<script src="/mail_base/static/lib/base.js" type="text/javascript" />
</xpath>
</template>
</data>
</openerp>

8
mail_check_immediately/README.rst

@ -0,0 +1,8 @@
.. image:: https://itpp.dev/images/infinity-readme.png
:alt: Tested and maintained by IT Projects Labs
:target: https://itpp.dev
Check mail immediately
======================
Description: https://apps.odoo.com/apps/modules/8.0/mail_check_immediately/

1
mail_check_immediately/__init__.py

@ -0,0 +1 @@
from . import models

15
mail_check_immediately/__manifest__.py

@ -0,0 +1,15 @@
{
"name": "Check mail immediately",
"vesion": "13.0.1.0.1",
"author": "IT-Projects LLC, Ivan Yelizariev",
"license": "Other OSI approved licence", # MIT
"category": "Discuss",
"support": "apps@itpp.dev",
"website": "https://twitter.com/yelizariev",
"price": 9.00,
"currency": "EUR",
"depends": ["base", "web", "fetchmail", "mail"],
"data": ["views.xml"],
"qweb": ["static/src/xml/main.xml"],
"installable": False,
}

4
mail_check_immediately/doc/changelog.rst

@ -0,0 +1,4 @@
`1.0.1`
-------
- FIX: incorrectly displayed last updated time when multiple threads (--workers)

80
mail_check_immediately/models.py

@ -0,0 +1,80 @@
import datetime
from odoo import api, exceptions, fields, models, tools
from odoo.tools.translate import _
class FetchMailServer(models.Model):
_inherit = "fetchmail.server"
_name = "fetchmail.server"
_last_updated = None
run_time = fields.Datetime(string="Launch time")
def _run_time(self):
if not self._last_updated:
self._last_updated = tools.datetime.now()
src_tstamp_str = self._last_updated.strftime(
tools.misc.DEFAULT_SERVER_DATETIME_FORMAT
)
src_format = tools.misc.DEFAULT_SERVER_DATETIME_FORMAT
dst_format = tools.misc.DEFAULT_SERVER_DATETIME_FORMAT
dst_tz_name = self._context.get("tz") or self.env.user.tz
_now = tools.misc.server_to_local_timestamp(
src_tstamp_str, src_format, dst_format, dst_tz_name
)
return _now
@api.model
def _fetch_mails(self):
if self._context.get("run_fetchmail_manually"):
# if interval less than 5 seconds
if self._last_updated and (
datetime.datetime.now() - self._last_updated
) < datetime.timedelta(0, 5):
raise exceptions.Warning(
_("Error"), _("Task can be started no earlier than 5 seconds.")
)
super(FetchMailServer, self)._fetch_mails()
res = (
self.env["fetchmail.server"]
.sudo()
.with_context(tz=self.env.user.tz)
.search([("state", "=", "done")])
)
if res:
res[0].run_time = self._run_time()
class FetchMailImmediately(models.AbstractModel):
_name = "fetch_mail.imm"
@api.model
def get_last_update_time(self):
res = (
self.env["fetchmail.server"]
.sudo()
.with_context(tz=self.env.user.tz)
.search([("state", "=", "done")])
)
array = [r.run_time for r in res]
if array:
return array[0]
else:
return None
@api.model
def run_fetchmail_manually(self):
fetchmail_task = self.env.ref("fetchmail.ir_cron_mail_gateway_action")
fetchmail_model = self.env["fetchmail.server"].sudo()
fetchmail_task._try_lock()
fetchmail_model.with_context(run_fetchmail_manually=True)._fetch_mails()

BIN
mail_check_immediately/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 2.1 KiB

49
mail_check_immediately/static/description/index.html

@ -0,0 +1,49 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Check mail immediately</h2>
<h3 class="oe_slogan">Keep your inbox up to date</h3>
</div>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot">
<img src="screenshot.png?"/>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2>Protect your business</h2>
</div>
<div class="oe_span6">
<p class="oe_mt32">
<a href="https://github.com/odoo/odoo/issues/7464">Sometimes</a> odoo mail fetching system doesn't work for really long time. It could be a real problem, if you will not notice it on time. Until this issue is fixed, you can restart odoo every time when you see that last fetching time is more than 5 minutes.
</p>
</div>
<div class="oe_span6">
<div class="oe_picture">
<img src="issue.png?3"/>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:apps@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:apps@it-projects.info">apps@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">
https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
<li><a href="https://m.me/itprojectsllc" target="_blank">https://m.me/itprojectsllc <i class="fa fa-facebook-square"></i></a></li>
<li>skype@it-projects.info <i class="fa fa-skype"></i></li>
</ul>
</div>
</div>
</section>

BIN
mail_check_immediately/static/description/issue.png

After

Width: 217  |  Height: 140  |  Size: 8.5 KiB

BIN
mail_check_immediately/static/description/screenshot.png

After

Width: 840  |  Height: 447  |  Size: 88 KiB

60
mail_check_immediately/static/src/js/main.js

@ -0,0 +1,60 @@
openerp.mail_check_immediately = function(instance, local) {
"use strict";
instance.mail.Wall.include({
init: function() {
this._super.apply(this, arguments);
var _this = this;
this.imm_model = new instance.web.Model("fetch_mail.imm");
this.events["click a.oe_fetch_new_mails"] = function() {
_this.run_fetchmail_manually();
};
},
start: function() {
var _this = this;
this._super();
this.get_last_fetched_time();
this.get_time_loop = setInterval(function() {
_this.get_last_fetched_time();
}, 30000);
},
run_fetchmail_manually: function() {
var _this = this;
this.imm_model
.call("run_fetchmail_manually", {
context: new instance.web.CompoundContext(),
})
.then(function() {
_this.get_last_fetched_time();
});
},
get_last_fetched_time: function() {
var _this = this;
this.imm_model
.call("get_last_update_time", {
context: new instance.web.CompoundContext(),
})
.then(function(res) {
var value = null;
if (res) value = $.timeago(res);
value = value || "undefined";
_this.$el
.find("span.oe_view_manager_fetch_mail_imm_field")
.html(value);
});
},
destroy: function() {
clearInterval(this.get_time_loop);
this._super.apply(this, arguments);
},
});
};

29
mail_check_immediately/static/src/xml/main.xml

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<templates>
<t t-name="fetch_mail_immediately.header">
<tr class="oe_header_row">
<td t-att-colspan="colspan or '3'">
<div class="oe_view_manager_fetch_mail_imm">
<em>
<span>Mails fetched:</span>
<a
href="#"
class="oe_fetch_new_mails"
title="Click to fetch mails now"
>
<span class="oe_view_manager_fetch_mail_imm_field" />
</a>
</em>
</div>
</td>
<td />
</tr>
</t>
<t t-extend="mail.wall">
<t t-jquery="tr.oe_header_row_top" t-operation="after">
<t t-call="fetch_mail_immediately.header">
<t t-set="colspan" t-value="2" />
</t>
</t>
</t>
</templates>

16
mail_check_immediately/views.xml

@ -0,0 +1,16 @@
<openerp>
<data>
<template
id="assets_backend_inherited_check_mail"
name="Check mail immediately bar"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/mail_check_immediately/static/src/js/main.js"
/>
</xpath>
</template>
</data>
</openerp>

48
mail_fix_553/README.rst

@ -0,0 +1,48 @@
.. image:: https://itpp.dev/images/infinity-readme.png
:alt: Tested and maintained by IT Projects Labs
:target: https://itpp.dev
Fix mail error 553
==================
Module updates 'FROM' field to portal@MYDOMAIN.COM value in order to fix 553 error on a mail service that checks FROM field.
E.g:
* Customer send email from USER@CUSTOMER.com to info@MYDOMAIN.COM
* odoo accept email and try to send notifcation to related odoo users. E.g to admin@gmail.com.
* By default odoo prepare notification email with parameters as follows:
* FROM: user@CUSTOMER.com
* TO: admin@gmail.com
if you mail service provider, e.g. pdd.yandex.ru, doesn't allow emails with a FROM value differ from ...@MYDOMAIN.COM, then you get 553. This is why you need to update FROM value to portal@MYDOMAIN.COM
Configuration
=============
You can configure default alias at Settings -> System Parameters -> mail.catchall.alias_from
You can configure name for default alias at Settings -> System Parameters -> mail.catchall.name_alias_from
You can configure name for default alias at Settings -> System Parameters -> mail.catchall.name_alias_from
Known issues / Roadmap
======================
The module is consist of redefined send function from mail.mail
model. So it is just copy pasted source code with some
modification. This function is changed very rarely, but sometime it
can happens and the module should be updated. You can check commits
for mail_mail.py here:
https://github.com/odoo/odoo/commits/8.0/addons/mail/mail_mail.py
Tested on `Odoo 8.0 <https://github.com/odoo/odoo/commit/d023c079ed86468436f25da613bf486a4a17d625>`_
Status
======
Related issues at odoo's tracker:
* https://github.com/odoo/odoo/issues/5864
* https://github.com/odoo/odoo/issues/3347
Fix: https://github.com/odoo-dev/odoo/commit/a4597fe34fcfa8dae28b156410080346bb33af33

1
mail_fix_553/__init__.py

@ -0,0 +1 @@
from . import mail_fix_553

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save