diff --git a/privacy_consent/README.rst b/privacy_consent/README.rst index feb717a..1330e8f 100644 --- a/privacy_consent/README.rst +++ b/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 `_. 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 `_. +`feedback `_. 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 `_ project on GitHub. +This module is part of the `OCA/data-protection `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/privacy_consent/controllers/main.py b/privacy_consent/controllers/main.py index 60bd233..289dc43 100644 --- a/privacy_consent/controllers/main.py +++ b/privacy_consent/controllers/main.py @@ -12,7 +12,7 @@ from odoo.addons.web.controllers.main import ensure_db class ConsentController(Controller): @route( - "/privacy/consent//" "/", + "/privacy/consent///", type="http", auth="none", website=True, diff --git a/privacy_consent/models/mail_mail.py b/privacy_consent/models/mail_mail.py index 5a94f5d..e0b7e37 100644 --- a/privacy_consent/models/mail_mail.py +++ b/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 diff --git a/privacy_consent/models/privacy_activity.py b/privacy_consent/models/privacy_activity.py index cf01ebd..ebecf2c 100644 --- a/privacy_consent/models/privacy_activity.py +++ b/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" ] diff --git a/privacy_consent/models/privacy_consent.py b/privacy_consent/models/privacy_consent.py index 19e6688..e697628 100644 --- a/privacy_consent/models/privacy_consent.py +++ b/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): diff --git a/privacy_consent/models/res_partner.py b/privacy_consent/models/res_partner.py index 6961c92..d421928 100644 --- a/privacy_consent/models/res_partner.py +++ b/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" + ] diff --git a/privacy_consent/static/description/index.html b/privacy_consent/static/description/index.html index c7bbf95..85722cd 100644 --- a/privacy_consent/static/description/index.html +++ b/privacy_consent/static/description/index.html @@ -3,7 +3,7 @@ - + Privacy - Consent