Not entirely sure about TestAllocationRights. For TestEsEdiCommon
issue is quite obviously that it's inherited by tests which are
external, so when the `post_install_l10n` tag gets applied those tests
get run during "normal" l10n and they break.
closesodoo/odoo#98814
Related: odoo/enterprise#30825
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
The test is currently disabled on runbot and breaks every night. Update the
counter to check if it is still random.
Task-2925606
closesodoo/odoo#99305
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
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
closesodoo/odoo#88372
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
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
closesodoo/odoo#98746
X-original-commit: 2fec9c53314ef3f7c7e3305a6ee2417018d70ce5
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Xavier Alt <alt@odoo.com>
This revision is to make uniform the behavior of the `groups` attribute
on the Python model fields
and on the node in the view architecture.
In both cases, remove the node from the view completely.
Before this revision,
in a back-end view:
- In the Python model, if a field has the `groups` attribute set
and the user is not part of
the groups, the field is removed, completely, from the view.
- In the view architecture, if a node has the `groups` attribute set
and the user is not part of
the groups, the node is made invisible (not completely removed, just
made invisible).
in a front-end view:
- if a node has a "groups" or "t-groups" set and the user
is not part of the groups, the node is removed from the view.
So it's 2/3 cases removing nodes restricted to a group.
and 1/3 case making invisible nodes restricted to a group.
It's simpler to have a uniform behavior for the 3 cases,
simpler to understandard for developers.
In addition, this will help for the goal to cache back-end views.
It makes possible to convert views using the `groups_id` field
by moving the content of these views directly
in the view to which they add content which is suppose to be completely
removed when the user has not the according group.
By getting rid of the `groups_id` many2many field on `ir.ui.view`,
it makes possible to cache the view architecture without
requiring to use the groups in the cache key.
Currently, if we want to cache the view architecture,
it would be required to use the intersection of the user
groups with the `groups_id` groups of the view,
making it costly to compute the cache key,
therefore altering the performance point to cache the view
architectures.
closesodoo/odoo#95729
Related: odoo/enterprise#29592
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
PURPOSE
Have more reliable tests.
Better spot side effects coming from sub addons.
Lessen non deterministic counters due to local db.
SPECIFICATIONS
Make crm, event and mail performance tests post install.
Update query counters with
* local values (install module only with enterprise activated);
* community / enterprise runbots (if value is different);
* some notes on non deterministic issue if known;
Task-2925606
closesodoo/odoo#96446
Related: odoo/enterprise#29726
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
# 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>
TLDR:
* invoices are implemented using computed methods instead of onchange
* the synchronization only happens when switching tabs in the Form view
to improve perfs.
_______________________________________________________________________
The whole engine of the synchronization of Invoices to the Journal
Entries has been refactored
* by using computed fields instead of onchange functions
* by synchronizing only from invoice to journal entry in `create` and
`write`
* by saving when switching tabs on the Invoice form, to synchronize
before showing the values
This comes with numerous advantages:
* no need to call the onchange methods manually
* no need to use the Form emulator to build invoices (i.e. EDI, OCR,
intercompany, ...)
* the performance for invoices with many lines improves drastically, going
from 2 minutes to 4 seconds to create an invoice with 500 lines
* the model is more declarative, we can now see how the values are computed
instead of having the values being copied from various places.
* remove the hack in `onchange` that disabled the recursivity of it,
which was unexpected and needed to be managed manually in all the
onchange methods
This means that:
* Some fields need to be exclusively computed on journal entries values
or invoice values, more specifically the Tax Summary widget.
It is now
- computed from entry lines, when opening the view
- computed from invoice lines when changing those, because the tax lines
will need to be recomputed anyways, erasing previously set values
- set with an inverse function when saving; after the sync has been done
* Some possible operations previously possible have been dropped.
(i.e. look at the removed test test_in_invoice_line_onchange_accounting_fields_1)
This is because such a behavior was undefined (how is changing the balance going
to affect the unit price? How is the amount currency going to affect it?)
_______________________________________________________________________
Implementation Details
----------------------
The "dynamic lines", meaning the payment terms and the tax lines are now
only created in the `create` and `write` functions.
In order to reduce code duplication, it has been implemented using
context managers used in both `account.move` and `account.move.line`
These context managers help comparing the values before/after, acting
like a local `onchange`, but getting benefit from the dirty flags from
the `compute` dependences.
This is relying on computed fields on the move (`needed_terms`) and on
the lines (`compute_all_tax`) which contain the values needed for the
related move.
Depending on the needed values and the existing values (`term_key` and
`tax_key`, respectively) the context manager will determine what needs
to be created/updated/deleted.
Some related changes are to produce a `dict` instead of a `str` for the
`tax_totals` (previously `tax_totals_json`) fields, by simplicity to
reduce the complexity of IO, and simplicity of debugging, because the
logic of the field needed to change (cannot be computed at the same time
anymore since it needed the lines to be synced)
By simplicity, and also because it makes more sense, some boolean fields
have been merged into `display_type`:
* `is_rounding_line`
* `exclude_from_invoice_tab`
* `is_anglo_saxon_line`
The `price_unit`, `quantity` and other "invoice fields" are now not set
anymore on lines that are not product lines since it didn't make any
sense to have it.
Performances
------------
You have to keep in mind that a simple `create` didn't compute a lot of
fields, for instance not taxes were set, no payment terms,...
Now it does.
```python
import random
from timeit import timeit
from odoo import Command
domain = [('company_id', 'in', (False, self.env.company.id))]
products = self.env['product.product'].search(domain).ids
partners = self.env['res.partner'].search(domain).ids
taxes = self.env['account.tax'].search(domain).ids
def create(nmove, nline):
self.env['account.move'].create([
{
'move_type': 'out_invoice',
'partner_id': random.choice(partners),
'invoice_line_ids': [
Command.create({
'name': f'line{i}',
'product_id': random.choice(products),
'tax_ids': [Command.set([random.choice(taxes)])],
})
for i in range(nline)
]
}
for j in range(nmove)
])
# After | Before
print(timeit("create(1, 1)", globals=globals(), number=1)) # 0.11 | 0.09
print(timeit("create(100, 1)", globals=globals(), number=1)) # 2.76 | 2.50
print(timeit("create(500, 1)", globals=globals(), number=1)) # 14.56 | 12.34
print(timeit("create(1, 100)", globals=globals(), number=1)) # 1.03 | 5.52
print(timeit("create(1, 500)", globals=globals(), number=1)) # 3.99 | 125.02
print(timeit("create(50, 50)", globals=globals(), number=1)) # 19.44 | 79.55
```
Another metric that can be used is running the test suite with
`--test-tags=/account` (only `account` installed)
* before: 404s, 267127 queries (366 tests)
* after: 318s, 232125 queries (362 tests)
Why this commit title?
----------------------
Someone told me that this was the perfect way of naming your commits.
c04065abd8
task-2711317
closesodoo/odoo#96134
Related: odoo/upgrade#3715
Related: odoo/enterprise#29758
Signed-off-by: Laurent Smet <las@odoo.com>
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
Closesodoo/odoo#42450Closesodoo/odoo#47497closesodoo/odoo#96190
X-original-commit: 71ccb7dae43a13521f2a290ce76cafd8fb5b963f
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
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
Closesodoo/odoo#93704Closesodoo/odoo#93704
X-original-commit: 1cf1b572b10bfbd02581c12f89824a028c4f23e6
Part-of: odoo/odoo#96190
Followup of odoo/odoo@6e46d4cd07 and odoo/odoo@1f81d60de6
Also fix a test failing with python 3.8. Message-ID is formatted using chevrons.
Task-2917174
X-original-commit: 26c88387f24b8515dc74c24594f203e3953b8a39
Part-of: odoo/odoo#96190
Onchange could also populate the lang field of the lead when updating the
customer.
Partial backport of odoo/odoo@65bb3a5710
Task-2917174
Closesodoo/odoo#78715
X-original-commit: e0e1e402a6c40ed89bc5a11671e364a67e93a176
Part-of: odoo/odoo#96190
In the web client, in a real use case, it's not possible
to write on fields which are invisible,
as it's not possible to write on fields which are readonly.
This is a first step in the goal to change the behavior
of the `groups=` attribute in the back-end views,
to remove them for the view instead of making them invisible.
This is mainly to reduce the diff of the revision that will introduce
the mentioned above behavior change.
As nodes with `groups=` will be removed from the view
when the user doesn't have the group, it's no longer possible
to set a value on a field having a `groups=` the user doesn't have
in the `Form` test class, as the field will no longer be at all in the
view.
However, these unit tests shouldn't have been able to set values
on invisible fields in the first place.
This revision therefore aims to correct the unit tests setting value
on fields which were invisible because the user executing the
test was not part of the required group(s) for these fields
to be visible in the view.
closesodoo/odoo#94337
Related: odoo/enterprise#28936
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
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
closesodoo/odoo#95484
X-original-commit: de59391caede72624fddcb01ba3565884c4e5574
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
In module mail, invalidating 'message_ids' on a mail thread also
invalidates its inverse field 'res_id' on messages. If you haven't
flushed it before, your cache will be inconsistent, as shown by the test
/mail:TestMailgateway.test_message_process_bounce_records_channel.
In module purchase_stock, add depends on report.stock.quantity. This
ensures that when the model is queried after changes in other models,
the data on which the SQL view depends is flushed to the database before
querying that model's table.
closesodoo/odoo#66938
Related: odoo/enterprise#16722
Signed-off-by: Raphael Collet <rco@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Use case
--------
A sale user convert a lead to an opportunity, this lead has duplicates.
The wizard will convert and merge the lead. At the end of the process
the duplicated lead are delete.
Issue
-----
Before this commit the user get an access error because he cannot delete
leads
Since they can merge lead using the action "Merge" it's not consistent
and sales user should be able to merge lead during the conversion
as well
closesodoo/odoo#94699
X-original-commit: 3b79867460d9a407fba094fe1cd719d8d52011ef
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Thibault Francois <tfr@odoo.com>
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
closesodoo/odoo#78696
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Currently using a customer with a company set on a lead without company
crashes, as it keep a void company on the lead. This is not compatible
with the company set on the partner itself.
OPW-2805181
Task-2888330
X-original-commit: 51be6cab5c4437ef56de5d1b25c0ba8486d25291
Part-of: odoo/odoo#94493
Update to latest runbot state, at least for tests known to be
deterministic.
Notably mail tests are lower than before, probably due to odoo/odoo#73271closesodoo/odoo#93470
X-original-commit: 6118ecba8d807ac5ebc69ae4877e1f202b0daeb1
Related: odoo/enterprise#28308
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
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
closesodoo/odoo#92534
X-original-commit: 0c55c0d31021abe966c453c4827d5873a7af485c
Signed-off-by: Fockedey Martin (mafo) <mafo@odoo.com>
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
closesodoo/odoo#91292
Related: odoo/enterprise#27302
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
``CRM`` application calls ``phone_get_sanitized_number`` on partner model to
synchronize lead values to its partner values. This method is defined in
``mail.thread.phone`` mixin. ``Partner`` model inherit from this mixin in
``SMS`` application which is auto install after mail and IAP. If this app
is removed, code is not reachable anymore and lead synchronize fails.
How to reproduce
* install CRM and its automatically installed dependencies;
* uninstall IAP;
* run lead unit tests -> synchronize crashes due to missing method as partner
does not inherit from the mixin anymore;
In this commit we define the missing methods on Partner model directly into
phone_validation. In SMS the inherit order is fixed so that the mixin method
takes over the manually defined one.
Fixes#79460.
X-original-commit: eefac25da8d8a01e5f7da8fab35810da402c0bd9
Part-of: odoo/odoo#88970
Co-authored-by: Thibault Delavallée <tde@odoo.com>
It looks like in enterprise, the value of has_group is already in cache
This will lead to an additional query when checking mail.message
creation access rights in community.
This commit warmup the user _has_group ormcache to avoid an
inconsistency between community and enterprise
Stack of the additional query:
```
sql('SELECT 1 FROM res_groups_users_rel WHERE uid=%s AND gid IN\n ... (SELECT res_id FROM ir_model_data WHERE module=%s AND name=%s)') (SELECT 1 FROM res_groups_users_rel WHERE uid=29 AND gid IN (SELECT res_id FROM ir_model_data WHERE module='base' AND name='group_user'))
execute (odoo/addons/base/models/res_users.py (self._cr.execute("""SELECT 1 FROM res_groups_users_rel WHERE uid=%s AND gid IN):847)
_has_group (odoo/tools/cache.py (value = d[key] = self.method(*args, **kwargs)):90)
lookup (called at <decorator-gen-111> ():2)
_has_group (odoo/addons/base/models/res_users.py (return self.with_user(uid)._has_group(group_ext_id)):832)
has_group (addons/mail/models/mail_message.py (if not self.env['res.users'].has_group('base.group_user'):):380)
check_access_rule (odoo/models.py (records.check_access_rule('create')):4321)
_create (odoo/models.py (records = self._create(data_list)):4087)
create (odoo/api.py (return create(self, arg)):410)
_model_create_multi (called at <decorator-gen-16> ():2)
create (odoo/addons/base/models/ir_fields.py (recs = super().create(vals_list)):613)
create (odoo/api.py (return create(self, arg)):410)
_model_create_multi (called at <decorator-gen-68> ():2)
create (addons/mail/models/mail_message.py (messages = super(Message, self).create(values_list)):599)
create (odoo/api.py (return create(self, arg)):410)
_model_create_multi (called at <decorator-gen-193> ():2)
create (addons/mail/models/mail_thread.py (return self.env['mail.message'].create(create_values_list)):2132)
_message_create (addons/mail/models/mail_thread.py (new_message = self._message_create(msg_values)):1874)
message_post (addons/rating/models/mail_thread.py (message = super(MailThread, self).message_post(**kwargs)):14)
message_post (addons/mail/wizard/mail_compose_message.py (ActiveModel.browse(res_id).message_post(**post_params)):321)
_action_send_mail (addons/mail/models/mail_thread.py (return composer._action_send_mail(auto_commit=auto_commit)):1964)
message_post_with_template (addons/mail/models/mail_thread.py (return record.message_post_with_template(False, **kwargs)):1929)
_message_compose_with_view (addons/mail/models/mail_thread.py (self._message_compose_with_view(views_or_xmlid, **kwargs)):1933)
message_post_with_view (addons/crm/models/crm_lead.py (opportunities_head.message_post_with_view():1336)
_merge_opportunity (addons/crm/models/crm_team.py (merged = lead_duplicates._merge_opportunity(user_id=False, team_id=False, auto_unlink=False, max_length=0)):578)
_allocate_leads_deduplicate (addons/crm/models/crm_team.py (assign_res = team._allocate_leads_deduplicate(candidate_lead, duplicates_cache=duplicates_lead_cache)):507)
_allocate_leads (addons/crm/models/crm_team.py (teams_data = self._allocate_leads(work_days=work_days)):304)
_action_assign_leads
test_assign_perf_duplicates (odoo/tools/misc.py (return func(*args, **kwargs)):792)
```
task-2796579
Part-of: odoo/odoo#85525
The performances tests in TestLeadAssignPerf have a margin for queries
because of some randomness in query counts.
Those margins avoid random failures but will hide small increments,
making the query count fail randomly in future build. This margin also
makes the update of query counts difficult.
This commit tries to identify the source of this randomness and proposes
some fixes.
Sources of randomness
=====================
Comparing different executions, the query can differ on two point:
1. During the flush, while updating the lead
1.1 the written user_id can vary (~1 additional query)
1.2 the written convert_date can changes (~4 additional queries)
1.3 the written date_last_stage_update can change (~1 additional query)
2. during _handle_salesmen_assignment
2.1 write/_message_auto_subscribe can change? (~1 additional query)
the point 1.2 and 1.3 can be easily reproduced, adding sleep,
especially a 0.1 sleep in convert_opportunity
Writing different values for date will lead to multiple execute
when flushing the records:
the orm cannot group records with different values
Proposed fixes
==============
A. Use `cr.now` instead of `fields.datetime.now`
Using the transaction time will avoid randomness linked to the change of
second during the transaction. This will fix 1.2 and 1.3
B. Sorting members
The members comes from a o2m and the order is not deterministic.
During the test with a subset of lead (10 instead of 100),
the two last members ('Martin Sales Manager' and 'Orteil Sales Own')
can come in different orders, leading to different user_id set on lead.
Instead of 4 different users, the lead where sometimes dispatch on
5 different users with this setup. (5 queries in flush() instead of 4)
This is fixed by adding a complete order (adding id) on crm.team.members
This will solve 1.1
C. The leads are also ordered by id if they have the same probability,
since it shouldn't hurt and make the search more deterministic.
2.1 was fixed by B or C or is not fixed, not sure anymore.
task-2796579
Part-of: odoo/odoo#85525
There were inconsistencies in the calls to `_render`.
* the view context could contain information that misled developers.
Indeed, the context and value of the view are not supposed to be found
in the rendering. Thus by calling `ir.qweb` with the name of the
template, we ensure that there is no unwanted information and in
addition the cache key is that of the name of the template which saves
a query.
* the context used for rendering was modified by a method on
`ir.ui.view`, except this is not information used by this model. There
is now a `_prepare_environment` method residing on `ir.qweb`. This
method allows to modify the value dictionary as well as the context in
which the rendering will be done. This preparation of the data as well
as my security check is done only once per rendering. This also saves
some queries
* Freeze options for rendering were inconsistent. It could be that
options on which rendering depends were not part of the cache key. Thus,
depending on the user who generated the generation of the rendering
function, there was or was not information in the template. For example
for automatic branding. This is no longer possible, because it is the
context that is used. The options serving as a cache key are only
recorded for information (for the profiling system for example). A
simplification of the `ir.qweb.field` models could be made.
The report rendering and call `ir.qweb` instead of `ir.ui.view`.
Part-of: odoo/odoo#85110
The test `test_assign_count` may fail randomly leading to the error:
```
self.assertEqual(self.sales_team_1_m3.lead_month_count, 14)
AssertionError: 12 != 14
```
Since BUNDLE_HOURS_DELAY is 0 (during tests), the domain becomes
`[('create_date', '<', fields.Datetime.now()]`
Depending of the time when the transaction starts, and the tests is
executed, the domain could match more or less records when executed one
second earlier or later. This is especially True for single module build
where there is less logic and the execution is faster. The domain may be
tested earlier and match less records.
This error can be reproduced deterministically by setting
`BUNDLE_HOURS_DELAY = 1/3600`
A fix could be to ignore ignore the create_date domain if the
BUNDLE_HOURS_DELAY is 0, we want to match all records in theory
(except if some of them are created in the future...)
The chosen solution is to use cr.now and use a <= instead.
Some assertions where also added to the test in order to identify why
the count was different and give a more precise message when it fails.
```
AssertionError: Lists differ: [] != ['TestLeadInitial_0000', 'TestLeadInitial_[97 chars]006']
Second list contains 6 additional elements.
First extra element 0:
'TestLeadInitial_0000'
- []
+ ['TestLeadInitial_0000',
+ 'TestLeadInitial_0001',
+ 'TestLeadInitial_0002',
+ 'TestLeadInitial_0004',
+ 'TestLeadInitial_0005',
+ 'TestLeadInitial_0006']
```
task-2796579
closesodoo/odoo#87107
X-original-commit: 4a5b68f05c57ba36560d43733dfd04b67c3297a8
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Expected Behaviour
When creating a contact from a lead with an unactive language, Odoo should
replace this language with the parent's language or the DB language.
Observed Behaviour
Since saas-15.1, when you create a contact from a lead email adress,
the contact is created with the lead's language, even if it's not active,
which give an error.
Reproducibility
This bug can be reproduced following these steps:
1. Set an uninstalled language on a lead (two choices):
a. Select an uninstalled language on a lead (this is what happens with
the trial creation, and how to reproduce it via the interface)
- install 8 languages in order to activate the "Search More..." link in
the Language select field of a lead
- on a lead which doesn't have a Customer yet, in the Language, "Search
More...", filter with Active = False, and select an uninstalled language
b. Install a language, select it on a lead with no Customer, and uninstall
the language
2. On the lead, in its chatter, open the Send Message and check the checkbox
next to its email => it should open a popup
3. Validate the popup => there is an exception in saas-15.X, and not in 15.0.
Related Issues/PR
- opw-2745841
closesodoo/odoo#85992
X-original-commit: c9b6ec91a87a4ad007287d978adc34332a97f8da
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Still having sometimes a test failing due to extra queries...
closesodoo/odoo#85929
X-original-commit: 34eebe66f12bf43dbf7c16800e177907fe39f2ba
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Bug
===
If we
1. Open a lead with an email but without partner
2. Set a partner without email on the lead
3. The warning "The email will be propagated" is visible
4. When saving the form, the email is not propagated even if the
warning message was visible
Solution
========
The reason is that, as the email was not changed, the inverse method
of this field was not called and so the email was not propagated.
The best solution would be to use "force_save" on those fields. But
this feature only works on readonly fields.
So, we simulate a real "force_save" on the email / phone, directly in
JS. That way the inverse will be called, and if necessary, the email /
phone will be propagated.
Task-2704904
closesodoo/odoo#84618
X-original-commit: 1d548c7eadcd25b97856c4769759358f86e00640
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: flch-odoo <flch@odoo.com>
Steps to follow
- Select only one company in the company selector but not the default one
from the current user;
- Go the the CRM app;
- Create a lead;
-> A multi company error appears !
Solution
- The default team is now restricted to the companies in the context
- When computing a lead's company_id when the team has no company, keep only
the ones within the allowed_company_ids;
opw-2713757
closesodoo/odoo#83764
X-original-commit: 58b9b3e839c7725fdcd66376564ce6554a4b82ac
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Purpose is to add some tests involving unsync of env.companies and current
user's company. Tests are added trying to mimic notably assignment cron
using sudo().
Next commit will fix some side issues.
opw-2713757
X-original-commit: 70b9f3aaa86acc6d32bee21fbd6114541115d310
Part-of: odoo/odoo#83764
Currently when converting leads we may end up with False being compared to
a void partner recordset. Due to the use of != this leads to unnecessary
update of leads when no partner is involved in lead convert.
By comparing recordsets everytime we save queries and performance each
time a convert on a lead without customer is done. This leads to about
saving 150 queries in heavy duty tests.
Task-2722512 (Lead: performance in convert without customer)
Task-2722513 (Lead: performance master task)
closesodoo/odoo#81028
Related: odoo/enterprise#23094
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Purpose
=======
When creating an opportunity, set the language of the Lead/Opportunity
to the partner's language if it is set instead of leaving it blank.
Also update tests to correctly test lang propagation.
Update event_crm so that lang of lead from registration is directly set
to False when there is no partner. Indeed we have no clue which lang we
should set and we can skip the field computation that otherwise triggers
some additional queries.
Task-2709436
Part-of: odoo/odoo#81028
PURPOSE
Concatenate feedback message and tracking when marking a lead as lost. This
currently generates 2 consecutive message about the same change, having a
single one is better from an UI point of view.
SPECIFICATIONS
Allow to link a body to a value change tracking. Tracking is currently done
by accumulating changes in a structure (see ``env.cr.precommit.data`` usage
with ``mail.tracking.<name>`` key). In the end those values are used to
generate a message with tracking value and a subtype.
In this commit we allow to manually set a body used as a message for the
tracking message, adding a new ``mail.tracking.message.<name>`` key. It is
used when posting or logging the tracking message, simply propagated as body
to ``message_post`` or ``message_log``.
In crm we use this when losting a lead through the dedicated wizard. A bit
of custom html allows to have a nice display.
Task-2671709
Part-of: odoo/odoo#78648
As this is a many2one, it should end with an ``_id`` suffix. Otherwise we
may think this is a char field, which was probably the case at one point.
Task-2671709
Part-of: odoo/odoo#78648
PURPOSE
Allow sales reps to add a closing note to their lead while it is being marked
as lost. This is currently already done by a lot of sales reps but manually
with the "Log a Note" button.
SPECIFICATIONS
In ``Lost Reason`` model: add a new html field allowing to log a note on the
lost leads. Below the m2o, add an Extra Comment field where users can add a
"closing note". When the wizard is submitted, log this message as a note on
selected records.
Add tests, allowing to test both the wizard and this new feature.
Task-2671709
Part-of: odoo/odoo#78648
Tracking is generated using commit hooks, meaning they are really sent when
the commit ends. This is done to ease values aggregation and accumulation
through various record updates. In some tests we therefore have to manually
flush the tracking, otherwise it is not created and posted. Notably tests about
lead lost wizard were not flushing and therefore not generated the tracking
messages. Those tests will be improved in future commits, cleaning them is
therefore a necessary step.
We also specifically add some tracking flush in mail performance tests. This
is to be sure we measure impact of a write and tracking separately from
previous transactions. Seems everything is working as intended as warmup and
query counters already perform flushes. Here we simply flush at the end
of the setup to be sure all base is clean before starting tests.
Task-2671709
Part-of: odoo/odoo#78648
In one week, this test failed about 4 times, seems mainly on nightly
enterprise. Let us update counter accordingly.
closesodoo/odoo#80164
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Seed is now fixed at beginning of each test to ensure random state is set
once for all and avoid random issues.
Task-2643740
X-original-commit: 85ebcaeaf909cd46743c20bf052360a65e60ea82
Part-of: odoo/odoo#79573
When lead is won/lost, 'date_closed' field should be updated. But since
recent commit[1], this field was not updated while marking lead as lost.
It used to work prior to commit because we used to set `active` and
`probability` together from `action_set_lost` method.
But now, won and lost action are handled with `toggle_active` method.
In case of the lost leads, it first sets the `active` field to False,
and the `date_closed` is correctly updated by write method. After that,
it sets the `probability` to 0, and during that the write method sets
the `date_closed` to False.
This commit fixes the issue by updating `date_closed` field from write
method, only if the `probability` is greater than zero, and thus not
discarding the already set value.
[1] - https://github.com/odoo/odoo/commit/9b76c6b7f1eec4057289de90d62b8a7a266b0aac
TaskID-2343223
closesodoo/odoo#79154
X-original-commit: 3b9db86b76a838c0ae6cc9d517d7a29bff2c0544
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Context
-------
Leads get assigned a different company than the one defined on the salesman
after being merged with another lead.
This happens because some leads assigned to a user_id have no company set. They
are merged with leads that receive self.env.company during assigment to the
to the team and then get merged with the lead without company. So the company
of the new lead is written on the old one.
Behavior before this PR
-----------------------
When the crm.team have the field company_id = False
With the following flow
1) Create a lead without a user_id and a team_id
2) Assign a team to the lead
3) Assign a user_id
The status of the company field on the lead is the following
1) set the company of the env.user
2) Keep the company of the lead
3) set the user company if the current company is not one of the allowed
company of the user
Behavior after this PR
----------------------
1) set the company of the env.user
2) set the company of the team even if it's False
(so erase the company if the team has no company set)
3) set the user company if the current company is not one of the allowed
company of the user
Other changes
-------------
When resetting team and user: void company to avoid having leads without
any information but a company set. It eases assignment.
Task-2520276
closesodoo/odoo#78860
X-original-commit: ff2a6949c3a59be98cd1849e7a2e38c6ccc3187e
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Thibault Delavallée <tde@odoo.com>
Co-authored-by: Thibault François <tfr@odoo.com>
Purpose of this commit is to highlight current behavior of multi company
in lead. Notably a company is set at creation even when no team or user
is set, leading to a lot of issues when dealing with lead merge or convert.
Task-2520276
X-original-commit: dc8d82bbe032cef2f732fdfb1ded3068edc37371
Part-of: odoo/odoo#78860
Co-authored-by: Thibault Delavallée <tde@odoo.com>
Co-authored-by: Thibault François <tfr@odoo.com>
Purpose
=======
When merging multiple leads, we want to move the followers to the
destination lead if they posted a message in the last 30 days.
A message will be added in the merge note to know which followers have
been added.
Task-2447721
PR odoo/odoo#75742