Before this commit, it was not possible to send messages in
full composer containing user mentions. Even whe the mentions were
added in the small composer and then continuing composing the message
in the full composer.
With this commit, we can now make user and channel mentions in the
full composer, by typing `@` and `#` like in the small composer of
Discuss.
When composing a message in small composer and then switching to full
composer, the mentions are preserved.
task-3470060
closesodoo/odoo#132701
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This PR introduce multiple usage of the escape key:
- Channel selector can now be closed using the escape key
- Using the escape key will focus the composer automatically
Task-3456518
closesodoo/odoo#135031
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, owl was in the linter's accepted global variables.
This allowed direct access to owl global object.
For instance, to use xml from owl, you could do :
`const { xml } = owl;`
or you could use it directly:
`owl.xml`
Now, owl is not accepted on linter's global variables anymore, so to
import xml, now you need to use a proper import:
`import { xml } from "@odoo/owl";`
task-id 3498859
closesodoo/odoo#137517
Related: odoo/enterprise#48364
Related: odoo/design-themes#709
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
Discuss model data that had commands have been simplified by [1].
Notably some `unlink` were replaced by `False` and or `DELETE`.
Some code in Discuss calls was still expecting receiving command data
in of `DELETE` while data received has become `false`. As a result,
the state of ringing threads and showing call invitation card was not
working.
This commit fixes the issue by relying on recent improvements that
commands can be passed immediately as data to relational fields [2].
Code in Discuss call still have some coupling between fields whenever
some records are either added to or removed from a field. Hooks
`onAdd` and `onDelete` on relational fields are added to support
these cases.
[1]: https://github.com/odoo/odoo/pull/136308
[2]: https://github.com/odoo/odoo/pull/137341closesodoo/odoo#137540
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
1. simplify message reaction formatter (personas)
Data was formatted to have "partners" and "guests" entries, both
of which contribute to personas.
To avoid some post-processing of data in JS, it's best to format
data to immediately include type of persona.
2. include "guestAuthor" in "author" data of message
Discuss models in JS group partners and guests into a single model
Persona, to make feature works regardless on whether user is
authenticated or not.
This commit simplifies code by removing data guestAuthor in message
formatted data, and instead author contains author data in all cases,
whether the author is a partner or guest.
3. simplify insert (remove id, redundant with preinsert)
Also rename Follower.isActive to Follower.is_active, for
even simpler Follower.insert()
closesodoo/odoo#137276
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit removes the legacy service mappers which are useless now.
closesodoo/odoo#136807
Task: 3439226
Related: odoo/enterprise#48015
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
Before this PR, channel update were not sent via bus notifications.
Part of task-2821415
closesodoo/odoo#136623
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
*board,mail,project
This commit aims to simplify the XMLParser logic and the way archs
are manipulated in views, motivated by [1] where we had to
modify the arch in View to insert access right information.
First, the xml utils have been reworked. The XMLParser class has
been removed. The xml utils module already exported a parseXML and
a serializeXML functions, this commit adds visitXML, s.t. the whole
XMLParser feature is fully replaced by the 3 functions.
Second, concrete views now receive the arch in props as an
XMLDocument, as the arch is parsed once for all in View. With this,
we were able to remove serializing/parsing back and forth at several
places, where we needed to extract information for sub-parts of an
arch individually (e.g. View, x2many subviews, list view groupby).
Third, even though this change has been driven by the one above and
wasn't initally wanted, the view compiler cache and API have been
simplified. The cache is now flat, there's an entry in the cache for
each template that has been compiled. Moreover, the useViewCompiler
hook no longer takes the cache key in params, as it can directly
compute it itself (the key being the outerHTML of the template).
[1] odoo/odoo#135145closesodoo/odoo#136376
Related: odoo/enterprise#47808
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
Follow-up PR of https://github.com/odoo/odoo/pull/136308
Commit above simplified code in discuss models so code applies
on records than properties on records. For example, instead of
juggling between persona local id and persona, some code can simply
keep logic on persona without leaking local id.
However the improvements are iterative, and more improvements are
needed to stop using local id. Some code still need local ids.
Commit above mistakenly converts a local id to persona on some code
that still work in terms of local id. As a result, message reactions
were not working properly, notably when adding a new reaction using
click on an existing message reaction of someone else.
There was also a bug in implementation in mock server which made the
test not working. This commit fixes this issue too.
Task-3523101
closesodoo/odoo#136940
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This significantly eases processing command data on relational field
received from server.
closesodoo/odoo#137341
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This field contained 2 sets with partner and channel ids.
It's easier and safer to reason in terms of records rather
than properties on records.
Part-of: odoo/odoo#137341
The cookie service was replaced by a utils file in core. This was done
to be able to use the cookies without the need of environment.
"Om Nom Nom Nom" - Cookie Monster
part-of task-id 3439226
closesodoo/odoo#136782
Related: odoo/enterprise#48005
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
With this commit, instead of `Record.insert()` before setting
relation with records, we can immediately pass record data.
For example:
```js
message.author = { id: 3, type: "partner", name: "Admin" };
thread.messages.add({ id: 10, body: "some-text-content" })
```
This is supported on all relational fields that define a target
model.
To make this work while drastically avoiding cyclic dependencies
in code, whenever data have to be inserted in relation, they are
pre-inserted with essential data, and then they are fully inserted
after being registered in the relation.
closesodoo/odoo#136539
Related: odoo/enterprise#47854
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This simplifies managing relations on the store, and gives
incentive to define them there instead of another prop that
is a record, e.g. `discuss`.
Part-of: odoo/odoo#136539
Before this commit, all mail templates were shared, which was cluttering the UI
for everyone.
Now, each user can have their own templates that they can edit and save. Access
is done through the mail composer wizard, where users can only access their own
templates and templates that don't belong to anyone.
Some groups are considered as admins and can access all templates in
Settings/Technical/Email/Email Templates:
- Sales Admin
- Project Admins
- Helpdesk Admins
- Accountants
- Event Admins
- Recruitment Admins
Task-2504439
Part-of: odoo/odoo#126049
This fixes flickers in situations where:
- close (manually): notify
- open (manually): notify
- close (from bus)
- open (from bus)
The final state is correct, but it does one extra close and open.
With this fix, it becomes
- close (manually): notify
- open (manually): notify
- (close from bus ignored)
- (open from bus ignored)
Note: the fix is aimed towards fixing issues within the tab making the
manual change, which is the most common use case. Other tabs are not
considered visible at the time of the change, making the flicker
irrelevant, which is convenient to ignore as fixing it would require
more advanced mechanism.
runbot-24379
runbot-24994
closesodoo/odoo#136698
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
The server is supposedly already aware of changes that are coming from
itself, it doesn't need to be notified again.
This prevents each extra open tab from making useless RPC.
This also fixes race conditions in situations where:
- close (manually): notify
- open (manually): notify
- close (from bus): notify close again <--- this is the bug
- open (from bus): already no notify for open from bus (ok)
- close (from bus again): and notify close yet again
Final state is close, whereas the user manually set open last.
With the fix, it becomes:
- close (manually): notify
- open (manually): notify
- close (from bus)
- open (from bus)
Finally state is open as expected, no extra RPC.
Note that is this example, there is still a problem, where an obsolete
value from the server (the first close from the bus) will overwrite the
newer local state (open), causing a potential flicker. This will be
fixed in a future commit.
runbot-24379
runbot-24994
Part-of: odoo/odoo#136698
Go to the form view of mailing.mailing, write "hello " as the subject,
insert an emoji, you end up with "hello:)" instead of "hello :)". The
problem is that when the input loose the focus, it is automatically
trim.
Reconfigure the `char_emojis` widget so that is doesn't trim.
task-id-3493168
closesodoo/odoo#136530
X-original-commit: 2adda1eb2760ccf970761f424105e245afc3de3f
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
In preparation to improve insert in relational field with data, so
that there's less risk for cyclic code execution (hint: there'll be
a preinsert).
closesodoo/odoo#136308
Related: odoo/enterprise#47777
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This method pushes the provided record if it's not in the record
list, otherwise it does nothing. This works a bit like `add()` on
Sets.
Part-of: odoo/odoo#136308
Relational data in server formatter are:
- for one relation: None/false or object
- for many relations: list of objects or list of commands
The commands were:
- 'insert': to add a new item in a relational field
- 'unlink': to remove an item from a relational field
- 'insert-and-unlink': to remove an item from a relational field
- 'clear': to remove all items from relational field
There was a slight nuance between 'unlink' and 'insert-and-unlink'
at some point, but it becomes irrelevant with current code of model.
The name of the commands were hard to grasp what they actually mean
for the many relations.
This commit improves it by renaming 'insert' by 'ADD' and the 2
'unlink' commands by 'DELETE'. This makes it more apparent that
the data in 'ADD' refers to data of record to add in the relation,
while 'DELETE' refers to data of record to delete from the relation.
The 'clear' has been replaced by `False` value instead of a command.
Part-of: odoo/odoo#136308
This allows to define categories as also models, which allow
to register list of threads as relational fields, which in turn
simplify code readability and maintainability of these relational
data.
Part-of: odoo/odoo#136308
These `update()` functions are specific to a discuss record,
so it's best to be defined in the model rather than another
service.
Part-of: odoo/odoo#136308
Steps to reproduce:
- Install `website_crm` module (for test purpose)
- Go to `Contact Us` page on website
- Edit the page
- Change the submit button to create an opportunity instead, then save
- Fill the form and save
- Go back to CRM app and open the opportunity just created
- In the chatter, try to send a message
- Click on the checkbox of the suggested recipient (to enable it)
Issue:
- Email is displayed twice in the suggested recipients before click
(instead of name + email or just email if same as name)
- Email is set as default name in the opened dialog
Cause:
- Displaying email even if same as name
- Not setting the fields with default values (received from
`/mail/thread/data` rpc call)
Solution:
- Don't display email if same as name
- For the suggested recipient label (next checkbox) : set name with
default name value if name parsed from mail is same value as email
- For the default values in the opened dialog: set default values with
defaults received from `/mail/thread/data` rpc call
opw-3470295
closesodoo/odoo#135951
X-original-commit: 02ef0425a1f4ae30d846f6c57489cdebc3b4bbad
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
This commit ensures that changes in translated fields on a freshly
duplicated record will apply to all translation even when the user
language is not en_US.
Steps to reproduce:
-go to accounting -> configuration -> taxes in other language than en_US
-open any record in form view
-duplicate the record
-change the name of the record and save
-ensure that the name is the same in all languages
task-3339736
closesodoo/odoo#134481
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Prior to this commit, there was a spacing issue in large screens (eg. 4K
screen), the form view wasn't large enough and this created a big gap
between the form view and the chatter.
This commit adapts the form view to large screens.
task-3453381
Part of task-3326263
closesodoo/odoo#136454
X-original-commit: 1a995cad898283f6909506ba43d1692381b3d6ef
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
This commit changes the canOpen prop of the many2oneAvatar field to be
set to true only when in form view. The field will therefore stop being
a link in readonly when outside of form view.
closesodoo/odoo#136118
Signed-off-by: Michaël Mattiello (mcm) <mcm@odoo.com>
* = bus, calendar, im_livechat, hr, project_todo, sms, snailmail,
test_mail, web, website_livechat
The current implementation often led to tests relying on DOM structure
to properly target the correct element with the text.
It is now easier to simply check if a parent contains some text.
closesodoo/odoo#136295
Related: odoo/enterprise#47770
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This solves the following problem:
- Add 150 records with 2 activities each (ex. A call and a to do)
- Go to the activity view (ex.: event through the systray) and clear filter
- Only 50 of the 150 records are displayed (instead of 100)
- Going to the next page, only 2 are displayed (instead of ~50) (will depends
on the data already present)
Technical notes:
Not all activities were displayed because the search limit was applied on the
activity search instead of searching all activity related to the records.
The method fetchActivityData was doing half of the job because it was not
assigning the activity data fetch on the server to the instance variable
activityData, which was causing strange behavior when clicking on next page. To
simplify and correct the code, that logic has been moved to that method instead
of relying on the caller to do that assignation.
Task-3508744
closesodoo/odoo#135651
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
The activity view pager test is improved to use the actual get_activity_data
mock rather than checking that it is called with the right parameters. Thanks
to that, we also check that the activities are displayed. To ensure that the
pager influence only the records displayed and not the related activities, we
set up test records with 2 activities each and check that there are 2 times
more activities displayed than the number of records.
Task-3508744
Part-of: odoo/odoo#135651
`RecordSet` relations were rare and not worth having them. Turning
them into `RecordList` has no drawbacks.
To simplify many relations to a single relational field,
`Record.List()` was renamed to `Record.many()`, and `Record.Set()`
has been removed.
closesodoo/odoo#134884
Related: odoo/enterprise#47745
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
- Split d.ts files in `@types` folders that are close to
where the definitions of model & patches.
- Update jsdocs of discuss models to be fully type, including
model patches
When defining a new discuss model or a patch, should define a
`@types/models.d.ts` file. It must make use of module `models`
to define interface with model name:
```ts
declare module "models" {
import { Thread as ThreadClass } from "./thread_model";
export interface Thread extends ThreadClass {}
// necessary to propagate types to relations
export Models {
"Thread": Thread,
}
}
```
When defining a patch, should also define a `@types/models.d.ts`
to augment the interface of the model at hand:
```js
patch(Thread.prototype, {
setup() {
this.pinnedMessages = Record.Set("Messages");
}
});
```
```ts
declare module "models" {
import { Message } from "models";
export interface Thread {
pinnedMessages: Set<Messages>,
}
}
```
Part-of: odoo/odoo#134884
With the introduction of relational fields on discuss models,
which makes it easier to manage relations between discuss records,
we are incentivized to define all discuss relations in the models.
Some services managed relations with their own datastructure.
For example, pin_message service uses some Maps and Sets to model
messages pinned on channels. This is cumbersome to manage deletion
of records by hand... And also the name of attributes in the service
are too long, which shows they are not placed in the right context
(= in a dedicated service rather than in models).
This commit turn these relational data in pin_message service into
new relational fields on Thread and Message models.
```js
patch(Thread.prototype, {
setup() {
this.pinnedMessages = Thread.Set("Messages");
},
});
```
For type inference of the discuss model patches, we rely on module
augmentation of TypeScript with interfaces: we define an interface
for the patch of a given model, and we combine the type of this
"patch" interface with the original Model type in the listing of
Models types:
```ts
declare module "models" {
import { Persona } from "./persona";
import { Thread } from "./thread";
export interface Models {
"Message": Message,
"Thread": Thread & Partial<Thread_Patch>,
}
export interface Thread_Patch {
pinnedMessages: RecordSet<Models["Message"]>
}
}
```
That way, whenever we use a record e.g. from a one relational field,
we have proper typing for the patches:
```js
class Message {
originThread = Record.one("Thread");
}
message.originThread; // Thread & Partial<Thread_Patch>
message.originThread.pinnedMessages; // RecordList<Messages>
```
So whenever you adapt a discuss model patch or add a new one, make
sure to register new props in an interface of "models". Other devs
will be grateful towards you!
------
Note that the previous implementation of Relational fields on discuss
models was not robust enough with patching, notably with the
implementation details of `@web/patch()` function. Instead of using
`Object.defineProperty` on the model class prototype of each
relational field, we now use a proxy. This prevents the proxy hook
to be shadowed by the patches. This also allows to support a new way
to delete `Record.one()` relations with the `delete` keyword.
Part-of: odoo/odoo#134884
Introduce many relation by means of `Record.List()` and
`Record.Set()`. `Record.List` makes a data-structure similar
to JS Arrays, whereas `Record.Set` makes a data-structure similar
to JS Sets. Instead of storing objects, they store local ids
of records.
Note that some methods that return a collection return a native
collection, not a record collection. For example,
`RecordList.filter()` returns an array, not a `RecordList`.
This allow limiting using these special collections only when
handling relations, not collections in general.
Also note that the `Record.List` and `Record.Set` both accept either
native collection or record collection as setter argument.
```js
class Thread extends Record {
messages = Record.List("Messages");
followers = Record.Set("Follower");
}
// ...
thread.messages = messages;
thread.messages.push(message);
thread.messages.filter((msg) => !msg.isEmpty);
thread.followers.add(follower);
```
These relations allow to normalize discuss store further, improve
code readability with simpler field names, and also prepare for
future improvements on models such as simpler python formatters,
simpler Record.insert flows, relational fields that automatically
reflect on record deletion, etc.
Part-of: odoo/odoo#134884
This allow storing only the local id internally, and there are
automatic `get`/`set` to get the related record. This prepares
support of record deletion that would automatically delete
all relational fields, in a follow-up PR.
```js
class Message {
author = one("Persona");
}
```
Relational fields can be used to uniquely identify records:
```js
class ChatWindow {
static id = "thread";
thread = one("Thread");
}
```
Part-of: odoo/odoo#134884
This commit introduces a new message action to download
all files of the message, when the message contains more
than a single attachment.
This commit also do not show the delete icon on a file
when it's linked to a message without any text content, and
there's only 1 file attached to this message.
This is because deleting message and deleting the file means
basically the same, as deleting the attachment would mean the
message is empty, and empty messages are considered deleted.
We only show "Delete" of the message for clarity.
Task-3340653
closesodoo/odoo#132164
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before:
- sharing the screen stops sharing video and vice versa
after:
- If user starts to share screen at the same time with video sharing, a pip of video sharing appears on the call when user focuses on the sharing screen and vice versa. This pip is draggable and depends on the nearest corner to drag situation, will be located on the corner.
Task-3374606
closesodoo/odoo#130354
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit changes the behavior of the avatar card preview so that it
is now triggered on click instead of on hover and the previous behavior
of the click event (open chat) is therefore removed. It also adds the
functionality to the Message and Activity components of discuss so that
clicking on the avatar inside these components will also show the card.
It also makes sure that the id of the user is added to the persona even
if nothing indicates that it should.
task-3442819
closesodoo/odoo#131355
Related: odoo/enterprise#47084
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
The Dynamic placeholder was not opening properly in mail template since the wysiwyg OWL conversion.
Fix it and also fix the tour that should have detected this error.
The tour itself was not running properly.
task-3495254
closesodoo/odoo#135275
X-original-commit: df8532cffc74038db0faef36b5f43758e1bbdf43
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>