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.

489 lines
17 KiB

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
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
  1. # Translation of Odoo Server.
  2. # This file contains the translation of the following modules:
  3. # * privacy_consent
  4. #
  5. msgid ""
  6. msgstr ""
  7. "Project-Id-Version: Odoo Server 11.0\n"
  8. "Report-Msgid-Bugs-To: \n"
  9. "Last-Translator: <>\n"
  10. "Language-Team: \n"
  11. "MIME-Version: 1.0\n"
  12. "Content-Type: text/plain; charset=UTF-8\n"
  13. "Content-Transfer-Encoding: \n"
  14. "Plural-Forms: \n"
  15. #. module: privacy_consent
  16. #: model:mail.template,body_html:privacy_consent.template_consent
  17. msgid "<?xml version=\"1.0\"?>\n"
  18. "<div style=\"background:#F3F5F6;color:#515166;padding:25px 0px;font-family:Arial,Helvetica,sans-serif;font-size:14px;\">\n"
  19. " <table style=\"width:600px;margin:5px auto;\">\n"
  20. " <tbody>\n"
  21. " <tr>\n"
  22. " <td>\n"
  23. " <a href=\"/\">\n"
  24. " <img src=\"/logo\" alt=\"${object.activity_id.controller_id.display_name|safe}\" style=\"vertical-align:baseline;max-width:100px;\"/>\n"
  25. " </a>\n"
  26. " </td>\n"
  27. " </tr>\n"
  28. " </tbody>\n"
  29. " </table>\n"
  30. " <table style=\"width:600px;margin:0px auto;background:white;border:1px solid #e1e1e1;\">\n"
  31. " <tbody>\n"
  32. " <tr>\n"
  33. " <td colspan=\"2\" style=\"padding:15px 20px 0px 20px; font-size:16px;\">\n"
  34. " <p>\n"
  35. " Hello, ${object.partner_id.name|safe}\n"
  36. " </p>\n"
  37. " <p>\n"
  38. " We contacted you to ask you to give us your explicit consent to include your data in a data processing activity called\n"
  39. " <b>${object.activity_id.display_name|safe}</b>, property of\n"
  40. " <i>${object.activity_id.controller_id.display_name|safe}</i>\n"
  41. " </p>\n"
  42. " ${object.description or \"\"}\n"
  43. " <p>\n"
  44. " % if object.state == \"answered\":\n"
  45. " The last time you answered, you\n"
  46. " % elif object.state == \"sent\":\n"
  47. " If you do nothing, we will assume you have\n"
  48. " % endif\n"
  49. "\n"
  50. " % if object.accepted:\n"
  51. " <b>accepted</b>\n"
  52. " % else:\n"
  53. " <b>rejected</b>\n"
  54. " % endif\n"
  55. " such data processing.\n"
  56. " </p>\n"
  57. " <p>\n"
  58. " You can update your preferences below:\n"
  59. " </p>\n"
  60. " </td>\n"
  61. " </tr>\n"
  62. " <tr>\n"
  63. " <td style=\"padding:15px 20px 0px 20px; font-size:16px; text-align:right;\">\n"
  64. " <a href=\"/privacy/consent/accept/\" style=\"background-color: #449d44; padding: 12px; font-weight: 12px; text-decoration: none; color: #fff; border-radius: 5px; font-size:16px;\">\n"
  65. " Accept\n"
  66. " </a>\n"
  67. " </td>\n"
  68. " <td style=\"padding:15px 20px 0px 20px; font-size:16px; text-align:left;\">\n"
  69. " <a href=\"/privacy/consent/reject/\" style=\"background-color: #d9534f; padding: 12px; font-weight: 12px; text-decoration: none; color: #fff; border-radius: 5px; font-size:16px;\">\n"
  70. " Reject\n"
  71. " </a>\n"
  72. " </td>\n"
  73. " </tr>\n"
  74. " <tr>\n"
  75. " <td colspan=\"2\" style=\"padding:15px 20px 15px 20px; font-size:16px;\">\n"
  76. " <p>\n"
  77. " If you need further information, please respond to this email and we will attend your request as soon as possible.\n"
  78. " </p>\n"
  79. " <p>\n"
  80. " Thank you!\n"
  81. " </p>\n"
  82. " </td>\n"
  83. " </tr>\n"
  84. " </tbody>\n"
  85. " </table>\n"
  86. " <table style=\"width:600px;margin:0px auto;text-align:center;\">\n"
  87. " <tbody>\n"
  88. " <tr>\n"
  89. " <td style=\"padding-top:10px;font-size: 12px;\">\n"
  90. " <p>\n"
  91. " Sent by\n"
  92. " <a href=\"/\" style=\"color:#717188;\">${object.activity_id.controller_id.display_name|safe}</a>.\n"
  93. " </p>\n"
  94. " </td>\n"
  95. " </tr>\n"
  96. " </tbody>\n"
  97. " </table>\n"
  98. " </div>\n"
  99. " "
  100. msgstr ""
  101. #. module: privacy_consent
  102. #: model:mail.message.subtype,name:privacy_consent.mt_activity_acceptance_changed
  103. msgid "Acceptance Changed"
  104. msgstr ""
  105. #. module: privacy_consent
  106. #: model:mail.message.subtype,name:privacy_consent.mt_consent_acceptance_changed
  107. msgid "Acceptance Changed by Subject"
  108. msgstr ""
  109. #. module: privacy_consent
  110. #: model:mail.message.subtype,description:privacy_consent.mt_consent_acceptance_changed
  111. msgid "Acceptance status updated by subject"
  112. msgstr ""
  113. #. module: privacy_consent
  114. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_accepted
  115. #: model:ir.ui.view,arch_db:privacy_consent.consent_search
  116. msgid "Accepted"
  117. msgstr ""
  118. #. module: privacy_consent
  119. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_activity_default_consent
  120. msgid "Accepted by default"
  121. msgstr ""
  122. #. module: privacy_consent
  123. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_active
  124. msgid "Active"
  125. msgstr ""
  126. #. module: privacy_consent
  127. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_activity_id
  128. #: model:ir.ui.view,arch_db:privacy_consent.consent_search
  129. msgid "Activity"
  130. msgstr ""
  131. #. module: privacy_consent
  132. #: selection:privacy.consent,state:0
  133. msgid "Answered"
  134. msgstr ""
  135. #. module: privacy_consent
  136. #: model:ir.ui.view,arch_db:privacy_consent.consent_search
  137. msgid "Archived"
  138. msgstr ""
  139. #. module: privacy_consent
  140. #: model:ir.ui.view,arch_db:privacy_consent.consent_form
  141. msgid "Ask for consent"
  142. msgstr ""
  143. #. module: privacy_consent
  144. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_activity_consent_required
  145. msgid "Ask subjects for consent"
  146. msgstr ""
  147. #. module: privacy_consent
  148. #: selection:privacy.activity,consent_required:0
  149. msgid "Automatically"
  150. msgstr ""
  151. #. module: privacy_consent
  152. #: selection:privacy.consent,state:0
  153. msgid "Awaiting response"
  154. msgstr ""
  155. #. module: privacy_consent
  156. #: model:ir.ui.view,arch_db:privacy_consent.activity_form
  157. msgid "Consent"
  158. msgstr ""
  159. #. module: privacy_consent
  160. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_activity_consent_template_default_body_html
  161. msgid "Consent Template Default Body Html"
  162. msgstr ""
  163. #. module: privacy_consent
  164. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_activity_consent_template_default_subject
  165. msgid "Consent Template Default Subject"
  166. msgstr ""
  167. #. module: privacy_consent
  168. #: model:ir.model,name:privacy_consent.model_privacy_consent
  169. msgid "Consent of data processing"
  170. msgstr ""
  171. #. module: privacy_consent
  172. #: model:ir.actions.act_window,name:privacy_consent.consent_action
  173. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_activity_consent_count
  174. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_activity_consent_ids
  175. #: model:ir.model.fields,field_description:privacy_consent.field_res_partner_privacy_consent_count
  176. #: model:ir.model.fields,field_description:privacy_consent.field_res_users_privacy_consent_count
  177. #: model:ir.ui.menu,name:privacy_consent.menu_privacy_consent
  178. msgid "Consents"
  179. msgstr ""
  180. #. module: privacy_consent
  181. #: model:ir.model,name:privacy_consent.model_res_partner
  182. msgid "Contact"
  183. msgstr ""
  184. #. module: privacy_consent
  185. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_create_uid
  186. msgid "Created by"
  187. msgstr ""
  188. #. module: privacy_consent
  189. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_create_date
  190. msgid "Created on"
  191. msgstr ""
  192. #. module: privacy_consent
  193. #: model:ir.model,name:privacy_consent.model_privacy_activity
  194. msgid "Data processing activities"
  195. msgstr ""
  196. #. module: privacy_consent
  197. #: model:mail.template,subject:privacy_consent.template_consent
  198. msgid "Data processing consent request for ${object.activity_id.display_name|safe}"
  199. msgstr ""
  200. #. module: privacy_consent
  201. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_display_name
  202. msgid "Display Name"
  203. msgstr ""
  204. #. module: privacy_consent
  205. #: selection:privacy.consent,state:0
  206. msgid "Draft"
  207. msgstr ""
  208. #. module: privacy_consent
  209. #: sql_constraint:privacy.consent:0
  210. msgid "Duplicated partner in this data processing activity"
  211. msgstr ""
  212. #. module: privacy_consent
  213. #: model:ir.model,name:privacy_consent.model_mail_template
  214. msgid "Email Templates"
  215. msgstr ""
  216. #. module: privacy_consent
  217. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_activity_consent_template_id
  218. msgid "Email template"
  219. msgstr ""
  220. #. module: privacy_consent
  221. #: model:ir.model.fields,help:privacy_consent.field_privacy_activity_consent_template_id
  222. msgid "Email to be sent to subjects to ask for consent. A good template should include details about the current consent request status, how to change it, and where to get more information."
  223. msgstr ""
  224. #. module: privacy_consent
  225. #: model:ir.model.fields,help:privacy_consent.field_privacy_activity_consent_required
  226. msgid "Enable if you need to track any kind of consent from the affected subjects"
  227. msgstr ""
  228. #. module: privacy_consent
  229. #: model:ir.ui.view,arch_db:privacy_consent.activity_form
  230. msgid "Generate and enqueue missing consent requests"
  231. msgstr ""
  232. #. module: privacy_consent
  233. #: model:ir.ui.view,arch_db:privacy_consent.activity_form
  234. msgid "Generate missing draft consent requests"
  235. msgstr ""
  236. #. module: privacy_consent
  237. #: code:addons/privacy_consent/models/privacy_activity.py:138
  238. #, python-format
  239. msgid "Generated consents"
  240. msgstr ""
  241. #. module: privacy_consent
  242. #: model:ir.ui.view,arch_db:privacy_consent.consent_search
  243. msgid "Group By"
  244. msgstr ""
  245. #. module: privacy_consent
  246. #: model:ir.ui.view,arch_db:privacy_consent.form
  247. msgid "Hello,"
  248. msgstr ""
  249. #. module: privacy_consent
  250. #: model:ir.ui.view,arch_db:privacy_consent.form
  251. msgid "I <b>accept</b> this processing of my data"
  252. msgstr ""
  253. #. module: privacy_consent
  254. #: model:ir.ui.view,arch_db:privacy_consent.form
  255. msgid "I <b>reject</b> this processing of my data"
  256. msgstr ""
  257. #. module: privacy_consent
  258. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_id
  259. msgid "ID"
  260. msgstr ""
  261. #. module: privacy_consent
  262. #: model:ir.ui.view,arch_db:privacy_consent.form
  263. msgid "If it was a mistake, you can undo it here:"
  264. msgstr ""
  265. #. module: privacy_consent
  266. #: model:ir.model.fields,help:privacy_consent.field_privacy_consent_accepted
  267. msgid "Indicates current acceptance status, which can come from subject's last answer, or from the default specified in the related data processing activity."
  268. msgstr ""
  269. #. module: privacy_consent
  270. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_last_metadata
  271. msgid "Last Metadata"
  272. msgstr ""
  273. #. module: privacy_consent
  274. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent___last_update
  275. msgid "Last Modified on"
  276. msgstr ""
  277. #. module: privacy_consent
  278. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_write_uid
  279. msgid "Last Updated by"
  280. msgstr ""
  281. #. module: privacy_consent
  282. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_write_date
  283. msgid "Last Updated on"
  284. msgstr ""
  285. #. module: privacy_consent
  286. #: selection:privacy.activity,consent_required:0
  287. msgid "Manually"
  288. msgstr ""
  289. #. module: privacy_consent
  290. #: model:ir.model.fields,help:privacy_consent.field_privacy_consent_last_metadata
  291. msgid "Metadata from the last acceptance or rejection by the subject"
  292. msgstr ""
  293. #. module: privacy_consent
  294. #: code:addons/privacy_consent/models/mail_template.py:24
  295. #, python-format
  296. msgid "Missing privacy consent link placeholders. You need at least these two links:\n"
  297. "<a href=\"%s\">Accept</a>\n"
  298. "<a href=\"%s\">Reject</a>"
  299. msgstr ""
  300. #. module: privacy_consent
  301. #: model:mail.message.subtype,name:privacy_consent.mt_activity_consent_new
  302. #: model:mail.message.subtype,name:privacy_consent.mt_consent_consent_new
  303. msgid "New Consent"
  304. msgstr ""
  305. #. module: privacy_consent
  306. #: model:ir.model,name:privacy_consent.model_mail_mail
  307. msgid "Outgoing Mails"
  308. msgstr ""
  309. #. module: privacy_consent
  310. #: model:mail.message.subtype,description:privacy_consent.mt_activity_acceptance_changed
  311. msgid "Privacy consent request acceptance status changed"
  312. msgstr ""
  313. #. module: privacy_consent
  314. #: model:mail.message.subtype,description:privacy_consent.mt_activity_consent_new
  315. #: model:mail.message.subtype,description:privacy_consent.mt_consent_consent_new
  316. msgid "Privacy consent request created"
  317. msgstr ""
  318. #. module: privacy_consent
  319. #: model:mail.message.subtype,description:privacy_consent.mt_activity_state_changed
  320. #: model:mail.message.subtype,description:privacy_consent.mt_consent_state_changed
  321. msgid "Privacy consent request state changed"
  322. msgstr ""
  323. #. module: privacy_consent
  324. #: model:ir.model.fields,help:privacy_consent.field_res_partner_privacy_consent_count
  325. #: model:ir.model.fields,help:privacy_consent.field_res_users_privacy_consent_count
  326. msgid "Privacy consent requests amount"
  327. msgstr ""
  328. #. module: privacy_consent
  329. #: model:ir.model.fields,field_description:privacy_consent.field_res_partner_privacy_consent_ids
  330. #: model:ir.model.fields,field_description:privacy_consent.field_res_users_privacy_consent_ids
  331. msgid "Privacy consents"
  332. msgstr ""
  333. #. module: privacy_consent
  334. #: model:ir.actions.server,name:privacy_consent.cron_auto_consent_ir_actions_server
  335. #: model:ir.cron,cron_name:privacy_consent.cron_auto_consent
  336. #: model:ir.cron,name:privacy_consent.cron_auto_consent
  337. msgid "Request automatic data processing consents"
  338. msgstr ""
  339. #. module: privacy_consent
  340. #: code:addons/privacy_consent/models/privacy_activity.py:99
  341. #, python-format
  342. msgid "Require consent is available only for subjects in current database."
  343. msgstr ""
  344. #. module: privacy_consent
  345. #: model:ir.model.fields,help:privacy_consent.field_privacy_activity_server_action_id
  346. msgid "Run this action when a new consent request is created or its acceptance status is updated."
  347. msgstr ""
  348. #. module: privacy_consent
  349. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_activity_server_action_id
  350. msgid "Server action"
  351. msgstr ""
  352. #. module: privacy_consent
  353. #: model:ir.model.fields,help:privacy_consent.field_privacy_activity_default_consent
  354. msgid "Should we assume the subject has accepted if we receive no response?"
  355. msgstr ""
  356. #. module: privacy_consent
  357. #: model:ir.ui.view,arch_db:privacy_consent.form
  358. msgid "Sincerely,<br/>"
  359. msgstr ""
  360. #. module: privacy_consent
  361. #: code:addons/privacy_consent/models/privacy_activity.py:91
  362. #, python-format
  363. msgid "Specify a mail template to ask automated consent."
  364. msgstr ""
  365. #. module: privacy_consent
  366. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_state
  367. #: model:ir.ui.view,arch_db:privacy_consent.consent_search
  368. msgid "State"
  369. msgstr ""
  370. #. module: privacy_consent
  371. #: model:mail.message.subtype,name:privacy_consent.mt_activity_state_changed
  372. #: model:mail.message.subtype,name:privacy_consent.mt_consent_state_changed
  373. msgid "State Changed"
  374. msgstr ""
  375. #. module: privacy_consent
  376. #: model:ir.model.fields,field_description:privacy_consent.field_privacy_consent_partner_id
  377. msgid "Subject"
  378. msgstr ""
  379. #. module: privacy_consent
  380. #: model:ir.model.fields,help:privacy_consent.field_privacy_consent_partner_id
  381. msgid "Subject asked for consent."
  382. msgstr ""
  383. #. module: privacy_consent
  384. #: model:ir.ui.view,arch_db:privacy_consent.form
  385. msgid "Thank you!"
  386. msgstr ""
  387. #. module: privacy_consent
  388. #: model:ir.ui.view,arch_db:privacy_consent.form
  389. msgid "Thanks for your response."
  390. msgstr ""
  391. #. module: privacy_consent
  392. #: model:ir.ui.view,arch_db:privacy_consent.activity_form
  393. msgid "This could enqueue many consent emails, are you sure to proceed?"
  394. msgstr ""
  395. #. module: privacy_consent
  396. #: model:ir.actions.server,name:privacy_consent.update_opt_out
  397. msgid "Update partner's opt out"
  398. msgstr ""
  399. #. module: privacy_consent
  400. #: model:ir.ui.view,arch_db:privacy_consent.form
  401. msgid "We asked you to authorize us to process your data in this data processing activity:"
  402. msgstr ""
  403. #. module: privacy_consent
  404. #: model:ir.ui.view,arch_db:privacy_consent.form
  405. msgid "We have recorded this action on your side."
  406. msgstr ""
  407. #. module: privacy_consent
  408. #: model:ir.ui.view,arch_db:privacy_consent.form
  409. msgid "You have <b class=\"text-danger\">rejected</b> such processing."
  410. msgstr ""
  411. #. module: privacy_consent
  412. #: model:ir.ui.view,arch_db:privacy_consent.form
  413. msgid "You have <b class=\"text-success\">accepted</b> such processing."
  414. msgstr ""