Commit Graph
1964 Commits
Author SHA1 Message Date
Brieuc-brd 418413e499 [IMP] web, *: directional icons
This commit adapts the directional icons to improve the usability and
maintain consistency with the ui icons library.

task-2818586

Part-of: odoo/odoo#116641
2023-05-12 22:59:22 +02:00
Elisabeth Dickinson b2ef35a431 [IMP] *: replace .bg-color by .text-bg-color on ribbons
Also remove unnecessary CSS on ribbons.

Part-of: odoo/odoo#116641
2023-05-12 22:59:16 +02:00
Brieuc-brdandElisabeth Dickinson 21d87a3da5 [REF] *: milk graphical assets
- apps icons
- base: replace demo avatars Mitchell, Marc and Joel
- mail: replace odoobot avatar

Part-of: odoo/odoo#116641
Co-authored-by: Elisabeth Dickinson <edi@odoo.com>
2023-05-12 22:59:14 +02:00
Pulinckx Pierre (PIPU) 608e90e998 [REF] *: Replace underscore functions by native JS
Replace _.map(), _.flatten(), _.delay(), _.contains(), _.pluck(), _.isUndefined(), _.isEmpty(), _.isString(), _.isEqual(), _.isBoolean(), _.memoize(), _.invoke(), _.bind(), _.escape(), _.debounce(),
_.str.sprintf(), _.str.repeat(), _.str.startswith(), _.str.trim(),
_.str.escapeHTML(), _.str.escapeRegExp(), _.str.startsWith(), _.str.include()

closes odoo/odoo#118012

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-04-20 11:57:29 +02:00
Rémy Voet (ryv) 234db70d86 [IMP] *: Use the new API of _read_group for backend use
Part-of: odoo/odoo#110737
2023-04-19 21:58:27 +02:00
Pulinckx Pierre (PIPU) 800223ae7c [REF] *: Replace underscore _.each() by native JS
Replaced _.each() functions (average 235 occurences)

Description of the refactoring this PR addresses:

Current behavior before PR:

There are underscore.js function enumerated above used in odoo.

Desired behavior after PR is merged:

These functions has been replaced by native javascript
prototypes/methods/functions.

TaskId : 3246238

closes odoo/odoo#118565

Signed-off-by: Georis François (fge) <fge@odoo.com>
2023-04-18 15:38:54 +02:00
Benoit Socias 02ed9f5e66 [FIX] website, *: avoid using unescaped query parameters
*: google_recaptcha, web_editor, website_blog, website_event_booth,
   website_event_exhibitor, website_event_track, website_forum,
   website_jitsi, website_sale_comparison, website_slides,
   website_livechat, website_twitter

This commit fixes improperly escaped query parameters across javascripts
of website-related modules.

See https://github.com/odoo/enterprise/pull/31711

closes odoo/odoo#118599

X-original-commit: 89be076aa51b097ada48d0046006be4d9692ac1e
Related: odoo/enterprise#39783
Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
2023-04-18 11:33:46 +02:00
Pulinckx Pierre (PIPU) 614de86989 [REF] *: Replace underscore function by native JS
Replace _.isNumber(), _.filter(), _.reject(), _.unique(), _.indexOf(), _.lastIndexOf(), _.findIndex(), _.range()
_.keys(), _.values(), _.str.sprintf() and some _.each()

closes odoo/odoo#118003

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-04-13 16:40:11 +02:00
niyasraphy 01c37a970c [FIX] website_forum: show correct karma in faq
before this commit, in the website forum faq section,
it is shown, for each down vote it will reduce 10 xp,
but actually it is reducing 2 XP.

after this commit, the points shown in the faq
will be corrected to 2 xp from 10 xp.

closes odoo/odoo#118216

X-original-commit: 3168a39885ec8d4bdf3f9029ab0716beaee11ba1
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-11 17:53:49 +02:00
niyasraphy 40be0ebf9b [IMP] website_forum: remove milli seconds from vote datetime
before this commit, in the votes tab in the website
user profile, the date time is shown including the
milli seconds in it.

* open forum
* open own user profile
* click votes tab and see the date time

after this commit, the milli seconds info will be
removed from the date time.

closes odoo/odoo#118152

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-11 09:21:23 +02:00
Michael (mcm) ff0d6dd580 [REF] *: replace odoo module by native one
This commit converts almost all odoo module by native module.
The goal is to deprecate odoo.define in favor of native module and then
simplify boot.js by removing the regexp that finds module dependencies.

task id: 3162300

closes odoo/odoo#117305

Related: odoo/enterprise#39118
Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-04-03 17:07:24 +02:00
Thibault Delavallée 8f8adf760b [FIX] website_forum: fix post/forum website URL computation on memory records
'slug' cannot be called on records which are not yet saved, aka have no ID.
In this commit we set the website_url to False for records that do not have
any ID.

Code managing those URLs is updated to be defensive, as notably when using
studio you may end up trying to call methods on in-memory records.

Followup of odoo/odoo@da3f4c2aff

Task-3254382

closes odoo/odoo#117255

X-original-commit: 36c734ab37fdf1d6a245e0e29cfefe3cc46c6d92
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-03 10:41:34 +02:00
Arthur Detroux (ard) 1ebcdb0023 [FIX] website, *: check access rights to display elements in New+ modal
*: website_blog,website_event,website_forum,website_hr_recruitment,
website_livechat,website_sale,website_slides

Prior to this commit, elements inside the New+ modal had a `isDisplayed`
property that was meant to be changed by the patches done by each
module. Unfortunately, this was forgotten in the refactor done in [1]
and more precisely when the component was introduced in [2].

This commit fixes that by checking the access rights of the user on each
individual model used on the create form.

[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b
[2]: https://github.com/odoo/odoo/commit/ca2e143d54622d598201826a2cd669bad64b205d

opw-3198700

closes odoo/odoo#117206

X-original-commit: 58704cb7615addd7d40291431e05a894776320d8
Related: odoo/enterprise#39066
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-03-30 18:58:59 +02:00
Florian Charlier 915dc4762c [REF] website_forum: simplify _compute_teaser
textwrap does the ellision and we don't need to replace newlines characters.
It is done for us already (except that multiple newlines will be replaced by
a single space).

closes odoo/odoo#116778

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-29 23:37:00 +02:00
Thibault Delavallée 1d2057806b [IMP] website_forum: improve website/forum count computation
Avoid search_count in a loop using a filtered_domain.

Also removed a sudo, as anyway this method is already called in sudo in
most cases.

Part-of: odoo/odoo#116778
2023-03-29 23:37:00 +02:00
niyasraphy 5a5ada1dc8 [FIX] website_forum: fix typo
Insteadeither is added without space, adding spacing between the words.

Insteadeither  --> Instead either

closes odoo/odoo#116493

X-original-commit: 4e59006e2a5a3812cc72dd622b2fcec1468ec0d2
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-27 09:39:56 +02:00
Thibault Delavallée 2c5738d7ab [FIX] website_forum: assign value for computed 'karma_flag' field
Before this commit, the compute method was not returning the value for the
field karma_flag field, and thus it was returning compute method failed to
assign value error.

After this commit, the compute method will return correctly set the value
for karma_flag field from the forum.

closes odoo/odoo#116281

X-original-commit: odoo/odoo@bfa3f2d
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-23 20:12:45 +01:00
Thibault Delavallée e33f28de85 [FIX] website_forum: fix website/forum count synchronization, rename field
Currently 'forums_count' field on website is not correctly updated. Test
introduced recently show that

  * at website create, counter is not computed;
  * at forum create, counter is not computed;

Only updating a forum active flag, website value, or unlinking it recomputes
the counters.

Note that manually updating counters is required as forum with False website
are global forum, valid for all websites.

Finally rename 'forums_count' into 'forum_count'. Fields in Odoo are rarely
plural (more like 'forum_ids' / 'forum_count' for example, even if in our
case the 2many does not exist due to shared behavior).

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:29 +01:00
Thibault Delavallée 64d5cc3899 [IMP] website_forum: add tests for website/forum count
Add tests for website.forums_count field that should be synchronized manually
with the actual number of forum. Seems it is not working as expected, as
the manual update is not done at forum creation, and the default seems not
correctly computed.

Those tests are therefore red without the upcoming fix.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:29 +01:00
Thibault Delavallée 86dec3b0d2 [FIX] website_forum: fix missing translation
Gamification data used in some emails to add links and shortcuts is not
correctly translated. Let us fix it.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:29 +01:00
Thibault Delavallée 24cb6d2caf [FIX] website_forum: use read_group to compute user statistics
Instead of doing 1 search_count / user in the loop, use read_group to fetch
data in batch.

Also remove an unnecessary import.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:28 +01:00
Thibault Delavallée 0e089316cb [REF] website_forum: rename views according to guidelines
PURPOSE

Reorganize website_forum module. This allows to better locate code, understand
organization, and prepare future changes.

SPECIFICATIONS

Rename main views and actions according to guidelines. Having standardized
names eases process of finding and updating views.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:28 +01:00
Thibault Delavallée 870a5d12e3 [FIX] website_forum: correctly translate default welcome message
Default value is currently not translated, which is sad. We therefore move
it into its own default method, use translation marks, and Markupize the
whole result.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:28 +01:00
Thibault Delavallée 97929d53c8 [FIX] website_forum: improve forum FAQ display
Better have a correctly formatted content looking like all other HTML fields.
This is achieved by using sanitize parameter which cleans up html content
according to our standards.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:26 +01:00
Thibault Delavallée 639f6195c2 [FIX] website_forum: avoid mutable as default method parameters
That is how you end up with funny results.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:25 +01:00
Thibault Delavallée f8c2d84024 [FIX] website_forum: better string manipulation for tags
A strange manipulation is performed when trying to create tags. In this
commit we simply make styling happy by trying to first prepare data
(strip, content) then use it. Feature is untouched currently.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:24 +01:00
Thibault Delavallée 112622db70 [FIX] website_forum: improve / cleanup computed fields
Notably add missing triggers for unstored fields depending on 'uid'.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:24 +01:00
Thibault Delavallée 264f0dcb4e [REF] website_forum: reorganize tests
Mainly reorganize them alphabetically so that execution order matches the
definition order. It helps when debugging.

Also clean some tests from odoo/odoo@f9c2716b3e because they either test nothing
either are not understandable by standard humans. Other tests are left
untouched.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:24 +01:00
Thibault Delavallée 45a5ecd08f [REF] website_forum: reorganize main python code, lint it quickly
PURPOSE

Reorganize website_forum module. This allows to better locate code, understand
organization, and prepare future changes.

SPECIFICATION

Reorganize main content of python code

  * group compute fields on top, order them following fields definition;
  * add section separators, to separate compute methods / CRUD methods /
    business methods / Mail methods / Tooling in file and have a way to
    sort a bit the code out;
  * rename compute methods to start with '_compute', to match guidelines
    and be coherent with global odoo naming;
  * perform some relining in fields definition, don't enforce any char
    length but try to stay aligned with Odoo apps;

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:24 +01:00
Thibault Delavallée 20565afc46 [REM] website_forum: remove dead view
'post_reply' template seems not used anywhere.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:23 +01:00
Thibault Delavallée 11df1af102 [MOV] website_forum: rename remaining files
PURPOSE

Reorganize website_forum module. This allows to better locate code, understand
organization, and prepare future changes.

SPECIFICATIONS

Rename remaining files: controllers, sub-modules, tests, ...

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:23 +01:00
Thibault Delavallée 232f1dba23 [MOV] website_forum: split templates per main usage
PURPOSE

Reorganize website_forum module. This allows to better locate code, understand
organization, and prepare future changes.

SPECIFICATIONS

Split templates by main usage. Files have been duplicated previously, they
are now cleaned to keep only content relevant to their usage. Split is done
according to

  * base file: layouts for main actions not specifically managed in other
    sub-files: display a forum, manage tags, post a new question or edit
    a question;
  * '_forum_all': 'all' page in multi-forum display, displaying the list of
    available forum;
  * '_layout': layouting templates. Modifications to global layout and forum
    specific page header used through all main templates;
  * '_moderation': moderation tools;
  * '_post': display a forum post;
  * '_tools': tooling and utility blocks, used as black boxes in various
    main templates;

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:23 +01:00
Thibault Delavallée a66f6aae7a [MOV] website_forum: duplicate 'forum_forum_templates.xml', prepare split
Purpose is to try to keep history before splitting frontend templates into
separate files. We first copy the file, then remove extra content in each
of them. Let us see if this works.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:23 +01:00
Thibault Delavallée 2ad0ed3add [MOV] website_forum: move, split and rename (backend) views
PURPOSE

Reorganize website_forum module. This allows to better locate code, understand
organization, and prepare future changes.

SPECIFICATIONS

Rename and split backend views / model. It allows an easier manipulation and
management.

Templates (frontend) files are renamed but not split. It requires a more
in-depth check of their content before splitting into sub-files (to have
tool templates separated from main templates notably). This will be done
in the next few commits.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:22 +01:00
Thibault Delavallée 00a626deb8 [MOV] website_forum: move, split and rename data files
PURPOSE

Reorganize website_forum module. This allows to better locate code, understand
organization, and prepare future changes.

SPECIFICATIONS

Split data files / model. It is easier to have a global view of a module
organization and content. It also allows to see technical data impacted
by the module installation (like ir_actions, mail_message_subtypes, ...)

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:22 +01:00
Thibault Delavallée b7d8df8ff1 [MOV] website_forum: split models per model
PURPOSE

Reorganize website_forum module. This allows to better locate code, understand
organization, and prepare future changes.

SPECIFICATIONS

Split python files / model. It is easier to have a global view of a module
organization and content when looking at the models directory. Each model
now belongs to a single file.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:22 +01:00
Thibault Delavallée 38bf03b255 [MOV] website_forum: duplicate 'forum.py', prepare models split
Purpose is to try to keep history before splitting models into separate files.
We first copy a file, then remove extra content in each of them. Let us see
if this works.

Task-3240082 (Forum: Reorganize and lint module)

Part-of: odoo/odoo#114841
2023-03-22 17:03:22 +01:00
Martin Trigaux 1be5eae8ef [I18N] *: remove nl_BE files
They dates from < 2027 and are quite outdated. Favour the nl
translation instead.
n_BE is not on Transifex so it was not possible to correct bad
translations.

closes odoo/odoo#115845

X-original-commit: d04c8b7e484db8306d858c891a7a2b11885fdcd9
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-03-20 16:51:30 +01:00
Louis Wicket (wil) 9afe7c74c9 [IMP] *: remove "French spacing" 👺
According to Wiktionary, French spacing is "the archaic practice (though
still current in French) of inserting a space around colons, semicolons,
question marks, and exclamation marks". This is not standard practice in
English and most languages of the world.

The purpose of this commit is to start purging the code from this typo,
as it may reflect poorly on the software for some people.

closes odoo/odoo#114533

Related: odoo/enterprise#37853
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-03-14 15:52:10 +01:00
Yannick Tivisse 4518a768eb [IMP] website_forum: Allow user deletion if linked to post vote
Purpose
=======

Currently the on_delete='restrict' implicit constraint prevents
the user deletion in case it's linked to a forum post vote.

Set the on_delete attribute to 'cascade' as the record is not
really a critical data.

Taskid: 3222941
Part-of: odoo/odoo#114656
2023-03-13 13:13:48 +01:00
Thibault Delavallée c088d5423e [IMP] mail: cleanup _notify_get_recipients code bits
This commit contains mainly code cleaning, docstrings and a small split
for notification tool methods. In this commit we

  * make some notification groups variable explicit;
  * move the filler of groups into its own submethod to ease being called
    from other code (to be used soon);
  * fix some strange overrides or code manipulation;
  * propagate some additional parameters to ease future commits that will
    improve rendering of groups-based notification emails;
  * cleanup, fixup and improve docstrings;

This does not change anything from functional point of view, just preparing
further work.

Task-3046371 (Mail: Better Language Support in Composer)

Part-of: odoo/odoo#106177
2023-03-09 15:54:12 +01:00
Jeremy Kersten f20f6667fa [FIX] website_forum: add default value for forum_origin
We have a lot of hits without any forum_origin which will raise an
error 500 because this parameter is required. But because this params is
not into the controller but received as a get parameter, it will match
the controller and return an error 500 instead of a beautiful 404.

Some controller like 'open_partner' redirect to this url without the
parameter forum_origin too, leading in a 500 in all cases.

Better for uX to have this param, but not critical to display the page.
The only negative impact will be to have a 'Back' button that return to
this new default value '/forum'.

closes odoo/odoo#114461

X-original-commit: 991d1c430f2c9bb0d2b2d7ac8f75338eafd2aced
Signed-off-by: Jérémy Kersten <jke@odoo.com>
2023-03-07 02:56:41 +01:00
niyasraphy f765bd1c2b [FIX] website_forum: restore answers field width on post form view
Before this commit, in the forum post form view, the answers one2many
field is not aligned properly.

* open a forum post from website
* click forum post in the top bar (near edit button)
* forum post form will be opened

After this commit, the field will be displayed properly.

closes odoo/odoo#114433

X-original-commit: 5d8db1e1715cef36468681f59da55c780ae67a55
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-03-07 02:56:21 +01:00
Thomas Josseandstd-odoo 0ffa2d64ba [IMP] gamification, website_forum, website_slides: karma tracking improvement
Purpose
=======
Some users found a way to farm karma points, so we want to be able to
track the source of the karma gain / loss.

Specifications
==============
Now, we added a reference field `origin_ref` which store the record
responsible for the karma gain / loss (e.g. a slide we just completed).

In addition to this origin, we also have a new field to store the
reason (e.g. "Slide completed") so we know exactly what happened and
how the user gains his karma.

Before, the `old_value` of the karma tracking has to be set manually,
but now it's done automatically based on the value of the previous
tracking of the same user. That way, it will simplify other part of
the code.

Add the karma reason in the website modules. Adapt those modules due
to the changes in gamification.

Task-2234179

closes odoo/odoo#76430

Related: odoo/enterprise#23702
Related: odoo/upgrade#3299
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Co-authored-by: std-odoo <std@odoo.com>
2023-03-06 17:47:09 +01:00
Romain Derie 357eb00f6a [FIX] website_forum: show again the tag subscribe box
On the `/forum/<forum>/tag` page, since the update from BS4 to B5, the
box to subscribe supposed to be shown when hovering a tag is not shown
anymore.

This is because in BS4, `col-md-3` was bringing the `position:relative`
css property but it's not the case anymore in BS5.
The `.o_forum_tag_follow_box` which is in `position:absolute` is
therefore not working as expected.
It is actually shown, but the user can't notice it as it's shown at the
very bottom of the page below the footer (you can see the scrollbar size
being changed).

closes odoo/odoo#111751

X-original-commit: 9a45860e9df1e24760ae5ba45faee4a67dbfc80d
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-02-03 07:06:58 +01:00
niyasraphy 2507c8e819 [FIX] website_forum: display correct user image in forum sidebar
Before this commit, on accessing the validation queue in the website forum,
the user image shown in the sidebar is different from the logged in user image.

The cause of issue was the variable passed from the controller and the
variable used for iterating the for loop who are the same, aka user. Thus
the value for 'user' is getting changed. resolved by storing the user value
to a temporary variable and restoring it after the loop.

After this commit, in the validation queue it will show the same logged in
user image in sidebar.

closes odoo/odoo#111474

X-original-commit: 31ad927c825f0aea02b3031fa228002ca33f65fd
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-01-31 15:18:01 +01:00
Géry Debongnie b53f78e224 [REF] web_tour,*: use the registry in collecting the tours
This is a step closer to a goal of avoiding dependence on asynchronous
modules. Starting from this commit, new tour definition should be
registered to `registry.category("web_tour.tours")` registry.

So, instead of the following:

```js
import tour from "web_tour.tour";
tour.register(name, options, steps);
```

We now do:

```js
import { registry } from "@web/core/registry";
registry.category("web_tour.tours").add(name, optionsWithSteps);
```

Notice the `options` and `steps` params are merged when registering
the tour definition. It should look something like so:

```js
registry.category("web_tour.tours").add("account_tour", {
  test: true,
  steps: [ ... ],
});
```

And if the `TourManager` instance is needed, one can get it from the
registry like so `registry.get("tourManager")`. Note however that
this instance is only available when the `TourManager` has been
instantiated -- so it's not available at top level of the module.

closes odoo/odoo#111103

Related: odoo/enterprise#36335
Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-01-27 23:17:35 +01:00
Martin Trigaux 776689b0f4 [I18N] *: export saas-16.1 source terms
closes odoo/odoo#110752

X-original-commit: 56b2b52287a8f2192d80ea417c7efac80a87c0a9
Related: odoo/enterprise#36173
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-01-24 10:20:30 +01:00
Thibault Delavallée 4775bd93a2 [REF] mail: cleanup post with {view, template} wrappers
RATIONALE

Purpose of this commit is to cleanup main post helpers and have a more easy
and understandable way of calling them.

SUMMARY

We now have two main API methods, based on business flow: either posting
on documents, either sending a mass mailing. Indeed those two flows are
different

  * post: create message, then launch notification process by taking into
    account subtype, followers, ...
  * mail: create mails in batch with recipients being based on template or
    given partners. No notifications is involved, only maybe traces if a
    mass mailing is linked

Delegate QWeb rendering to the render mixin (i.e. _render_template_qweb_view)
in order to have a single point to forge evaluation context and re-use
existing rendering code.

SPECIFICATIONS

Main API helpers are now

  * ``message_post_with_source``: (batch) post on records, using an ir.ui.view
    (given a record or its xml id) or a mail.template record (given a record or
    its xml id). When using a template, a composer is called to post on each
    record (as batch post is not yet supported). When using a view, a direct
    call to message_post using the rendered bodies is done, one record at a
    time.
  * ``message_mail_with_source``: send a mass mailing on records, acting like
    invoking the mail composer in mass mode. Same arguments are valid, either
    a reference to a view, either a reference to a mail template.

Other helpers are

  * ``_message_log_with_view``: (batch) log on records, using an ir.ui.view
    to render the body using QWeb (no notification process);
  * ``_message_log(_batch)``: (batch) log on records (no notification process);
  * ``message_notify``: notify partners on records (creating notifications
    specifically for some people while message itself is not displayed in
    chatter);

Code migration

  * ``message_post_with_template`` in "mass mode": use ``message_mail_with_source``
    and set the template record as source;
  * ``message_post_with_template`` in "comment" mode: use ``message_post_with_source``
    and set the template record as source;
  * ``message_post_with_view``: its main usage was to post on a document, in which
    case it generally can be replaced by ``message_mail_with_source`` using
    the view reference as source;

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:34 +01:00
Thibault Delavallée 418761e344 [LINT] mail, various: use explicit subtype in message_post_{with_...}
RATIONALE

Purpose of this commit is to be explicit in subtype chosen when invoking the
message composer / calling message_post. As default value may not always be
clear, better be explicit in case the composer default value changes.

SPECIFICATIONS

Add explicit references to subtype when it is not obvious what will be the
final subtype, notably when using helpers (post_with_view or template which
uses the composer that is not crystal clear in its subtype management).

In this commit we also add support of XMLID-based subtype when invoking the
composer. A ``default_subtype_xmlid`` context key is transformed into a
``default_subtype_id``, to be used notably in JS where we cannot easily
use a ``ref``-like statement. Post API now also supports 'subytpe_xmlid'
argument allowing to give the xml id and ease calling the methods.

Use ``_xmlid_to_res_id`` to get directly the ID of subtypes in order to
avoid useless queries from ``ref`` that does an exists.

Also remove useless values given to post API, notably author_id that is by
default the current users' partner.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00