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][ADD][mail_activity_team] #330

Merged
merged 6 commits into from
Jan 8, 2019
Merged

Conversation

JordiBForgeFlow
Copy link
Sponsor Member

This module adds the possibility to assign teams to activities.

Usage

To set up new teams:

#. Go to Settings / Activate developer mode
#. Go to Settings / Technical / Email / Activity Teams
#. Create a new Team and assign (optionally) the models in which it will
be used, and the members of the team.

You can also assign a user to Activity teams going to
Settings / Users & Companies / Users, and in the Preferences tab, field
Activity Teams.

When you create a new activity the application will propose the user's
assigned team.

You can report on the activities assigned to a team going to
Dashboards / Activities, and then filter by a specific team or group by
teams.

@JordiBForgeFlow
Copy link
Sponsor Member Author

@mreficent Can you please add tests?

@JordiBForgeFlow
Copy link
Sponsor Member Author

@mreficent We also need a button in the team that counts how many mail activities meet the model and members of the team, but have no team assigned. The user should be able to click this button to start a wizard that should update, for these activities, the new team.

"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
access_mail_activity_team_all,mail.activity.team.all,model_mail_activity_team,,1,0,0,0
access_mail_activity_team_user,mail.activity.team.user,model_mail_activity_team,base.group_user,1,1,0,0
access_mail_activity_team_system_user,mail.activity.team.system.user,model_mail_activity_team,base.group_system_user,1,1,1,1
Copy link
Member

Choose a reason for hiding this comment

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

base.group_system_user does not exist use instead base.group_system

<record id="mail_activity_rule_my_team" model="ir.rule">
<field name="name">mail.activity: user: my team</field>
<field name="model_id" ref="mail.model_mail_activity"/>
<field name="domain_force">['|', '&amp;'('team_id', '=', False),('user_id', '=', user.id),('team_id', '=', user.team_ids.ids)]</field>
Copy link
Member

@HviorForgeFlow HviorForgeFlow Nov 27, 2018

Choose a reason for hiding this comment

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

Suggested change
<field name="domain_force">['|', '&amp;'('team_id', '=', False),('user_id', '=', user.id),('team_id', '=', user.team_ids.ids)]</field>
<field name="domain_force">["|", ('team_id', 'in', user.activity_team_ids.ids), "&amp;", ('team_id', '=', False), ('user_id', '=', user.id)]</field>

<field name="name"/>
</group>
<group name="models">
<field name="res_model_ids" widget="many2many_tags"/>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<field name="res_model_ids" widget="many2many_tags"/>
<field name="res_model_ids" widget="many2many_tags"
options="{'no_create': True, 'no_open': True}"/>


name = fields.Char(string='Name', required=True, translate=True)
active = fields.Boolean(string='Active', default=True)
res_model_ids = fields.Many2many('ir.model', string='Used models')
Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

@mreficent can you check how it would be possible to add a domain here that only shows the models that inherit the activity.mixin? Otherwise it is very confusing for the user to see all models here, most of which do not allow to add activities.

@MiquelRForgeFlow MiquelRForgeFlow force-pushed the 11.0-mail_activity_team branch 2 times, most recently from 6c3bbf1 to 92da1e7 Compare November 28, 2018 14:12
@MiquelRForgeFlow
Copy link
Contributor

The WIP label should be changed to needs review

@hbrunn hbrunn added this to the 11.0 milestone Nov 29, 2018
_inherit = "mail.activity"

def _get_default_team_id(self):
res_model = self.env.context.get('default_res_model', False)
Copy link
Member

Choose a reason for hiding this comment

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

does it matter if you get False or None here?

Copy link
Contributor

Choose a reason for hiding this comment

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

what do you mean?

Copy link
Member

Choose a reason for hiding this comment

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

dict.get returns None if the key doesn't exist and you didn't pass another default. So to rephrase: What's the , False) part good for?

if team.res_model_ids:
domain.append(('res_model_id', 'in', team.res_model_ids.ids))
team.count_missing_activities = len(
activity_model.search(domain)
Copy link
Member

Choose a reason for hiding this comment

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

pass count=True instead of using len on the results

default=0,
)

def action_missing_activities(self):
Copy link
Member

Choose a reason for hiding this comment

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

this function name sounds a bit misleading, shouldn't it be something like assign_team_to_unassigned_activities?

@MiquelRForgeFlow
Copy link
Contributor

@hbrunn changes done :)

Copy link
Contributor

@LoisRForgeFlow LoisRForgeFlow left a comment

Choose a reason for hiding this comment

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

Functional review:
When you first create an activity it does not show any team:
image

If you remove the user assigned to, they show all up. All teams should be selectable at the beggining (or at least the ones the user assigned is member of).

<field name="arch" type="xml">
<data>
<field name="signature" position="before">
<field name="activity_team_ids" widget="many2many_tags"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

The label is not displayed.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

If you test in local, you see that the label is displayed. Maybe it's not displayed due to another module of the repository

Copy link
Contributor

@MiquelRForgeFlow MiquelRForgeFlow Nov 30, 2018

Choose a reason for hiding this comment

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

It's due to mail_digest module

@MiquelRForgeFlow
Copy link
Contributor

(or at least the ones the user assigned is member of)

that's how it works now. but I will improve it

@LoisRForgeFlow
Copy link
Contributor

yes, after removing the user and selecting a team, the first time no team show up.

@MiquelRForgeFlow MiquelRForgeFlow force-pushed the 11.0-mail_activity_team branch 7 times, most recently from 7501f48 to 180ca02 Compare November 30, 2018 12:41
Copy link
Member

@etobella etobella left a comment

Choose a reason for hiding this comment

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

Interesting module!
However, I miss the filter My teams activities on the dashboard. This way, I know which activities are assigned to my team.
Also, If only one member of the team exists, you should assign it automatically.

@AdriaGForgeFlow AdriaGForgeFlow force-pushed the 11.0-mail_activity_team branch 3 times, most recently from ade4bef to cf57f33 Compare December 24, 2018 09:04
Copy link
Member

@HviorForgeFlow HviorForgeFlow left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@etobella etobella left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@JordiBForgeFlow
Copy link
Sponsor Member Author

@ageficent on runbot, when I go to a team and press 'Assign to missing activities' I am getting this error:

image

Copy link
Contributor

@LoisRForgeFlow LoisRForgeFlow left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@LoisRForgeFlow
Copy link
Contributor

merge? 🤔

@hbrunn hbrunn merged commit 29ef70f into OCA:11.0 Jan 8, 2019
@MiquelRForgeFlow MiquelRForgeFlow deleted the 11.0-mail_activity_team branch January 8, 2019 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants