Browse Source

[MIG] privacy_consent: version 13.0

- Remove prefetching optimizations; v13 ORM does it better.
- Reset counters always in computed methods.
- Remove workaround for skipping duplicate consent creation message.
- Implement the new `_creation_subtype()` to let creation subscriptions keep on working.

@Tecnativa TT25941
pull/56/head
Jairo Llopis 3 years ago
committed by Valtteri Lattu
parent
commit
8449b8e564
  1. 10
      privacy_consent/README.rst
  2. 2
      privacy_consent/controllers/main.py
  3. 10
      privacy_consent/models/mail_mail.py
  4. 3
      privacy_consent/models/privacy_activity.py
  5. 14
      privacy_consent/models/privacy_consent.py
  6. 7
      privacy_consent/models/res_partner.py
  7. 8
      privacy_consent/static/description/index.html
  8. 19
      privacy_consent/views/privacy_consent.xml

10
privacy_consent/README.rst

@ -14,13 +14,13 @@ Privacy - Consent
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdata--protection-lightgray.png?logo=github
:target: https://github.com/OCA/data-protection/tree/12.0/privacy_consent
:target: https://github.com/OCA/data-protection/tree/13.0/privacy_consent
:alt: OCA/data-protection
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/data-protection-12-0/data-protection-12-0-privacy_consent
:target: https://translation.odoo-community.org/projects/data-protection-13-0/data-protection-13-0-privacy_consent
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/263/12.0
:target: https://runbot.odoo-community.org/runbot/263/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -136,7 +136,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/data-protection/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/data-protection/issues/new?body=module:%20privacy_consent%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/data-protection/issues/new?body=module:%20privacy_consent%0Aversion:%2013.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.
@ -173,6 +173,6 @@ 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/data-protection <https://github.com/OCA/data-protection/tree/12.0/privacy_consent>`_ project on GitHub.
This module is part of the `OCA/data-protection <https://github.com/OCA/data-protection/tree/13.0/privacy_consent>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

2
privacy_consent/controllers/main.py

@ -12,7 +12,7 @@ from odoo.addons.web.controllers.main import ensure_db
class ConsentController(Controller):
@route(
"/privacy/consent/<any(accept,reject):choice>/" "<int:consent_id>/<token>",
"/privacy/consent/<any(accept,reject):choice>/<int:consent_id>/<token>",
type="http",
auth="none",
website=True,

10
privacy_consent/models/mail_mail.py

@ -20,9 +20,7 @@ class MailMail(models.Model):
and not failure_type
):
# Get related consent
consent = self.env["privacy.consent"].browse(
self.mail_message_id.res_id, self._prefetch,
)
consent = self.env["privacy.consent"].browse(self.mail_message_id.res_id)
# Set as sent if needed
if consent.state == "draft" and consent.partner_id.id in {
par.id for par in success_pids
@ -48,11 +46,7 @@ class MailMail(models.Model):
if self.model != "privacy.consent":
return result
# Tokenize consent links
consent = (
self.env["privacy.consent"]
.browse(self.mail_message_id.res_id)
.with_prefetch(self._prefetch)
)
consent = self.env["privacy.consent"].browse(self.mail_message_id.res_id)
result = result.replace("/privacy/consent/accept/", consent._url(True),)
result = result.replace("/privacy/consent/reject/", consent._url(False),)
return result

3
privacy_consent/models/privacy_activity.py

@ -53,11 +53,12 @@ class PrivacyActivity(models.Model):
@api.depends("consent_ids")
def _compute_consent_count(self):
self.consent_count = 0
groups = self.env["privacy.consent"].read_group(
[("activity_id", "in", self.ids)], ["activity_id"], ["activity_id"],
)
for group in groups:
self.browse(group["activity_id"][0], self._prefetch).consent_count = group[
self.browse(group["activity_id"][0]).consent_count = group[
"activity_id_count"
]

14
privacy_consent/models/privacy_consent.py

@ -59,14 +59,15 @@ class PrivacyConsent(models.Model):
track_visibility="onchange",
)
def _creation_subtype(self):
return self.env.ref("privacy_consent.mt_consent_consent_new")
def _track_subtype(self, init_values):
"""Return specific subtypes."""
if self.env.context.get("subject_answering"):
return "privacy_consent.mt_consent_acceptance_changed"
if "activity_id" in init_values or "partner_id" in init_values:
return "privacy_consent.mt_consent_consent_new"
return self.env.ref("privacy_consent.mt_consent_acceptance_changed")
if "state" in init_values:
return "privacy_consent.mt_consent_state_changed"
return self.env.ref("privacy_consent.mt_consent_state_changed")
return super(PrivacyConsent, self)._track_subtype(init_values)
def _token(self):
@ -115,10 +116,9 @@ class PrivacyConsent(models.Model):
@api.model_create_multi
def create(self, vals_list):
"""Run server action on create."""
super_ = super(PrivacyConsent, self.with_context(mail_create_nolog=True))
results = super_.create(vals_list)
results = super().create(vals_list)
# Sync the default acceptance status
results.sudo()._run_action()
results._run_action()
return results
def write(self, vals):

7
privacy_consent/models/res_partner.py

@ -19,10 +19,11 @@ class ResPartner(models.Model):
@api.depends("privacy_consent_ids")
def _compute_privacy_consent_count(self):
"""Count consent requests."""
self.privacy_consent_count = 0
groups = self.env["privacy.consent"].read_group(
[("partner_id", "in", self.ids)], ["partner_id"], ["partner_id"],
)
for group in groups:
self.browse(
group["partner_id"][0], self._prefetch
).privacy_consent_count = group["partner_id_count"]
self.browse(group["partner_id"][0]).privacy_consent_count = group[
"partner_id_count"
]

8
privacy_consent/static/description/index.html

@ -3,7 +3,7 @@
<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.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Privacy - Consent</title>
<style type="text/css">
@ -367,7 +367,7 @@ ul.auto-toc {
!! 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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/data-protection/tree/12.0/privacy_consent"><img alt="OCA/data-protection" src="https://img.shields.io/badge/github-OCA%2Fdata--protection-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/data-protection-12-0/data-protection-12-0-privacy_consent"><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/263/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/data-protection/tree/13.0/privacy_consent"><img alt="OCA/data-protection" src="https://img.shields.io/badge/github-OCA%2Fdata--protection-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/data-protection-13-0/data-protection-13-0-privacy_consent"><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/263/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows the user to define a set of subjects (partners)
affected by any data processing activity, and establish
a process to ask them for consent to include them in that activity.</p>
@ -484,7 +484,7 @@ and the request state.</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/data-protection/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/data-protection/issues/new?body=module:%20privacy_consent%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/data-protection/issues/new?body=module:%20privacy_consent%0Aversion:%2013.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">
@ -516,7 +516,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<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/data-protection/tree/12.0/privacy_consent">OCA/data-protection</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/data-protection/tree/13.0/privacy_consent">OCA/data-protection</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>

19
privacy_consent/views/privacy_consent.xml

@ -18,18 +18,13 @@
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button
class="oe_stat_button"
icon="fa-archive"
name="toggle_active"
type="object"
>
<field
name="active"
options='{"terminology": "archive"}'
widget="boolean_button"
/>
</button>
<field name="active" invisible="1" />
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
</div>
<group>
<field name="partner_id" />

Loading…
Cancel
Save