Commit Graph
632 Commits
Author SHA1 Message Date
Renaud Thiry 31262f27a5 [IMP] crm: remove set_lost_with_reason action
This cancels the changes added to f91782279a
for minor version 16.3 as the server action is completely removed
instead of being fixed in this.

The action is not removed in the upgrade as it is still technically
working. Though it should be considered deprecated.

------------------------------------

We remove the action that was used to conditionally call a window action

The action was not called consistently and added confusing indirection.

To maintain the current behaviour of only suggesting adding a loss
reason for opportunities.
We make the reason fields toggleable in the wizard, and hide them by
default for leads.

This leaves the user with the option to add a reason anyway, and serves
as a confirmation wizard if they don't want to.

-------------------

task-3272955

closes odoo/odoo#118494

Related: odoo/upgrade#4640
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-05-10 10:18:46 +02:00
Renaud Thiry 1a25988101 [IMP] crm: replace context with explicit default
Prior to this we used the context active_ids directly to determine
which leads to mark as lost in the lost reason wizard.

We now use a m2m field to store that value to make the behavior more
obvious and predictable, and to ease debugging.

task-3272955

Part-of: odoo/odoo#118494
2023-05-10 10:18:46 +02:00
amdi-odoo a8e9b25761 [IMP] crm: add monthly lead assignment count color
Draw attention to the monthly assigned lead count when
it is exceeding the limit by changing the text color
to orange.

Task-3204763

Part-of: odoo/odoo#115326
2023-05-05 12:43:59 +02:00
Victor Feyens f4ea6d3226 [FIX] *: strict api for main orm methods
Enforce strict types for returned values for
* create
* write
* unlink
* default_get

to make those methods more consistent and reliable.
Also make sure they can be called with empty self/values,
i.e. that they follow the same behavior as the base methods
defined in the main orm Model.

closes odoo/odoo#116809

Related: odoo/enterprise#38880
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-04-25 15:20:43 +02:00
Renaud Thiry 1196d470eb [IMP] mail, crm: reword notification actions
Prior to this notification actions are shown as such:
MODEL RECORD_NAME won | lost | settings

After they will be shown as such:
MODEL won lost settings RECORD_NAME

with the action links colored to match the company color.

The aim is to streamline the layout of e-mails and make actions
clearer.

task-3067315

closes odoo/odoo#106307

Related: odoo/enterprise#34284
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-24 10:20:12 +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
Martin Trigaux 69f911d994 [IMP] *: enforce usage of Markup in mail
When using message_post, the body format must be explicitly specified.
If html is expected, a Markup object should be used.
If text is given, the content will be escaped.

Before this PR:
message_post was unaware if the content of a message was HTML or
text. This lead to multiple situation where the content was
incorrectly considered as HTML and led to display errors.
In
  self.message_post(body="Hello %s!" % self.name)
if the name contained HTML, it would be evaluated.

In
  self.message_post(body="Contact Raoul <raoul@caramail.be>")
the email would not be displayed as considered as unknown HTML and
discarded by the sanitizer

Now each call must explict the type of content.
Use the escape() helper to properly combine Markup and translations.
It would also be acceptable to use Markup() to wrap a static
translation but escape is better as one can not guarantee the content
of a translation.

closes odoo/odoo#111850

Related: odoo/documentation#3612
Related: odoo/enterprise#36728
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-13 16:39:48 +02:00
std-odoo df9e9ec261 [IMP] digest, *: compute the KPI in batch
*: account, crm, hr_recruitement, im_livechat, point_of_sale,
   project, sale_management, website_sale

Purpose
=======
Now, the KPI are computed based on their `company_id` and not based
on the current company. If no company is set on the digest, we compute
it based on the current company.

The KPIs are computed based on their company. Most of the time, they
will all belong to the same company so we can improve the performance
by computing them in batch.

Task-2827996
See odoo/enterprise/pull/27658

Part-of: odoo/odoo#91945
2023-04-05 15:11:06 +02:00
Renaud Thiry f91782279a [IMP] crm: preserve action context for lost lead
Prior to this all of the context of the action called in the list
action was overriden. We now combine the action context with the
environment context.

This allows keeping the context from the XML action that defines the modal sizing.

task-3235932

closes odoo/odoo#116287

Related: odoo/upgrade#4493
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-04-04 17:03:28 +02:00
Louis Wicket (wil) 0c53d28133 [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#116167

Related: odoo/enterprise#38542
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
2023-03-24 12:50:13 +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
Thibault Delavallée b1695201b8 [PERF] crm: rewrite duplicates computation
RATIONALE

Duplicates computation on leads is slow when having a lot of leads. We can
simplify the heuristic to keep only relevant terms and use tailored fields
to find duplicates based on email and phone, to speedup the computation while
loosing few duplicates or avoiding false duplicates.

SPECIFICATIONS

We remove
  * an ilike on email_normalized (slow and exact matches are what really
    matters);
  * an ilike based on partner_name and contact_name (as lead is a contact
    oriented record, better optimize email and phone / mobile than names that
    are weak criterions);
  * an ilike on phone_mobile_search, which was searching on both fields
    phone and mobile;

Criterions are now

  * email domain exact match;
  * phone_sanitized exact match;
  * same commercial entity;

Main change is that only phone_sanitized is used for exact match. Partial
matching based on phone and mobile number is lost. That should not be an
issue as real duplicates should come with a complete phone or mobile number
and not partial numbers. First found in phone / mobile populates the phone
sanitized field, meaning if we have two different numbers, only one is used
for duplicate finding. This is considered acceptable.

Other main change is the removal of partner name / contact name search. Those
are weak criterions and did not return any explicit result when used internally.

Task-3142659 (Crm: Fix duplicate leads computation performances)

Part-of: odoo/odoo#112535
2023-03-09 10:51:37 +01:00
Thibault Delavallée 4ad44d1c45 [PERF] crm: add index on phone_sanitized
RATIONALE

Duplicates computation on leads is slow when having a lot of leads. We can
simplify the heuristic to keep only relevant terms and use tailored fields
to find duplicates based on email and phone, to speedup the computation while
loosing few duplicates or avoiding false duplicates.

SPECIFICATIONS

Index on "phone_sanitized" field of <crm.lead> is added as btree_not_null as
it is mainly used to search for direct matches. Partial searches are not the
main usage of this field.

Task-3142659 (Crm: Fix duplicate leads computation performances)

Part-of: odoo/odoo#112535
2023-03-09 10:51:36 +01:00
Jérémy Hennecart (jeh) a25ab87abe [IMP] crm: improve log meeting
When logging a meeting linked to a lead we now add a link to the
record. The link takes the place of the subject as it's the same
displayed value.

task-2984657

closes odoo/odoo#106546

Related: odoo/enterprise#32945
Related: odoo/upgrade#3974
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-06 17:47:18 +01:00
Raphael Collet 6ef3772847 [IMP] *: optimize code with search_fetch() and fetch()
closes odoo/odoo#112126

Related: odoo/enterprise#36782
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-03-05 15:12:57 +01:00
Raphael Collet e962860c6f [IMP] core: introduce search_fetch() and fetch()
This fulfills the goal of searching and fetching fields in a single SQL
query.  We introduce the new method search_fetch() for that purpose.
Also introduce method fetch() to fetch some fields for a recordset if
they are not in cache yet.

The call graph is as follows:

    search()        calls   search_fetch()
    search_read()   calls   search_fetch() and _read_format()
    read()          calls   fetch() and _read_format()

    search_count()  calls   _search()
    search_fetch()  calls   _search() and _fetch_query()
    fetch()         calls   _search() and _fetch_query()

The methods _search() and _fetch_query() are usually the ones to
override to implement business-specific logic.  The method _search()
returns a Query object to retrieve the records that satisfy the given
domain and are accessible for reading.  The method _fetch_query() uses a
Query object to retrieve fields from the database and store them in
cache.

Also use search_fetch() to save one query in search_read() and the
reading of one2many fields.

Part-of: odoo/odoo#112126
2023-03-05 15:12:55 +01:00
Raphael Collet 7e6cff5479 [IMP] core: search() and _search() no longer have parameter count
The parameter in search() is redundant with method search_count(), and
was making the calls less readable.

The method _search() is aimed at always returning a Query object.  The
method can therefore never return an integer, hence the removal of the
parameter.  This does not actually remove any functionality from the
method; counting result is simply given by using it differently.

Part-of: odoo/odoo#112126
2023-03-05 15:12:54 +01:00
Pierre-Yves Dufays a1d508f7ba [IMP] crm: provide crm_lead values for related res_partner creation
Define information taken from the lead when a partner is automatically
created from it. It avoids the user to enter the information twice and
automated partner creation now correctly takes information when possible.

Task-3024050

Part-of: odoo/odoo#105111
2023-02-23 14:53:56 +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
Julien Castiaux ad9bd90d7b [FIX] core, *: BaseModel overrides signatures
*: base, account, crm, hr, hr_attendance, test_access_rights

The various public methods of the ORM can be override in other models,
those overrides sometime don't implement the exact same signature as the
original method in the ORM. In this work we sanitize all the overrides
to ensure a better compatibility. The background objective is to make it
possible to call any public method using kwarg: `search(domain=[...])`.

* `search`, the first parameter was renamed from `args` to `domain` in
  0e9adf7 but the overrides were not updated.
* `invalidate_models` and `invalidate_recordset`, a new `flush=True`
  parameter was introduced in 9c3b9a4 but the overrides were not
  updated.
* `update`, there is a clash between the `update` method responsible for
  writing on a record and `update` in bus responsible to update the user
  presence. The bus method has been renamed so it doesn't clash with the
  ORM.

This sanitization comes with a new linter that verifies that all
overrides of BaseModel public methods share a compatible signature. The
linter has been disabled for `create`, `write` and `default_get` as too
many overrides don't respect the signature of BaseModel.

closes odoo/odoo#106999

Related: odoo/enterprise#34991
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-12-15 12:36:56 +01:00
Pierre-Yves Dufays 8bf004831f [IMP] crm: add index on phone and mobile fields
This index allows to improve performances of learch searching based on phone
and mobile fields. We currently use those fields are phone_sanitized is
based on both fields, which could lead to information loss and/not not
accurate results, notably when used to find duplicates.

Task-3007714

closes odoo/odoo#105873

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-12-12 13:18:46 +01:00
Pierre-Yves Dufays 33d23cc246 [IMP] crm: improve lead searching and duplicate detection
Accelerate duplicate lead detection by adding indexes on field involved in the
search.

In this commit we add trigram indexes on email_normalized, partner_name and
contact_name that are used a lot for searching and finding leads.

Task-3007714

Part-of: odoo/odoo#105873
2022-12-12 13:18:46 +01:00
Florian Charlier 987ca5c2b8 [REF] *: use f-strings
* = crm, mail, survey, test_event_full, website_event

To increase readability and performance, use f-strings where appropriate
(multiple concatenation +- formatting).

Note: Also removing unnecessary string concatenation with `%` for `(i)like`
in domains definitions.

Task-2977548
See odoo/enterprise#31156

closes odoo/odoo#99811

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-12-02 16:41:50 +01:00
Thibault Delavallée b4d24ab9c6 [FIX] various: use Markup for empty list help
Some cases require usage of Markup in order to correctly display HTML content
and avoid escaped or invalid statements.

Fix: in hr_recruitment, support default_job_id from context, easing display
of job's alias in empty list helper.

Task-3074357

closes odoo/odoo#106061

Related: odoo/enterprise#34139
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-11-21 15:56:57 +01:00
Thibault Delavallée 202153fb1b [IMP] mail, various: cleanup empty list help message overrides
Purpose is to cleanup code: stop using help parameter name (use help_message as
help is a keyword), try to call super(), ...

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-36879 (Mail: Support MultiCompany Aliases)

Part-of: odoo/odoo#105992
2022-11-18 13:59:53 +01:00
miad-odoo 5a65465dde [IMP] crm: add prorated recurring revenue in forecast view
Purpose:
In the Forecast view of the CRM module, when recurring revenues are activated,
they are not shown in the progress bar of each stage of the kanban view. Only
the prorated expected revenue (non-recurring) are shown. In the regular
kanban view, they are shown.

To display them, we extended the CrmKanban view, which already possesses this
behavior, since behaviors relevant to the CrmKanban view are also relevant
to the ForecastKanban view.

As for the forecast kanban cards, when recurring revenues are activated,
they show "regular" recurring revenues instead of "prorated" recurring
revenues. Expected revenues are prorated. This is misleading for users.
The goal is to show prorated recurring revenues instead of just
recurring revenues.

Task-2994146
Task-3006404

closes odoo/odoo#102037

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-10-25 13:03:04 +02:00
Denis Ledoux 59a78b344a [FIX] base, crm: format address mixin _get_view override
The same override of `_get_view` was done in `res.partner` and `crm.lead`
in order to call `_view_get_address`, to change the address format
of the partner and lead form.

The definition of `_view_get_address` was already shared between these
two models through the `format.address.mixin` mixin.
So, why not share the override of `_get_view` also in this mixin,
so only one override needs to be written, instead of two.

In addition to merge the code of the `_get_view` override
in `format.address.mixin`, also set the `_get_view_cache_key`,
so the partner and lead form are correctly cached by company,
in case multiple companies in a same db use different address views.

Before this revision, this wasn't the case for `crm.lead`,
which therefore leaded to a bug when two companies where
using different address view, and one company accessed the lead
form before the other, therefore caching its own view version
in the cache, re-used later by the second company when fetching
its own lead form.

This revision takes the opportunity to add a unit test for crm.lead,
to assert the expected form according to the company address.
There was already a test for res.partner, but not for crm.lead.
To avoid copy/pasting the unit for both models,
a common test class is created, re-used to test both res.partner
and crm.lead.

closes odoo/odoo#103438

X-original-commit: 7e4a8b77024af663c5555c6d56557e2c6136b24b
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-10-19 20:47:51 +02:00
Denis Ledoux af24e05429 [FIX] crm: remove no longer used code.
The code removed by this revision was initally introduced in
odoo/odoo@126ba0a9a8

The `_get_view` override introduced relied
on the context key `opportunity_id`,
which was set in the crm.phonecall form view with
```xml
<field name="opportunity_id" on_change="on_change_opportunity(opportunity_id)" context="{'opportunity_id': opportunity_id}"/>
```
as you can see in the above mentioned revision.

This above node was removed 7 years ago in revision
https://github.com/odoo/odoo/commit/ff2b14d4c3c5aaa62418b527585d0a19e98a23de#diff-892062d6151c1e1c1cb5f6c09035df1d5ae6d5a71f7558aacfdc8cf62627bf5fL138
Therefore making pointless the code about it in the `_get_view`
override.

In addition to this clue to make sure the override is pointless,
checking the code, we can see it relies on `get_formview_action`
to set a different view according to the result of `get_formview_action`.

Since revision
https://github.com/odoo/odoo/commit/e28d3aa4d3851d72deba08c236072d002f83216a#diff-595d3dbbabdc4f766a380a320c1c1a43b143385bc7487c7275e80f76a9fbabc2L1224
the override of `get_formview_id` is removed,
therefore making `get_formview_action` of `crm.lead` completely default
(as there is no override of `get_formview_action` either in crm.lead,
nor any dependent method)

We can therefore assume this code was useless,
at least in standard odoo,
and can therefore be removed.

X-original-commit: 82c2f4b13034c16ca5546afd777150ecb4d8ad9b
Part-of: odoo/odoo#103438
2022-10-19 20:47:51 +02:00
std-odoo 17335f13fd [IMP] crm: add a properties field on lead
Purpose
=======
To be able to customize the working flow on the lead, based on their
team, we add a properties field on leads, whose definition is stored
on their team.

Include the properties value in the merge message to keep the history
of the properties value if they have been overwritten during the merge
process.

Task-2965523

X-original-commit: 4722cc4b1fb027b7b9d731c3b206656588071360
Part-of: odoo/odoo#101487
2022-09-28 19:31:49 +02:00
Pierre-Yves Dufays a577afc75e [IMP] account,crm,project,purchase,sale,[test_]mail: improves activity notif
Ease the understanding of the notifications sent when users are assigned to an
activity or a model (task, lead, ...).

Technical note:
- the customization of data sent to the email layout template (here subtitles)
should be done by overriding
mail_thread._notify_by_email_prepare_rendering_context on the model.
But in this case, we send an activity (ex.: todo) for a model (ex.: crm.lead)
which involves 2 models. Data from both models must be sent to the template
layout. To solve this problem an optional parameter to
mail_thread.message_notify has been added: subtitles. This allows the
caller which knows about the 2 models to set the values for subtitles for
the template.
- mail_activity._render_notify_header has been added to render the subject and
subtitles using the language of the recipients through the context lang
variable.
- a generic mail notification template has been added and the specific
mail_notification_paynow has been derived from it as the only change is the
handling of the signature.

Task-2801600

Part-of: odoo/odoo#88466
2022-09-14 19:13:44 +02:00
Xavier-Do b1b66b82a6 [FIX] crm, project: fixing some non-total order
Non total order can lead to randomized order in some case, making some
test behaviour random and/or difficult to debug.

Adding some fallback 'id' order shouldn't hurt

closes odoo/odoo#99324

X-original-commit: 6e40e5fe775273a2d3a968ac113cbeb578318dd1
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-08-31 21:12:12 +02:00
Pratik Raval bb24757d08 [IMP] crm: detect leads based on similar phone/mobile number
Currently, the 'similar lead detection' mechanism only considers email,
contact name, and partner name while finding duplicate leads in CRM.

After this commit, it will also consider the mobile/phone number for
the same. Note that the mobile numbers and phone numbers both will be
matched with each other while finding duplicate leads.

Task-2817884

closes odoo/odoo#88372

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-08-25 19:56:48 +02:00
bve-odooandXavier Alt 9d1cb826c7 [FIX] crm: missing company on default crm team on incoming emails
Commit 0edc854a84 introduces a company check on the salesperson, partner
& team on the lead model.

However 184334a97d1ccd19b9a7266a13ff51531d22cff4 was not able to find the expected company on a lead
created by email when the team did not have a company set. Which is the case by
default for the following crm.team:

  - Sales (3ad1867ea4)
  - Pre-Sales
  - Website (3ad1867ea4)
  - PoS

Having added the company check introduce an unexpected error:
  "Incompatible companies on records:\n-
  '[header subject of email]'
  belongs to company False and 'Customer'
  (partner_id: '[name in header from of email]')
  belongs to another company."

Error was hard to spot as the db logs are reporting that the routing of the
email was correctly done. But script to send eml using xmlrpc showed the error.

In this commit we fix the issue by removing the custom code trying to set
a company in ``message_new`` method of crm.lead. Indeed as it is a computed
field with a complete heuristic it is easier to let the ORM do its job and
remove that wrong value. It is now correctly computed as with any other
lead.

opw-2862509
opw-2783249
opw-2832435
opw-2881841

closes odoo/odoo#98746

X-original-commit: 2fec9c53314ef3f7c7e3305a6ee2417018d70ce5
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Xavier Alt <alt@odoo.com>
2022-08-24 09:29:27 +02:00
Florian Charlier 6d28b10bb5 [IMP] crm: improve lead company computation performance
# Purpose
Avoid unnecessary steps to compute/assign lead company.

Task-2824913
See odoo/odoo#97136

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-08-16 09:18:56 +02:00
Florian CharlierandFabio Barbero 6f81b5e0a8 [FIX/IMP] crm: allow more specific lead default company
# Purpose

Take into account the current company when creating a new lead if not defined
earlier.

# Specifications

If there is no company provided by the sales team and the user belongs
to several companies and several companies are allowed by context,
we preferentially take the current company over the user's company if allowed.

# Additional considerations

This commit
* builds on the multi-company fix brought by e5f35a60 avoiding the restricted
access error when setting to the user's base company if not allowed by context,
but will also allow to first preferentially use the current company instead of None.
* Complete tests

Task-2824913

X-original-commit: ce62780153183545ba423a7a8d945d9665cdc50e
Part-of: odoo/odoo#97136
Co-authored-by: Florian Charlier <flch@odoo.com>
Co-authored-by: Fabio Barbero <faba@odoo.com>
2022-08-16 09:18:56 +02:00
KareemAbuzaid 205df4df9c [FW][FIX] crm: remove res_model/res_id from meetings when unlinking leads
With Calendar and CRM installed:
- Create a lead and a meeting related to that lead.
- Delete the lead.
- Go to the meeting form view from the calendar App.
- Click the Document action button and nothing will take place.

After this commit if you delete the lead, you will no longer be able to the
see the button as document information is correctly reset.

Task-2917174
Closes odoo/odoo#42450
Closes odoo/odoo#47497

closes odoo/odoo#96190

X-original-commit: 71ccb7dae43a13521f2a290ce76cafd8fb5b963f
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-07-18 19:55:39 +02:00
Thibault Delavallée 9cd840f25b [FW][FIX] crm: correctly reset date_closed when going out of won stage
Probability is not always given to write, hence date_closed is currently not
always reset. Indeed as it is a computed field it can be updated after stage
update, without being explicitly in values.

In this fix we consider that going out of won stage without any other hints
on probability is like being not won anymore, therefore resetting date closed.

Task-2917116
Closes odoo/odoo#93704
Closes odoo/odoo#93704

X-original-commit: 1cf1b572b10bfbd02581c12f89824a028c4f23e6
Part-of: odoo/odoo#96190
2022-07-18 19:55:38 +02:00
Lorenzo Ciciotti e0898fd4d8 [FW][FIX] crm: update lead language based on partner
Onchange could also populate the lang field of the lead when updating the
customer.

Partial backport of odoo/odoo@65bb3a5710

Task-2917174
Closes odoo/odoo#78715

X-original-commit: e0e1e402a6c40ed89bc5a11671e364a67e93a176
Part-of: odoo/odoo#96190
2022-07-18 19:55:38 +02:00
Raphael Collet c2293ca70c [FIX] crm: add missing compute_sudo on crm.lead.company_currency
The field `company_currency` is indirectly used by portal users, and
does not seem to be a security concern in that context.  But as portal
users cannot read companies, the field should be computed in superuser
mode.  This apparently used to work by accident in the past...

closes odoo/odoo#95325

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-07-14 22:45:44 +02:00
Abdelouahab (abla) c91797a41d [FIX] crm : set default value to company_currency
To reproduce
============

Have two companies with different currencies,
Create a lead in the first compnay => the expected revenue has the company's currency
Create a lead in the second company => the expected revenue doesn't have the currency

Purpose
=======

in v15 the `company_id` has became computed, but the compute method in some scenarios
doesn't set the `company_id`.
`company_currency` is related to `company_id`, so when `company_id` is not set `company_currency`
is also not set which occures this issue.

Specification
=============
To solve the issue, the field `company_currency` is computed now, and we give it the value of the active
company if `company_id` is not set.

opw-2862410

closes odoo/odoo#95484

X-original-commit: de59391caede72624fddcb01ba3565884c4e5574
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-07-07 10:15:59 +02:00
Mitul Shah f0b7600314 [IMP] base, crm: set salesperson and team on partner from parent
This commit does below improvements:

1/ If salesperson and sales team are set on an individual partner, we propagate
   those to parent company being created from m2o of the form view.
2/ If the existing parent company is manually linked to an individual partner
   being created, and salesperson and sales team are not set on the individual,
   we set those values from the linked parent (if set on the parent).

Task-2636290

closes odoo/odoo#78696

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-06-24 13:49:07 +02:00
Laurent Desausoi (lade) 70c22cac0d [FIX] crm: set partner company on lead when resetting company
In a multi-company environment, when we transform a lead (which has no
salesperson) into an opportunity, we get an error if the customer has
a company set.

To reproduce the issue
  1) Create a new company
  2) Create a Lead for a customer with the Company set
  3) Remove the Sales Team
  4) Set the company on the Lead
  5) Convert to an opportunity and you will see an error showing up

Solution

A previous commit (1fad826743de9c8f916ef083e8de453212df6959) adapted the `_compute_company_id`
computation in which a case was forgotten (the case described here-above).
The fix was to force the `company_id` to the one of the `partner_id` if it
has one.

OPW-2805181
Task-2888330

closes odoo/odoo#88108

closes odoo/odoo#94493

X-original-commit: fc3bb66a863cd3ff8c92d70dd43146a5610a4a43
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-06-24 10:30:06 +02:00
Fabio Barbero dc66b7aec3 [IMP] mail, various: use overridden method in message_notify
Purpose
=======

In message_notify, when called on a recordset, call model methods instead of
base one defined on MailThread. This allows to use internal methods overrides.

Also perform some linting on calls to ``message_notify`` in order to better
spot calls, parameters, ...

Task-2852908

closes odoo/odoo#92868

Related: odoo/enterprise#28038
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-06-18 10:23:03 +02:00
Umesh Gupta 273a0b4a7a [IMP] crm: display correct team count while creating a stage
Currently, when creating a new stage, even if there are sales team(s)
available, the `team_count` always displays zero, because it is a
computed field but is not dependent on any other field.

This commit improves the behavior by small hack, which makes the
compute method dependent on `team_id` field so that it can be
triggered while creating a record.

taskID-2819559

closes odoo/odoo#88738

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-06-15 09:59:57 +02:00
MAHAMADASIF ANSARI cc062596f4 [IMP] crm: improve helper string
This commit improves the helper string for 'My Pipleline' a bit in case
the logged in user has not joined any sales team yet. Also, if user is
having enough rights to access 'Configuration >Sales Team' menu, the
helper string will now contain a link to this menu as well.

task-2846401

closes odoo/odoo#91304

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-06-14 13:45:56 +02:00
mafo-odoo 28b41a3246 [FIX] crm: no date_closed update between 2 won stages
Steps to reproduce:
	install crm and change a lead between two won
	stages

Expected behavior:
The date_closed does not change

Current behavior:
The date_closed changes

opw-2839298

closes odoo/odoo#92534

X-original-commit: 0c55c0d31021abe966c453c4827d5873a7af485c
Signed-off-by: Fockedey Martin (mafo) <mafo@odoo.com>
2022-06-01 08:51:46 +02:00
Raphael Collet 6cf8db906f [REF] *: adapt code to new flush API
closes odoo/odoo#87527

Related: odoo/upgrade#3497
Related: odoo/enterprise#26939
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-05-25 18:00:47 +02:00
Christophe Monniez 65c8814a2f [FIX] various: replace deprecated currentThread method
CurrentThread is now really deprecated in Python 3.10 ... Time to
change.

Part-of: odoo/odoo#91927
2022-05-23 08:29:52 +02:00
Fabio Barbero fc79bd1e0e [IMP] sm modules: "neutralise" genders
Purpose
=======
Change all masculine nouns in Odoo's code to neutral nouns (when
possible), making sure that demo data is correctly handled. This is
particularly important since our code is open source, and nowadays lots
of machine learning models are trained on open source repositories.

With this small change we contribute to training more "fair" models, and
teaching models that "employee" or "user" != "he".

This also affects some text visible by the user, hence making it more
inclusive for Odoo users.

Task-2853046

closes odoo/odoo#91292

Related: odoo/enterprise#27302
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-05-16 10:09:32 +02:00