social icon indicating copy to clipboard operation
social copied to clipboard

[17.0][MIG] mail_composer_cc_bcc: Migration to 17.0

Open trisdoan opened this issue 1 year ago • 4 comments

1) Summary of changes in 17.0

mail.template https://github.com/odoo/odoo/blob/17.0/addons/mail/models/mail_template.py

  • generate_recipients replaced by _generate_template_recipients

mail.mail: https://github.com/odoo/odoo/blob/17.0/addons/mail/models/mail_mail.py

  • new method _prepare_outgoing_list: https://github.com/odoo/odoo/commit/b1d678b12ac5aac4086771f9ae88d401d919c9fa
  • replaces _send_prepare_values
  • new method _personalize_outgoing_body is also introduced

account.move.send: replaces account_invoice_send

  • do not inherit mail.compose.message
  • _action_send_mail replaced by _send_mail
  • introduce new method _get_mail_move_values

2) Consequences

  • We don't need to fully replace mail.mail:_send_mail() as we did before, thanks to _prepare_outgoing_list.
  • override _get_mail_move_values and _send_mail in account.move.send as it does not benefit from mail.compose.message

3) This change

  • major refactoring:
    • roll back to do as odoo: one mail per recipient (will enable compatibility with mail_tracking)
    • keep same all headers (To, Cc, Bcc) in all emails
    • use a context to define the proper smtp_to for each email
    • introduce test_MailTemplate_upstream_file_hash & test_MailComposer_upstream_file_hash to keep track of changes upstream

_compute_partner_ids

  • remove email_cc from partner_ids to keep consistency with previous versions and create no confusion

_action_send_mail

  • update context when composition_mode == 'comment'

  • My colleague Hai is busy on other topics, I will take over as a maintainer of this module from now on.

trisdoan avatar Feb 21 '24 02:02 trisdoan

Hello,

Could you clarify why the module depends on the account? I couldn't find any justification for this dependency. Could you either remove it or explain the reasoning behind its inclusion?

Thank you.

llabusch93 avatar Mar 08 '24 08:03 llabusch93

Good catch @llabusch93 !

  • mail_composer_cc_bcc should not depend on account anymore indeed;
  • only mail_composer_cc_bcc_account will (to adapt the Invoice Sending wizard).

This will be fixed soon.

nilshamerlinck avatar Mar 08 '24 08:03 nilshamerlinck

Hi @llabusch93 and @nilshamerlinck, thank you for your review

I updated as you suggested.

trisdoan avatar Mar 11 '24 07:03 trisdoan

/ocabot migration mail_composer_cc_bcc

gurneyalex avatar Apr 09 '24 16:04 gurneyalex

@trisdoan can you check @mmequignon's comments?

gurneyalex avatar May 31 '24 06:05 gurneyalex

Hello @mmequignon, @gurneyalex I took your suggestions into account :pray:

trisdoan avatar Jun 01 '24 04:06 trisdoan

Hello @mmequignon's , how does it look to you?

trisdoan avatar Jun 24 '24 02:06 trisdoan

Hello @mmequignon's , how does it look to you?

Thank you, totally missed the notifications, sorry about that :pray:

mmequignon avatar Jul 19 '24 11:07 mmequignon

/ocabot merge nobump

gurneyalex avatar Jul 19 '24 19:07 gurneyalex

Hey, thanks for contributing! Proceeding to merge this for you. Prepared branch 17.0-ocabot-merge-pr-1312-by-gurneyalex-bump-nobump, awaiting test results.

OCA-git-bot avatar Jul 19 '24 19:07 OCA-git-bot

@gurneyalex The merge process could not be finalized, because command oca-gen-addon-readme --if-source-changed --org-name OCA --repo-name social --branch 17.0 --addons-dir /tmp/tmp985i_3ld --commit failed with output:

/tmp/tmp985i_3ld/mail_composer_cc_bcc/README.rst:87: (ERROR/3) Duplicate substitution definition name: "image".
Traceback (most recent call last):
  File "/usr/local/bin/oca-gen-addon-readme", line 8, in <module>
    sys.exit(gen_addon_readme())
             ^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/src/oca-maintainers-tools/tools/gen_addon_readme.py", line 575, in gen_addon_readme
    check_rst(readme_filename)
  File "/ocamt/src/oca-maintainers-tools/tools/gen_addon_readme.py", line 398, in check_rst
    publish_file(
  File "/ocamt/lib/python3.12/site-packages/docutils/core.py", line 422, in publish_file
    output, publisher = publish_programmatically(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/core.py", line 722, in publish_programmatically
    output = publisher.publish(enable_exit_status=enable_exit_status)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/core.py", line 234, in publish
    self.document = self.reader.read(self.source, self.parser,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/readers/__init__.py", line 70, in read
    self.parse()
  File "/ocamt/lib/python3.12/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/__init__.py", line 184, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 169, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 3034, in text
    self.section(title.lstrip(), source, style, lineno + 1, messages)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
                   ^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2790, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
                   ^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2790, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
                   ^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2357, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2369, in explicit_construct
    return method(self, expmatch)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2087, in substitution_def
    self.document.note_substitution_def(
  File "/ocamt/lib/python3.12/site-packages/docutils/nodes.py", line 1536, in note_substitution_def
    msg = self.reporter.error(
          ^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/utils/__init__.py", line 231, in error
    return self.system_message(self.ERROR_LEVEL, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/utils/__init__.py", line 197, in system_message
    raise SystemMessage(msg, level)
docutils.utils.SystemMessage: /tmp/tmp985i_3ld/mail_composer_cc_bcc/README.rst:87: (ERROR/3) Duplicate substitution definition name: "image".

OCA-git-bot avatar Jul 19 '24 19:07 OCA-git-bot

Hello @gurneyalex, could you please remerge

trisdoan avatar Jul 21 '24 15:07 trisdoan

/ocabot merge nobump

hbrunn avatar Jul 22 '24 05:07 hbrunn

On my way to merge this fine PR! Prepared branch 17.0-ocabot-merge-pr-1312-by-hbrunn-bump-nobump, awaiting test results.

OCA-git-bot avatar Jul 22 '24 05:07 OCA-git-bot

Congratulations, your PR was merged at 8270ee804ff929a47a4056c85ab15a570aafa2f4. Thanks a lot for contributing to OCA. ❤️

OCA-git-bot avatar Jul 22 '24 05:07 OCA-git-bot