Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.0][mail_activity_board] Add new module that insert activities board in boards. #283

Merged
merged 23 commits into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d56c2f0
[ADD] Module that insert activities board.
Jun 12, 2018
4b929c4
[FIX] Author error in __manifest__ file and style changes.
Jun 13, 2018
7ed0a4c
[FIX] Fix replace in view, rename files and style changes.
Jun 13, 2018
919f33e
[FIX] Enumerated list ends without a blank line; unexpected unindent.
Jun 14, 2018
cc486cb
[FIX] Name fail.
Jun 14, 2018
4caf09e
[FIX] Bug in view.
Jun 14, 2018
ad7b784
[FIX] Add button Activities in mail.thread and readme folder. Others…
Jul 8, 2018
f870bad
[FIX] Type 'tree' not found in registry: problem solved.
Jul 9, 2018
ce43235
[FIX] Dependence change: 'mail' for 'calendar'.
Jul 9, 2018
82dd15e
[FIX] Eliminated unnecessary imports.
Jul 9, 2018
470b3dc
[FIX] Bugs about js and if/else.
Jul 13, 2018
4456f9e
[FIX] Improvements following guide lines and eliminating unnecessary …
Jul 16, 2018
e93ca79
[ADD] Added counter in the 'Activities List' button.
Jul 16, 2018
676a3ed
[FIX] Bugs in javascript with 'Activities' button.
Jul 17, 2018
0146f61
[ADD] Tests folder.
dajuayen Sep 8, 2018
926cc1f
[FIX] Deleted references to modules not installed.
dajuayen Sep 9, 2018
d642084
[FIX] Formatting javascript.
dajuayen Sep 9, 2018
21b8b8a
[FIX] Bug: added a soft line before a class.
dajuayen Sep 9, 2018
28c6295
[FIX] Bug: https://github.com/OCA/social/pull/283#discussion_r204302325
dajuayen Sep 9, 2018
0bdcc94
[FIX] Escaping 'lt' in xml file. Bug: https://github.com/OCA/social/p…
dajuayen Sep 10, 2018
bbb99e7
[FIX] The meeting attendees are shown in kanban mode on the meeting b…
dajuayen Sep 16, 2018
3ddadf7
[FIX] Hide in form view of the activity board the assistant field if …
dajuayen Sep 16, 2018
97297af
[FIX] Change to default kanban view for partners.
dajuayen Sep 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 16 additions & 67 deletions mail_activity_board/README.rst
Original file line number Diff line number Diff line change
@@ -1,72 +1,21 @@
**This file is going to be generated by oca-gen-addon-readme.**

*Manual changes will be overwritten.*

Please provide content in the ``readme`` directory:

* **DESCRIPTION.rst** (required)
* INSTALL.rst (optional)
* CONFIGURE.rst (optional)
* **USAGE.rst** (optional, highly recommended)
* DEVELOP.rst (optional)
* ROADMAP.rst (optional)
* HISTORY.rst (optional, recommended)
* **CONTRIBUTORS.rst** (optional, highly recommended)
* CREDITS.rst (optional)

Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.

.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3



================
Activities Board
================

This module adds an activity board with form, tree, kanban, calendar, pivot, graph and search views.


Configuration
=============


Install it from APPs.


Usage
=====

Access to the views from menu Boards.

A smartButton of activities is added in the opportunity 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.


Credits
=======


Contributors
------------

* SDI <http://www.sdi.es>

* David Juaneda Ayensa <djuaneda@sdi.es>
* Javier Garcia <jgarcia@sdi.es>


Maintainer
----------

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

This module is maintained by the OCA.

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.

To contribute to this module, please visit http://odoo-community.org.
A good, one sentence summary in the manifest is also highly recommended.
4 changes: 0 additions & 4 deletions mail_activity_board/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# SDI
# author: djuaneda@sdi.es

from . import models
30 changes: 15 additions & 15 deletions mail_activity_board/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Copyright 2018 SDi - David Juaneda
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
# Copyright 2016 David Juaneda - <djuaneda@sdi.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Activities board',
'version': '11.0.1.0.1',
'category': 'Social Network',
'author': 'David Juaneda, '
'Javier Garcia, '
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/social',
'summary': 'Add Activity Boards',
'license': 'GPL-3',
'version': '11.0.1.0.0',
'development_status': 'Beta',
'category': 'Uncategorized',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Social Network was a good category IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it.

'website': 'https://github.com/OCA/social',
'author': 'SDi, David Juaneda, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'application': False,
'installable': True,
'depends': [
'crm',
'mail',
'calendar',
'board',
],
'data': [
'views/templates.xml',
'views/mail_activity_view.xml',
'views/crm_lead_opportunity_view.xml',
],
'qweb': [],
'demo': [],
'installable': True,
'qweb': [
'static/src/xml/inherit_chatter.xml',
]
}
6 changes: 1 addition & 5 deletions mail_activity_board/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# SDI
# author: djuaneda@sdi.es

from . import crm_lead
from . import mail_activity
from . import mail_activity_mixin
36 changes: 0 additions & 36 deletions mail_activity_board/models/crm_lead.py

This file was deleted.

26 changes: 10 additions & 16 deletions mail_activity_board/models/mail_activity.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
# Copyright 2016 David Juaneda - <djuaneda@sdi.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# SDI
# author: djuaneda@sdi.es
from odoo import api, models, fields
from odoo.tools.safe_eval import safe_eval


class MailActivity(models.Model):
_inherit = "mail.activity"

res_model_id_name = fields.Char(
default="", related='res_model_id.name',
string="Origin", store=False, readonly=True)
related='res_model_id.name', string="Origin",
store=False, default="", readonly=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store=False is the default, you can remove it.

Also, default="" can lead to confusing behavior, because in Odoo, the standard is that empty fields return False always. Having "" instead of False is unconsistent, so please remove that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted store=False.
Deleted default="".

duration = fields.Float(
related='calendar_event_id.duration',
string="Duration", store=False, readonly=True)
calendar_event_id_start = fields.Datetime(
default=False, related='calendar_event_id.start',
related='calendar_event_id.duration', string="Duration",
store=False, readonly=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely, with related='calendar_event_id.duration', readonly=True it should be the same, because all other attributes are inherited from the related field itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to leave the field with only "related" and "readonly" attributes and it has behaved as you have indicated, so I have changed it.

calendar_event_id_start = fields.Datetime(
related='calendar_event_id.start', string="Start",
store=False, default=False, readonly=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too.

calendar_event_id_partner_ids = fields.Many2many(
related='calendar_event_id.partner_ids', string='Attendees',
store=False, default=False, readonly=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too.


@api.multi
def open_origin(self):
"""
Utility method used to add an "Open Company" button in partner views.
"""
""" """
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!!!

self.ensure_one()
response = {'type': 'ir.actions.act_window',
'res_model': self.res_model,
Expand All @@ -41,9 +37,7 @@ def open_origin(self):
return response

@api.model
def action_your_activities(self):
def action_activities_board(self):
action = self.env.ref(
'mail_activity_board.open_boards_activities_form_tree').read()[0]
action_context = safe_eval(action['context'], {'uid': self.env.uid})
action['context'] = action_context
'mail_activity_board.open_boards_activities').read()[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just do self.env.ref(...).id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do not return the same.
self.env.ref ('...'). read () [0] returns a dictionary with all the data of the action.
self.env.ref ('...'). id only returns the id (int) of the action.

I can not change it

return action
33 changes: 33 additions & 0 deletions mail_activity_board/models/mail_activity_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2016 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this line along with the """

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected it.


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: Dictionary that contains the id of the object
and the model it is about.
:return: action.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce 4 spaces of indentation in all this docstring.

FTR https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the link.

"""
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
3 changes: 3 additions & 0 deletions mail_activity_board/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `SDI <https://www.sdi.es>`_:

* David Juaneda
2 changes: 2 additions & 0 deletions mail_activity_board/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module adds an activity board with form, tree, kanban, calendar, pivot, graph and search views.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

11 changes: 11 additions & 0 deletions mail_activity_board/readme/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
11.0.0.0.0 (2018-06-12)
~~~~~~~~~~~~~~~~~~~~~~~

* [BREAKING] Breaking changes come first.
(`#70 <https://github.com/OCA/repo/issues/70>`_)
* [ADD] New feature.
(`#74 <https://github.com/OCA/repo/issues/74>`_)
* [FIX] Correct this.
(`#71 <https://github.com/OCA/repo/issues/71>`_)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I delete this file.



9 changes: 9 additions & 0 deletions mail_activity_board/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -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.
34 changes: 34 additions & 0 deletions mail_activity_board/static/src/js/override_chatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* 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: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope you're not overriding parent events. To protect against that, you should do:

events: _.extend({}, chatter.prototype.events, {
    // your events here...
}),

JS is funny 😋

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you know what little you've learned by hitting your head against the wall, ... it's very funny, it's not just.

'click .o_chatter_button_new_message': '_onOpenComposerMessage',
'click .o_chatter_button_log_note': '_onOpenComposerNote',
'click .o_chatter_button_schedule_activity': '_onScheduleActivity',
'click .o_chatter_button_count_activity': '_onCountActivity',
},

_onCountActivity: function (event) {
event.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed if you add type="button" to the button. Remove and see comments below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean only the line:

event.preventDefault();

var self = this;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this...

this._rpc({
model: self.record.model,
method: 'redirect_to_activities',
args: [[]],
kwargs: {'id':self.record.res_id,
'model':self.record.model},
context: this.record.getContext(),
}).then(function(action) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... if you do this here:

}).then($.proxy(this, "do_action"));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take note, although I do not know very well what it does

return self.do_action(action);
});
},

});
});
12 changes: 12 additions & 0 deletions mail_activity_board/static/src/xml/inherit_chatter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?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_count_activity" title=" activity">
<i class="fa fa-list"/> <t t-if="isMobile">Activities</t><t t-else="">Activities</t>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the if?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy & paste

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already removed it.

Copy link
Contributor Author

@dajuayen dajuayen Jul 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally I have left it:
<t t-if = "isMobile"> List </ t> Activities list </ t>

because it shows a different legend if 'isMobile' or not.

</button>
</t>
</t>

</templates>
27 changes: 0 additions & 27 deletions mail_activity_board/views/crm_lead_opportunity_view.xml

This file was deleted.

Loading