Browse Source

Merge pull request #338 from Eficent/12.0-mig-mail_activity_board

[12.0][MIG] mail_activity_board
pull/376/head
Jordi Ballester Alomar 5 years ago
committed by GitHub
parent
commit
893a6d3f25
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 94
      mail_activity_board/README.rst
  2. 1
      mail_activity_board/__init__.py
  3. 24
      mail_activity_board/__manifest__.py
  4. 113
      mail_activity_board/i18n/mail_activity_board.pot
  5. 2
      mail_activity_board/models/__init__.py
  6. 107
      mail_activity_board/models/mail_activity.py
  7. 32
      mail_activity_board/models/mail_activity_mixin.py
  8. 7
      mail_activity_board/readme/CONTRIBUTORS.rst
  9. 2
      mail_activity_board/readme/DESCRIPTION.rst
  10. 9
      mail_activity_board/readme/USAGE.rst
  11. BIN
      mail_activity_board/static/description/icon.png
  12. 435
      mail_activity_board/static/description/index.html
  13. 33
      mail_activity_board/static/src/js/override_chatter.js
  14. 13
      mail_activity_board/static/src/xml/inherit_chatter.xml
  15. 1
      mail_activity_board/tests/__init__.py
  16. 172
      mail_activity_board/tests/test_mail_activity_board.py
  17. 210
      mail_activity_board/views/mail_activity_view.xml
  18. 8
      mail_activity_board/views/templates.xml
  19. 2
      mail_activity_done/__manifest__.py
  20. 2
      mail_activity_done/models/mail_activity.py
  21. 2
      mail_activity_done/models/res_users.py
  22. 4
      mail_activity_done/tests/test_mail_activity_done.py
  23. 2
      mail_activity_done/views/mail_activity_views.xml

94
mail_activity_board/README.rst

@ -0,0 +1,94 @@
================
Activities board
================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/12.0/mail_activity_board
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-12-0/social-12-0-mail_activity_board
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/205/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module adds an activity board with form, tree, kanban, calendar, pivot, graph and search views.
**Table of contents**
.. contents::
:local:
Usage
=====
To use this module, you need to:
#. Access to the views from menu Boards.
A smartButton of activities is added in the mail thread from form view.
From this smartButton is linked to the activity board, to the view tree,
which shows the activities related to the opportunity.
From the form view of the activity you can navigate to the origin of the activity.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_activity_board%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* SDi
* David Juaneda
Contributors
~~~~~~~~~~~~
* `SDI <https://www.sdi.es>`_:
* David Juaneda
* `Eficent <https://www.eficent.com>`_:
* Miquel Raïch (miquel.raich@eficent.com)
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/social <https://github.com/OCA/social/tree/12.0/mail_activity_board>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

1
mail_activity_board/__init__.py

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

24
mail_activity_board/__manifest__.py

@ -0,0 +1,24 @@
# Copyright 2018 David Juaneda - <djuaneda@sdi.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Activities board',
'summary': 'Add Activity Boards',
'version': '12.0.1.0.0',
'development_status': 'Beta',
'category': 'Social Network',
'website': 'https://github.com/OCA/social',
'author': 'SDi, David Juaneda, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'installable': True,
'depends': [
'calendar',
'board',
],
'data': [
'views/templates.xml',
'views/mail_activity_view.xml',
],
'qweb': [
'static/src/xml/inherit_chatter.xml',
]
}

113
mail_activity_board/i18n/mail_activity_board.pot

@ -0,0 +1,113 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_activity_board
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.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_activity_board
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_search
msgid "Act. next 6 months"
msgstr ""
#. module: mail_activity_board
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_search
msgid "Act. next month"
msgstr ""
#. module: mail_activity_board
#. openerp-web
#: code:addons/mail_activity_board/static/src/xml/inherit_chatter.xml:8
#: model:ir.actions.act_window,name:mail_activity_board.open_boards_activities
#: model:ir.ui.menu,name:mail_activity_board.board_menu_activities
#, python-format
msgid "Activities"
msgstr ""
#. module: mail_activity_board
#: model:ir.model,name:mail_activity_board.model_mail_activity
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_form_board
msgid "Activity"
msgstr ""
#. module: mail_activity_board
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_form_board
msgid "Activity Form"
msgstr ""
#. module: mail_activity_board
#: model:ir.model,name:mail_activity_board.model_mail_activity_mixin
msgid "Activity Mixin"
msgstr ""
#. module: mail_activity_board
#: model:ir.model.fields,field_description:mail_activity_board.field_mail_activity_calendar_event_id_partner_ids
msgid "Attendees"
msgstr ""
#. module: mail_activity_board
#: model:ir.model.fields,field_description:mail_activity_board.field_mail_activity_duration
msgid "Duration"
msgstr ""
#. module: mail_activity_board
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_form_board
msgid "Log a note..."
msgstr ""
#. module: mail_activity_board
#: model:ir.model.fields,field_description:mail_activity_board.field_mail_activity_res_model_id_name
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_search
msgid "Origin"
msgstr ""
#. module: mail_activity_board
#. openerp-web
#: code:addons/mail_activity_board/static/src/xml/inherit_chatter.xml:7
#, python-format
msgid "See activities list"
msgstr ""
#. module: mail_activity_board
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_search
msgid "Show activities scheduled for next 6 months."
msgstr ""
#. module: mail_activity_board
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_search
msgid "Show activities scheduled for next month."
msgstr ""
#. module: mail_activity_board
#: model:ir.model.fields,field_description:mail_activity_board.field_mail_activity_calendar_event_id_start
msgid "Start"
msgstr ""
#. module: mail_activity_board
#: model:ir.model.fields,help:mail_activity_board.field_mail_activity_calendar_event_id_start
msgid "Start date of an event, without time for full days events"
msgstr ""
#. module: mail_activity_board
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_form_board
msgid "Start meeting"
msgstr ""
#. module: mail_activity_board
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_search
msgid "User"
msgstr ""
#. module: mail_activity_board
#: model:ir.ui.view,arch_db:mail_activity_board.mail_activity_view_form_board
msgid "e.g. Discuss proposal"
msgstr ""

2
mail_activity_board/models/__init__.py

@ -0,0 +1,2 @@
from . import mail_activity
from . import mail_activity_mixin

107
mail_activity_board/models/mail_activity.py

@ -0,0 +1,107 @@
# Copyright 2018 David Juaneda - <djuaneda@sdi.es>
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models, fields, SUPERUSER_ID
class MailActivity(models.Model):
_inherit = "mail.activity"
res_model_id_name = fields.Char(
related='res_model_id.name', string="Origin",
readonly=True)
duration = fields.Float(
related='calendar_event_id.duration', readonly=True)
calendar_event_id_start = fields.Datetime(
related='calendar_event_id.start', readonly=True)
calendar_event_id_partner_ids = fields.Many2many(
related='calendar_event_id.partner_ids',
readonly=True)
@api.multi
def open_origin(self):
self.ensure_one()
vid = self.env[self.res_model].browse(self.res_id).get_formview_id()
response = {
'type': 'ir.actions.act_window',
'res_model': self.res_model,
'view_mode': 'form',
'res_id': self.res_id,
'target': 'current',
'flags': {
'form': {
'action_buttons': False
}
},
'views': [
(vid, "form")
]
}
return response
@api.model
def action_activities_board(self):
action = self.env.ref(
'mail_activity_board.open_boards_activities').read()[0]
return action
@api.model
def _find_allowed_model_wise(self, doc_model, doc_dict):
doc_ids = list(doc_dict)
allowed_doc_ids = self.env[doc_model].with_context(
active_test=False).search([('id', 'in', doc_ids)]).ids
return set([message_id for allowed_doc_id in allowed_doc_ids
for message_id in doc_dict[allowed_doc_id]])
@api.model
def _find_allowed_doc_ids(self, model_ids):
ir_model_access_model = self.env['ir.model.access']
allowed_ids = set()
for doc_model, doc_dict in model_ids.items():
if not ir_model_access_model.check(doc_model, 'read', False):
continue
allowed_ids |= self._find_allowed_model_wise(doc_model, doc_dict)
return allowed_ids
@api.model
def _search(self, args, offset=0, limit=None, order=None, count=False,
access_rights_uid=None):
# Rules do not apply to administrator
if self._uid == SUPERUSER_ID:
return super(MailActivity, self)._search(
args, offset=offset, limit=limit, order=order,
count=count, access_rights_uid=access_rights_uid)
ids = super(MailActivity, self)._search(
args, offset=offset, limit=limit, order=order,
count=False, access_rights_uid=access_rights_uid)
if not ids and count:
return 0
elif not ids:
return ids
# check read access rights before checking the actual rules
super(MailActivity, self.sudo(access_rights_uid or self._uid)).\
check_access_rights('read')
model_ids = {}
self._cr.execute("""
SELECT DISTINCT a.id, im.id, im.model, a.res_id
FROM "%s" a
LEFT JOIN ir_model im ON im.id = a.res_model_id
WHERE a.id = ANY (%%(ids)s)""" % self._table, dict(ids=ids))
for a_id, ir_model_id, model, model_id in self._cr.fetchall():
model_ids.setdefault(model, {}).setdefault(
model_id, set()).add(a_id)
allowed_ids = self._find_allowed_doc_ids(model_ids)
final_ids = allowed_ids
if count:
return len(final_ids)
else:
# re-construct a list based on ids, because set didn't keep order
id_list = [a_id for a_id in ids if a_id in final_ids]
return id_list

32
mail_activity_board/models/mail_activity_mixin.py

@ -0,0 +1,32 @@
# Copyright 2018 David Juaneda - <djuaneda@sdi.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class MailActivityMixin(models.AbstractModel):
_inherit = 'mail.activity.mixin'
def redirect_to_activities(self, **kwargs):
"""Redirects to the list of activities of the object shown.
Redirects to the activity board and configures the domain so that
only those activities that are related to the object shown are
displayed.
Add to the title of the view the name the class of the object from
which the activities will be displayed.
:param kwargs: contains the id of the object and the model it's about.
:return: action.
"""
_id = kwargs.get("id")
action = self.env['mail.activity'].action_activities_board()
views = []
for v in action['views']:
if v[1] == 'tree':
v = (v[0], 'list')
views.append(v)
action['views'] = views
action['domain'] = [('res_id', '=', _id)]
return action

7
mail_activity_board/readme/CONTRIBUTORS.rst

@ -0,0 +1,7 @@
* `SDI <https://www.sdi.es>`_:
* David Juaneda
* `Eficent <https://www.eficent.com>`_:
* Miquel Raïch (miquel.raich@eficent.com)

2
mail_activity_board/readme/DESCRIPTION.rst

@ -0,0 +1,2 @@
This module adds an activity board with form, tree, kanban, calendar, pivot, graph and search views.

9
mail_activity_board/readme/USAGE.rst

@ -0,0 +1,9 @@
To use this module, you need to:
#. Access to the views from menu Boards.
A smartButton of activities is added in the mail thread from form view.
From this smartButton is linked to the activity board, to the view tree,
which shows the activities related to the opportunity.
From the form view of the activity you can navigate to the origin of the activity.

BIN
mail_activity_board/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

435
mail_activity_board/static/description/index.html

@ -0,0 +1,435 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Activities board</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="activities-board">
<h1 class="title">Activities board</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mail_activity_board"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-12-0/social-12-0-mail_activity_board"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds an activity board with form, tree, kanban, calendar, pivot, graph and search views.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<p>To use this module, you need to:</p>
<ol class="arabic simple">
<li>Access to the views from menu Boards.</li>
</ol>
<p>A smartButton of activities is added in the mail thread from form view.
From this smartButton is linked to the activity board, to the view tree,
which shows the activities related to the opportunity.</p>
<p>From the form view of the activity you can navigate to the origin of the activity.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_activity_board%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<ul class="simple">
<li>SDi</li>
<li>David Juaneda</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.sdi.es">SDI</a>:<ul>
<li>David Juaneda</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mail_activity_board">OCA/social</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

33
mail_activity_board/static/src/js/override_chatter.js

@ -0,0 +1,33 @@
/* Copyright 2018 David Juaneda
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
odoo.define('mail.Chatter.activity', function (require) {
"use strict";
var chatter = require('mail.Chatter');
chatter.include({
events: _.extend({}, chatter.prototype.events, {
'click .o_chatter_button_list_activity': '_onListActivity',
}),
/**
* Performs the action to redirect to the activities of the object.
*
* @private
*/
_onListActivity: function () {
this._rpc({
model: this.record.model,
method: 'redirect_to_activities',
args: [[]],
kwargs: {
'id':this.record.res_id,
'model':this.record.model,
},
context: this.record.getContext(),
}).then($.proxy(this, "do_action"));
},
});
});

13
mail_activity_board/static/src/xml/inherit_chatter.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-extend="mail.Chatter.Buttons">
<t t-jquery="button.o_chatter_button_schedule_activity" t-operation="after">
<button t-if="schedule_activity_btn" class="btn btn-sm btn-link o_chatter_button_list_activity"
title="See activities list" type="button">
<i class="fa fa-list"/> Activities
</button>
</t>
</t>
</templates>

1
mail_activity_board/tests/__init__.py

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

172
mail_activity_board/tests/test_mail_activity_board.py

@ -0,0 +1,172 @@
# Copyright 2018 David Juaneda - <djuaneda@sdi.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
class TestMailActivityBoardMethods(TransactionCase):
def setUp(self):
super(TestMailActivityBoardMethods, self).setUp()
# Set up activities
# Create a user as 'Crm Salesman' and added few groups
self.employee = self.env['res.users'].create({
'company_id': self.env.ref("base.main_company").id,
'name': "Employee",
'login': "csu",
'email': "crmuser@yourcompany.com",
'groups_id': [(6, 0, [self.env.ref('base.group_user').id])]
})
# Create a user who doesn't have access to anything except activities
mail_activity_group = self.create_mail_activity_group()
self.employee2 = self.env['res.users'].create({
'company_id': self.env.ref("base.main_company").id,
'name': "Employee2",
'login': "alien",
'email': "alien@yourcompany.com",
'groups_id': [(6, 0, [mail_activity_group.id])],
})
# lead_model_id = self.env['ir.model']._get('crm.lead').id
partner_model_id = self.env['ir.model']._get('res.partner').id
ActivityType = self.env['mail.activity.type']
self.activity1 = ActivityType.create({
'name': 'Initial Contact',
'days': 5,
'summary': 'ACT 1 : Presentation, barbecue, ... ',
'res_model_id': partner_model_id,
})
self.activity2 = ActivityType.create({
'name': 'Call for Demo',
'days': 6,
'summary': 'ACT 2 : I want to show you my ERP !',
'res_model_id': partner_model_id,
})
self.activity3 = ActivityType.create({
'name': 'Celebrate the sale',
'days': 3,
'summary': 'ACT 3 : '
'Beers for everyone because I am a good salesman !',
'res_model_id': partner_model_id,
})
# I create an opportunity, as employee
self.partner_client = self.env.ref("base.res_partner_1")
# assure there isn't any mail activity yet
self.env['mail.activity'].sudo().search([]).unlink()
self.act1 = self.env['mail.activity'].sudo().create({
'activity_type_id': self.activity3.id,
'note': 'Partner activity 1.',
'res_id': self.partner_client.id,
'res_model_id': partner_model_id,
'user_id': self.employee.id
})
self.act2 = self.env['mail.activity'].sudo().create({
'activity_type_id': self.activity2.id,
'note': 'Partner activity 2.',
'res_id': self.partner_client.id,
'res_model_id': partner_model_id,
'user_id': self.employee.id
})
self.act3 = self.env['mail.activity'].sudo().create({
'activity_type_id': self.activity3.id,
'note': 'Partner activity 3.',
'res_id': self.partner_client.id,
'res_model_id': partner_model_id,
'user_id': self.employee.id
})
def create_mail_activity_group(self):
manager_mail_activity_test_group = self.env['res.groups'].create({
'name': 'group_manager_mail_activity_test',
})
mail_activity_model_id = self.env['ir.model'].sudo().search(
[('model', '=', 'mail.activity')], limit=1)
access = self.env['ir.model.access'].create({
'name': 'full_access_mail_activity',
'model_id': mail_activity_model_id.id,
'perm_read': True,
'perm_write': True,
'perm_create': True,
'perm_unlink': True,
})
access.group_id = manager_mail_activity_test_group
return manager_mail_activity_test_group
def get_view(self, activity):
action = activity.open_origin()
result = self.env[action.get('res_model')]\
.load_views(action.get('views'))
return result.get('fields_views').get(action.get('view_mode'))
def test_open_origin_res_partner(self):
""" This test case checks
- If the method redirects to the form view of the correct one
of an object of the 'res.partner' class to which the activity
belongs.
"""
# Id of the form view for the class 'crm.lead', type 'lead'
form_view_partner_id = self.env.ref('base.view_partner_form').id
# Id of the form view return open_origin()
view = self.get_view(self.act1)
# Check the next view is correct
self.assertEqual(form_view_partner_id, view.get('view_id'))
# Id of the form view return open_origin()
view = self.get_view(self.act2)
# Check the next view is correct
self.assertEqual(form_view_partner_id, view.get('view_id'))
# Id of the form view return open_origin()
view = self.get_view(self.act3)
# Check the next view is correct
self.assertEqual(form_view_partner_id, view.get('view_id'))
def test_redirect_to_activities(self):
""" This test case checks
- if the method returns the correct action,
- if the correct activities are shown.
"""
action_id = self.env.ref(
'mail_activity_board.open_boards_activities').id
action = self.partner_client\
.redirect_to_activities(**{'id': self.partner_client.id})
self.assertEqual(action.get('id'), action_id)
kwargs = {
'groupby': [
"activity_type_id"
],
}
kwargs['domain'] = action.get('domain')
result = self.env[action.get('res_model')]\
.load_views(action.get('views'))
fields = result.get('fields_views').get('kanban').get('fields')
kwargs['fields'] = list(fields.keys())
result = self.env['mail.activity'].read_group(**kwargs)
acts = []
for group in result:
records = self.env['mail.activity'].search_read(
domain=group.get('__domain'), fields=kwargs['fields']
)
acts += [record_id.get('id') for record_id in records]
for act in acts:
self.assertIn(act, self.partner_client.activity_ids.ids)
def test_read_permissions(self):
search1 = self.env['mail.activity'].sudo(self.employee).search([])
self.assertEqual(len(search1), 3)
search2 = self.env['mail.activity'].sudo(self.employee2).search([])
self.assertEqual(len(search2), 0)

210
mail_activity_board/views/mail_activity_view.xml

@ -0,0 +1,210 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!--
VIEWS
-->
<!-- FORM VIEW -->
<record id="mail_activity_view_form_board" model="ir.ui.view">
<field name="name">mail.activity.boards.view.form</field>
<field name="model">mail.activity</field>
<field name="priority">30</field>
<field name="arch" type="xml">
<form string="Activity Form" create="false" edit="false" delete="false">
<sheet string="Activity">
<button name="open_origin" type="object" class="centre oe_link" nolabel="1">
<h1><field name="res_name"/></h1>
</button>
<field name="activity_category" invisible="1" />
<field name="res_model" invisible="1"/>
<field name="res_model_id" invisible="1"/>
<field name="res_id" invisible="1"/>
<group>
<group>
<field name="activity_type_id" required="1" options="{'no_create': True, 'no_open': True}"/>
<field name="res_model_id_name"/>
<field name="calendar_event_id" invisible="1"/>
<field name="create_date" invisible="1"/>
</group>
<group>
<field name="date_deadline"
attrs="{'invisible': [('activity_category', '=', 'meeting')]}"/>
<field name="calendar_event_id_start" string="Start meeting"
attrs="{'invisible': [('calendar_event_id','=', False)]}"/>
<field name="duration" widget="float_time"
attrs="{'invisible': ['|',('duration', '=', False),
('calendar_event_id','=', False)]}"/>
<field name="user_id" options="{'no_open': True}"/>
</group>
</group>
<group attrs="{'invisible': ['|',('calendar_event_id','=', False),('calendar_event_id_partner_ids','=', False)]}">
<field name="calendar_event_id_partner_ids" mode="kanban"/>
</group>
<group>
<field name="summary" placeholder="e.g. Discuss proposal"/>
<field name="note" placeholder="Log a note..."/>
</group>
</sheet>
</form>
</field>
</record>
<!-- TREE VIEW -->
<record id="mail_activity_view_tree" model="ir.ui.view">
<field name="name">mail.activity.boards.view.tree</field>
<field name="model">mail.activity</field>
<field name="inherit_id" ref="mail.mail_activity_view_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="default_order"/>
<attribute name="decoration-danger">(date_deadline &lt; current_date)</attribute>
<attribute name="decoration-warning">(date_deadline == current_date)</attribute>
<attribute name="decoration-success">(date_deadline &gt; current_date)</attribute>
</xpath>
</field>
</record>
<!-- KANBAN VIEW -->
<record id="mail_activity_view_kanban" model="ir.ui.view">
<field name="name">mail.activity.boards.view.kanban</field>
<field name="model">mail.activity</field>
<field name="priority" eval="10"/>
<field name="arch" type="xml">
<kanban default_group_by="activity_type_id" class="_kanban_small_column o_opportunity_kanban" create="0" _order="date_deadline"
group_create="false" group_delete="false" group_edit="false">
<field name="user_id"/>
<field name="res_id"/>
<field name="res_name"/>
<field name="res_model"/>
<field name="summary"/>
<field name="date_deadline"/>
<field name="state"/>
<field name="icon"/>
<field name="activity_type_id"/>
<field name="activity_category"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_content oe_kanban_global_click">
<div class="oe_kanban_content">
<div>
<strong class="o_kanban_record_subtitle">
<span t-attf-class="fa #{record.icon.raw_value}" />
<field name="summary"/>
</strong>
</div>
<div>
<strong class="o_kanban_record_title"><field name="res_name"/></strong>
</div>
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left">
<t t-set="act_date" t-value="new Date(record.date_deadline.raw_value)"/>
<t t-if="act_date &lt; (new Date())">
<span t-attf-class="text-danger"><i class="fa fa-clock-o"/></span>
<t t-if="record.activity_category.raw_value!='meeting'">
<span t-attf-class="text-danger">
<field name="date_deadline" t-options='{"widget": "date"}'/>
</span>
</t>
<t t-else="">
<span t-attf-class="text-danger">
<field name="calendar_event_id_start" t-options='{"widget": "date"}'/>
</span>
</t>
</t>
<t t-else="">
<span><i class="fa fa-clock-o"/></span>
<t t-if="record.activity_category.raw_value!='meeting'">
<span>
<field name="date_deadline" t-options='{"widget": "date"}'/>
</span>
</t>
<t t-else="">
<field name="calendar_event_id_start" t-options='{"widget": "date"}'/>
</t>
</t>
</div>
<div class="oe_kanban_bottom_right">
<img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)"
t-att-title="record.user_id.value"
t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar"/>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!-- SEARCH VIEW -->
<record id="mail_activity_view_search" model="ir.ui.view">
<field name="name">mail.activity.boards.view.search</field>
<field name="model">mail.activity</field>
<field name="inherit_id" ref="mail.mail_activity_view_search"/>
<field name="priority" eval="2"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr='//field[@name="res_model_id"]' position='before'>
<field name="user_id"/>
<field name="res_name" string="Origin"/>
</xpath>
<xpath expr='//filter[@name="activities_my"]' position='after'>
<filter string="Act. next month" name="activities_month"
domain="[('date_deadline', '&lt;', (context_today()+datetime.timedelta(days=30)).strftime('%Y-%m-%d'))]"
help="Show activities scheduled for next month."/>
<filter string="Act. next 6 months" name="activities_6_month"
domain="[('date_deadline', '&lt;', (context_today()+datetime.timedelta(days=180)).strftime('%Y-%m-%d'))]"
help="Show activities scheduled for next 6 months."/>
<separator/>
</xpath>
<xpath expr='//search/group' position='inside'>
<filter string="User" name='assigned_user' context="{'group_by':'user_id'}"/>
<filter string="Origin" name='origin' context="{'group_by': 'res_model_id'}"/>
</xpath>
</field>
</record>
<!--
ACTION
-->
<record model="ir.actions.act_window" id="open_boards_activities">
<field name="name">Activities</field>
<field name="res_model">mail.activity</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,form</field>
<field name="domain">[]</field>
<field name="context">{}</field>
<field name="view_ids"
eval="[(5, 0, 0),
(0, 0, {'view_mode': 'kanban', 'view_id': ref('mail_activity_view_kanban')}),
(0, 0, {'view_mode': 'tree', 'view_id': ref('mail_activity_view_tree')}),
(0, 0, {'view_mode': 'form', 'view_id': ref('mail_activity_view_form_board')}),
(0, 0, {'view_mode': 'calendar'}),
(0, 0, {'view_mode': 'pivot'}),
(0, 0, {'view_mode': 'graph'})]"/>
<field name="search_view_id" ref="mail_activity_view_search"/>
</record>
<!--
Menus
-->
<menuitem
id="board_menu_activities"
name="Activities"
parent="base.menu_board_root"
action="open_boards_activities"
sequence="1"/>
</odoo>

8
mail_activity_board/views/templates.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="mail_activity_board assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/mail_activity_board/static/src/js/override_chatter.js"/>
</xpath>
</template>
</odoo>

2
mail_activity_done/__manifest__.py

@ -2,7 +2,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Mail Activity Done",
"version": "12.0.1.0.0",
"version": "12.0.1.1.0",
"author": "Eficent,"
"Odoo Community Association (OCA)",
"license": "LGPL-3",

2
mail_activity_done/models/mail_activity.py

@ -14,7 +14,7 @@ class MailActivity(models.Model):
'Completed Date', index=True, readonly=True,
)
@api.depends('done')
@api.depends('date_deadline', 'done')
def _compute_state(self):
super(MailActivity, self)._compute_state()
for record in self.filtered(lambda activity: activity.done):

2
mail_activity_done/models/res_users.py

@ -7,7 +7,7 @@ class ResUsers(models.Model):
_inherit = 'res.users'
@api.model
def activity_user_count(self):
def systray_get_activities(self):
# Here we totally override the method. Not very nice, but
# we should perhaps ask Odoo to add a hook here.
query = """SELECT m.id, count(*), act.res_model as model,

4
mail_activity_done/tests/test_mail_activity_done.py

@ -29,7 +29,7 @@ class TestMailActivityDoneMethods(TransactionCase):
self.act1.done = True
self.assertEquals(self.act1.state, 'done')
def test_activity_user_count(self):
act_count = self.employee.sudo(self.employee).activity_user_count()
def test_systray_get_activities(self):
act_count = self.employee.sudo(self.employee).systray_get_activities()
self.assertEqual(len(act_count), 1,
"Number of activities should be equal to one")

2
mail_activity_done/views/mail_activity_views.xml

@ -39,7 +39,7 @@
<attribute name="domain">[('date_deadline', '=', context_today().strftime('%Y-%m-%d')), ('done', '!=', True)]</attribute>
</filter>
<filter name="activities_upcoming_all" position="attributes">
<attribute name="domain">[('activity_ids.date_deadline', '&gt;', context_today().strftime('%Y-%m-%d')), ('done', '!=', True)]</attribute>
<attribute name="domain">[('date_deadline', '&gt;', context_today().strftime('%Y-%m-%d')), ('done', '!=', True)]</attribute>
</filter>
</field>
</record>

Loading…
Cancel
Save