You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

525 lines
16 KiB

6 years ago
6 years ago
6 years ago
privacy_consent: Separate automated emails send process Before https://github.com/OCA/data-protection/pull/29 there was a race condition where an email could be sent while the same transaction that created the `privacy.consent` record still wasn't committed, producing a 404 error if the user clicked on "Accept" or "Reject" before all mails were sent. To avoid that, a raw `cr.commit()` was issued, but this produced another situation where the user had to wait until the full email queue is cleared to get his page loaded. It wasn't an error, but a long queue meant several minutes waiting, and it's ulikely that an average human is so patient. So, here's the final fix (I hope!). The main problem was that I was looking in the wrong place to send the email. It turns out that the `self.post_message_with_template()` method is absolutely helpless in the case at hand, where these criteria must be met: * E-mail must be enqueued, no matter if there are less or more than 50 consents to send. * The template must be processed per record. * In an ideal world, a `cr.commit()` must be issued after each sent mail. The metod that was being used: * Didn't allow to use `auto_commit` mode. * Only allowed to render the template per record if called with `composition_mode="mass_mail"`. * Only allowed to enqueue emails if called with `composition_mode="mass_post"`. Obviously, I cannot set 2 different values for `composition_mode`, so a different strategy had to be used. I discovered that the `mail.template` model has a helpful method called `send_mail()` that, by default: * Renders the template per record * Enqueues the email * The email queue is cleared in `auto_commit=True` mode. So, from now on, problems are gone: * The user click, or the cron run, will just generate the missing `privacy.consent` records and enqueue mails for them. * The mail queue manager will send them later, in `auto_commit` mode. * After sending the e-mail, this module will set the `privacy.consent` record as `sent`. * Thanks to *not* sending the email, the process the user faces when he hits the "generate" button is faster. * Instructions in the README and text in the "generate" button are updated to reflect this new behavior. * Thanks to the `auto_commit` feature, if Odoo is rebooted in the middle of a mail queue clearance, the records that were sent remain properly marked as sent, and the missing mails will be sent after the next boot. * No hardcoded commits. * No locked transactions. * BTW I discovered that 2 different emails were created when creating a new consent. I started using `mail_create_nolog=True` to avoid that problem and only log a single creation message. Note to self: never use again `post_message_with_template()`.
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
  7. <title>Privacy - Consent</title>
  8. <style type="text/css">
  9. /*
  10. :Author: David Goodger (goodger@python.org)
  11. :Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
  12. :Copyright: This stylesheet has been placed in the public domain.
  13. Default cascading style sheet for the HTML output of Docutils.
  14. See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
  15. customize this style sheet.
  16. */
  17. /* used to remove borders from tables and images */
  18. .borderless, table.borderless td, table.borderless th {
  19. border: 0 }
  20. table.borderless td, table.borderless th {
  21. /* Override padding for "table.docutils td" with "! important".
  22. The right padding separates the table cells. */
  23. padding: 0 0.5em 0 0 ! important }
  24. .first {
  25. /* Override more specific margin styles with "! important". */
  26. margin-top: 0 ! important }
  27. .last, .with-subtitle {
  28. margin-bottom: 0 ! important }
  29. .hidden {
  30. display: none }
  31. .subscript {
  32. vertical-align: sub;
  33. font-size: smaller }
  34. .superscript {
  35. vertical-align: super;
  36. font-size: smaller }
  37. a.toc-backref {
  38. text-decoration: none ;
  39. color: black }
  40. blockquote.epigraph {
  41. margin: 2em 5em ; }
  42. dl.docutils dd {
  43. margin-bottom: 0.5em }
  44. object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
  45. overflow: hidden;
  46. }
  47. /* Uncomment (and remove this text!) to get bold-faced definition list terms
  48. dl.docutils dt {
  49. font-weight: bold }
  50. */
  51. div.abstract {
  52. margin: 2em 5em }
  53. div.abstract p.topic-title {
  54. font-weight: bold ;
  55. text-align: center }
  56. div.admonition, div.attention, div.caution, div.danger, div.error,
  57. div.hint, div.important, div.note, div.tip, div.warning {
  58. margin: 2em ;
  59. border: medium outset ;
  60. padding: 1em }
  61. div.admonition p.admonition-title, div.hint p.admonition-title,
  62. div.important p.admonition-title, div.note p.admonition-title,
  63. div.tip p.admonition-title {
  64. font-weight: bold ;
  65. font-family: sans-serif }
  66. div.attention p.admonition-title, div.caution p.admonition-title,
  67. div.danger p.admonition-title, div.error p.admonition-title,
  68. div.warning p.admonition-title, .code .error {
  69. color: red ;
  70. font-weight: bold ;
  71. font-family: sans-serif }
  72. /* Uncomment (and remove this text!) to get reduced vertical space in
  73. compound paragraphs.
  74. div.compound .compound-first, div.compound .compound-middle {
  75. margin-bottom: 0.5em }
  76. div.compound .compound-last, div.compound .compound-middle {
  77. margin-top: 0.5em }
  78. */
  79. div.dedication {
  80. margin: 2em 5em ;
  81. text-align: center ;
  82. font-style: italic }
  83. div.dedication p.topic-title {
  84. font-weight: bold ;
  85. font-style: normal }
  86. div.figure {
  87. margin-left: 2em ;
  88. margin-right: 2em }
  89. div.footer, div.header {
  90. clear: both;
  91. font-size: smaller }
  92. div.line-block {
  93. display: block ;
  94. margin-top: 1em ;
  95. margin-bottom: 1em }
  96. div.line-block div.line-block {
  97. margin-top: 0 ;
  98. margin-bottom: 0 ;
  99. margin-left: 1.5em }
  100. div.sidebar {
  101. margin: 0 0 0.5em 1em ;
  102. border: medium outset ;
  103. padding: 1em ;
  104. background-color: #ffffee ;
  105. width: 40% ;
  106. float: right ;
  107. clear: right }
  108. div.sidebar p.rubric {
  109. font-family: sans-serif ;
  110. font-size: medium }
  111. div.system-messages {
  112. margin: 5em }
  113. div.system-messages h1 {
  114. color: red }
  115. div.system-message {
  116. border: medium outset ;
  117. padding: 1em }
  118. div.system-message p.system-message-title {
  119. color: red ;
  120. font-weight: bold }
  121. div.topic {
  122. margin: 2em }
  123. h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
  124. h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
  125. margin-top: 0.4em }
  126. h1.title {
  127. text-align: center }
  128. h2.subtitle {
  129. text-align: center }
  130. hr.docutils {
  131. width: 75% }
  132. img.align-left, .figure.align-left, object.align-left, table.align-left {
  133. clear: left ;
  134. float: left ;
  135. margin-right: 1em }
  136. img.align-right, .figure.align-right, object.align-right, table.align-right {
  137. clear: right ;
  138. float: right ;
  139. margin-left: 1em }
  140. img.align-center, .figure.align-center, object.align-center {
  141. display: block;
  142. margin-left: auto;
  143. margin-right: auto;
  144. }
  145. table.align-center {
  146. margin-left: auto;
  147. margin-right: auto;
  148. }
  149. .align-left {
  150. text-align: left }
  151. .align-center {
  152. clear: both ;
  153. text-align: center }
  154. .align-right {
  155. text-align: right }
  156. /* reset inner alignment in figures */
  157. div.align-right {
  158. text-align: inherit }
  159. /* div.align-center * { */
  160. /* text-align: left } */
  161. .align-top {
  162. vertical-align: top }
  163. .align-middle {
  164. vertical-align: middle }
  165. .align-bottom {
  166. vertical-align: bottom }
  167. ol.simple, ul.simple {
  168. margin-bottom: 1em }
  169. ol.arabic {
  170. list-style: decimal }
  171. ol.loweralpha {
  172. list-style: lower-alpha }
  173. ol.upperalpha {
  174. list-style: upper-alpha }
  175. ol.lowerroman {
  176. list-style: lower-roman }
  177. ol.upperroman {
  178. list-style: upper-roman }
  179. p.attribution {
  180. text-align: right ;
  181. margin-left: 50% }
  182. p.caption {
  183. font-style: italic }
  184. p.credits {
  185. font-style: italic ;
  186. font-size: smaller }
  187. p.label {
  188. white-space: nowrap }
  189. p.rubric {
  190. font-weight: bold ;
  191. font-size: larger ;
  192. color: maroon ;
  193. text-align: center }
  194. p.sidebar-title {
  195. font-family: sans-serif ;
  196. font-weight: bold ;
  197. font-size: larger }
  198. p.sidebar-subtitle {
  199. font-family: sans-serif ;
  200. font-weight: bold }
  201. p.topic-title {
  202. font-weight: bold }
  203. pre.address {
  204. margin-bottom: 0 ;
  205. margin-top: 0 ;
  206. font: inherit }
  207. pre.literal-block, pre.doctest-block, pre.math, pre.code {
  208. margin-left: 2em ;
  209. margin-right: 2em }
  210. pre.code .ln { color: grey; } /* line numbers */
  211. pre.code, code { background-color: #eeeeee }
  212. pre.code .comment, code .comment { color: #5C6576 }
  213. pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
  214. pre.code .literal.string, code .literal.string { color: #0C5404 }
  215. pre.code .name.builtin, code .name.builtin { color: #352B84 }
  216. pre.code .deleted, code .deleted { background-color: #DEB0A1}
  217. pre.code .inserted, code .inserted { background-color: #A3D289}
  218. span.classifier {
  219. font-family: sans-serif ;
  220. font-style: oblique }
  221. span.classifier-delimiter {
  222. font-family: sans-serif ;
  223. font-weight: bold }
  224. span.interpreted {
  225. font-family: sans-serif }
  226. span.option {
  227. white-space: nowrap }
  228. span.pre {
  229. white-space: pre }
  230. span.problematic {
  231. color: red }
  232. span.section-subtitle {
  233. /* font-size relative to parent (h1..h6 element) */
  234. font-size: 80% }
  235. table.citation {
  236. border-left: solid 1px gray;
  237. margin-left: 1px }
  238. table.docinfo {
  239. margin: 2em 4em }
  240. table.docutils {
  241. margin-top: 0.5em ;
  242. margin-bottom: 0.5em }
  243. table.footnote {
  244. border-left: solid 1px black;
  245. margin-left: 1px }
  246. table.docutils td, table.docutils th,
  247. table.docinfo td, table.docinfo th {
  248. padding-left: 0.5em ;
  249. padding-right: 0.5em ;
  250. vertical-align: top }
  251. table.docutils th.field-name, table.docinfo th.docinfo-name {
  252. font-weight: bold ;
  253. text-align: left ;
  254. white-space: nowrap ;
  255. padding-left: 0 }
  256. /* "booktabs" style (no vertical lines) */
  257. table.docutils.booktabs {
  258. border: 0px;
  259. border-top: 2px solid;
  260. border-bottom: 2px solid;
  261. border-collapse: collapse;
  262. }
  263. table.docutils.booktabs * {
  264. border: 0px;
  265. }
  266. table.docutils.booktabs th {
  267. border-bottom: thin solid;
  268. text-align: left;
  269. }
  270. h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
  271. h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
  272. font-size: 100% }
  273. ul.auto-toc {
  274. list-style-type: none }
  275. </style>
  276. </head>
  277. <body>
  278. <div class="document" id="privacy-consent">
  279. <h1 class="title">Privacy - Consent</h1>
  280. <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  281. !! This file is generated by oca-gen-addon-readme !!
  282. !! changes will be overwritten. !!
  283. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
  284. <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/11.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-11-0/data-protection-11-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/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
  285. <p>This module allows the user to define a set of subjects (partners)
  286. affected by any data processing activity, and establish
  287. a process to ask them for consent to include them in that activity.</p>
  288. <p>For those that need explicit consent as a lawfulness base for personal data
  289. processing, as required by GDPR (article 6.1.a), this module provides the
  290. needed tools to automate it.</p>
  291. <p><strong>Table of contents</strong></p>
  292. <div class="contents local topic" id="contents">
  293. <ul class="simple">
  294. <li><a class="reference internal" href="#installation" id="id1">Installation</a><ul>
  295. <li><a class="reference internal" href="#multi-database-instances" id="id2">Multi-database instances</a></li>
  296. </ul>
  297. </li>
  298. <li><a class="reference internal" href="#usage" id="id3">Usage</a></li>
  299. <li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
  300. <li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
  301. <li><a class="reference internal" href="#authors" id="id6">Authors</a></li>
  302. <li><a class="reference internal" href="#contributors" id="id7">Contributors</a></li>
  303. <li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
  304. </ul>
  305. </li>
  306. </ul>
  307. </div>
  308. <div class="section" id="installation">
  309. <h1><a class="toc-backref" href="#id1">Installation</a></h1>
  310. <p>You may want to install, along with this module, one of OCA’s
  311. <tt class="docutils literal">mail_tracking</tt> module collection, such as <tt class="docutils literal">mail_tracking_mailgun</tt>, so
  312. you can provide more undeniable proof that some consent request was sent, and
  313. to whom.</p>
  314. <p>However, the most important proof to provide is the answer itself (more than
  315. the question), and this addon provides enough tooling for that.</p>
  316. <div class="section" id="multi-database-instances">
  317. <h2><a class="toc-backref" href="#id2">Multi-database instances</a></h2>
  318. <p>To enable multi-database support, you must load this addon as a server-wide
  319. addon. Example command to boot Odoo:</p>
  320. <pre class="literal-block">
  321. odoo-bin --load=web,privacy_consent
  322. </pre>
  323. </div>
  324. </div>
  325. <div class="section" id="usage">
  326. <h1><a class="toc-backref" href="#id3">Usage</a></h1>
  327. <p>New options for data processing activities:</p>
  328. <ol class="arabic">
  329. <li><p class="first">Go to <em>Privacy &gt; Master Data &gt; Activities</em> and create one.</p>
  330. </li>
  331. <li><p class="first">Give it a name, such as <em>Sending mass mailings to customers</em>.</p>
  332. </li>
  333. <li><p class="first">Go to tab <em>Consent</em> and choose one option in <em>Ask subjects for consent</em>:</p>
  334. <ul class="simple">
  335. <li><em>Manual</em> tells the activity that you will want to create and send the
  336. consent requests manually, and only provides some helpers for you to
  337. be able to batch-generate them.</li>
  338. <li><em>Automatic</em> enables this module’s full power: send all consent requests
  339. to selected partners automatically, every day and under your demand.</li>
  340. </ul>
  341. </li>
  342. <li><p class="first">When you do this, all the consent-related options appear. Configure them:</p>
  343. <ul>
  344. <li><p class="first">A smart button tells you how many consents have been generated, and lets you
  345. access them.</p>
  346. </li>
  347. <li><p class="first">Choose one <em>Email template</em> to send to subjects. This email itself is what
  348. asks for consent, and it gets recorded, to serve as a proof that it was sent.
  349. The module provides a default template that should be good for most usage
  350. cases; and if you create one directly from that field, some good defaults
  351. are provided for your comfortability.</p>
  352. </li>
  353. <li><p class="first"><em>Subjects filter</em> defines what partners will be elegible for inclusion in
  354. this data processing activity.</p>
  355. </li>
  356. <li><p class="first">You can enable <em>Accepted by default</em> if you want to assume subjects
  357. accepted their data processing. You should possibly consult your
  358. lawyer to use this.</p>
  359. </li>
  360. <li><p class="first">You can choose a <em>Server action</em> (developer mode only) that will
  361. be executed whenever a new non-draft consent request is created,
  362. or when its acceptance status changes.</p>
  363. <p>This module supplies a server action by default, called
  364. <em>Update partner’s opt out</em>, that syncs the acceptance status with the
  365. partner’s <em>Elegible for mass mailings</em> option.</p>
  366. </li>
  367. </ul>
  368. </li>
  369. <li><p class="first">Click on <em>Generate consent requests</em> link to create new consent requests.</p>
  370. <ul class="simple">
  371. <li>If you chose <em>Manual</em> mode, all missing consent request are created as
  372. drafts, and nothing else is done now.</li>
  373. <li>If you chose <em>Automatic</em> mode, also those request e-mails are enqueued
  374. and, when the mail queue is cleared, they will be set as <em>Sent</em>.</li>
  375. </ul>
  376. </li>
  377. <li><p class="first">You will be presented with the list of just-created consent requests.
  378. See below.</p>
  379. </li>
  380. </ol>
  381. <p>New options for consent requests:</p>
  382. <ol class="arabic simple">
  383. <li>Access the consent requests by either:<ul>
  384. <li>Generating new consent requests from a data processing activity.</li>
  385. <li>Pressing the <em>Consents</em> smart button in a data processing activity.</li>
  386. <li>Going to <em>Privacy &gt; Privacy &gt; Consents</em>.</li>
  387. </ul>
  388. </li>
  389. <li>A consent will include the partner, the activity, the acceptance status,
  390. and the request state.</li>
  391. <li>You can manually ask for consent by pressing the button labeled as
  392. <em>Ask for consent</em>.</li>
  393. <li>All consent requests and responses are recorded in the mail thread below.</li>
  394. </ol>
  395. </div>
  396. <div class="section" id="bug-tracker">
  397. <h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
  398. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/data-protection/issues">GitHub Issues</a>.
  399. In case of trouble, please check there if your issue has already been reported.
  400. If you spotted it first, help us smashing it by providing a detailed and welcomed
  401. <a class="reference external" href="https://github.com/OCA/data-protection/issues/new?body=module:%20privacy_consent%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
  402. <p>Do not contact contributors directly about support or help with technical issues.</p>
  403. </div>
  404. <div class="section" id="credits">
  405. <h1><a class="toc-backref" href="#id5">Credits</a></h1>
  406. <div class="section" id="authors">
  407. <h2><a class="toc-backref" href="#id6">Authors</a></h2>
  408. <ul class="simple">
  409. <li>Tecnativa</li>
  410. <li>initOS GmbH</li>
  411. </ul>
  412. </div>
  413. <div class="section" id="contributors">
  414. <h2><a class="toc-backref" href="#id7">Contributors</a></h2>
  415. <ul class="simple">
  416. <li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
  417. <li>Jairo Llopis</li>
  418. </ul>
  419. </li>
  420. <li><a class="reference external" href="https://www.initos.com">initOS GmbH</a>:<ul>
  421. <li>Florian Kantelberg</li>
  422. </ul>
  423. </li>
  424. </ul>
  425. </div>
  426. <div class="section" id="maintainers">
  427. <h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
  428. <p>This module is maintained by the OCA.</p>
  429. <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
  430. <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
  431. mission is to support the collaborative development of Odoo features and
  432. promote its widespread use.</p>
  433. <p>This module is part of the <a class="reference external" href="https://github.com/OCA/data-protection/tree/11.0/privacy_consent">OCA/data-protection</a> project on GitHub.</p>
  434. <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>
  435. </div>
  436. </div>
  437. </div>
  438. </body>
  439. </html>