- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 638
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
[17.0][MIG] mail_activity_validation: Migration to 17.0 #1336
Closed
+612
−0
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2022 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Mail Activity Validation", | ||
"version": "12.0.1.0.0", | ||
"category": "Discuss", | ||
"website": "https://github.com/OCA/social", | ||
"author": "Camptocamp SA, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"application": False, | ||
"summary": "Allow to define validation activities", | ||
"depends": [ | ||
"mail", | ||
], | ||
"data": [ | ||
"views/mail_activity_type.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import mail_activity | ||
from . import mail_activity_mixin | ||
from . import mail_activity_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2022 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import _, models | ||
from odoo.exceptions import AccessError | ||
|
||
|
||
class MailActivity(models.Model): | ||
_inherit = "mail.activity" | ||
|
||
def action_done_schedule_next(self): | ||
group_intersect = False | ||
if set(self.env.user.groups_id) | set( | ||
self.activity_type_id.validator_group_ids | ||
): | ||
group_intersect = True | ||
if ( | ||
self.activity_type_id.category != "validation" | ||
or not self.activity_type_id.validator_group_ids | ||
or group_intersect | ||
): | ||
return super().action_done_schedule_next() | ||
|
||
raise AccessError( | ||
_( | ||
"Only validators in groups {} are " | ||
"allowed to validate this activity." | ||
).format( | ||
"\n".join( | ||
g.display_name for g in self.activity_type_id.validator_group_ids | ||
) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2022 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import models | ||
|
||
|
||
class MailActivityMixin(models.AbstractModel): | ||
_inherit = "mail.activity.mixin" | ||
|
||
def check_validation_activities_todo(self): | ||
for rec in self: | ||
remaining_activities = rec.activity_ids.filtered( | ||
lambda a: a.activity_category == "validation" | ||
) | ||
|
||
if remaining_activities: | ||
return False | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2022 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class MailActivityType(models.Model): | ||
_inherit = "mail.activity.type" | ||
|
||
category = fields.Selection(selection_add=[("validation", "Validation")]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an ondelete property |
||
validator_group_ids = fields.Many2many( | ||
"res.groups", | ||
"mail_activity_groups_rel", | ||
"activity_id", | ||
"group_id", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Damien Crier <damien.crier@camptocamp.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This module allows to define activities as "validation" ones. | ||
|
||
This module do nothing if installed as this. You need another module that do something with the "validation" activities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
Copyright 2022 Camptocamp SA (https://www.camptocamp.com) | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
--> | ||
<odoo> | ||
|
||
<record id="mail_activity_type_view_form" model="ir.ui.view"> | ||
<field name="model">mail.activity.type</field> | ||
<field name="inherit_id" ref="mail.mail_activity_type_view_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//sheet" position="inside"> | ||
<div | ||
name="activities_validators" | ||
attrs="{'invisible': [('category', '!=', 'validation')]}" | ||
> | ||
<label for="validator_group_ids" /> | ||
<field name="validator_group_ids" nolabel="1" /> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
1 change: 1 addition & 0 deletions
1
setup/mail_activity_validation/odoo/addons/mail_activity_validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../mail_activity_validation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.