Commit Graph
143436 Commits
Author SHA1 Message Date
Xavier BOL (xbo) c006e97f71 [FIX] pad_project: copy the content in the pad when use_pad=False
Before this commit, when the user edits the description of a task with
use_pad=True and then change the project of this task to one with
use_pads=False. The description written in the pad server is not copied
in the description field of the task.

This commit copies the content of the pad for this case when the use_pad
changes to become False and description_pad is set.

Step to reproduce:
-----------------

1. Go to Settings of the Project App and enable the Collaborative Pads
2. Go to the Project App, in the Projects dashboard (kanban view of projects)
3. Create two Projects (one called "Project A" and the other called "Project B")
4. Edit the Project B to activate the pad, that is, check the Use
collaborative pads checkbox.
5. Go to the view list of tasks in the "Project B"
6. Click on "Create" button to create a task in the task form view.
7. Write a description for this task.
8. Change the project of this task by the "Project A". With this change,
the collaborative pad is disabled for this task since the Project A has
not the pad, and then the description field is empty rather than have
the content that we have just written.

task-2515150

closes #70401

closes odoo/odoo#70917

X-original-commit: 32a8f598d6a958f2a08b204524007cc075697fda
Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
2021-05-17 18:32:55 +00:00
Xavier BOL (xbo) d4d09d0fe1 [FIX] pad: copy the pad_content_field content in pad when genrate pad url
Before this commit, in Project App, when the "Collaborative Pads" is
enabled in the Settings of this app, if the user create a task without
project or in a project that has not the pad enabled and he writes a
description for his new task and select (another) project in which the
pads is enabled then the description field in the form view changed to
have the collaborative pad and the problem is the description is not
copied in the pad and seems erase/delete for the user.

This commit checks if the pad_content_field is not empty after
generating the pad url for the new task/record, if it is the case then
we copy the content in the pad and the user can continue his edition
before saving the task/record.

Step to reproduce:
-----------------

1. Go to Settings of the Project App and enable the Collaborative Pads
2. Go to the Project App, in the Projects dashboard (kanban view of projects)
3. Create two Projects (one called "Project A" and the other called "Project B")
4. Edit the Project B to activate the pad, that is, check the Use
collaborative pads checkbox.
5. Go to the view list of tasks in the "Project A"
6. Click on "Create" button to create a task in the task form view.
7. Write a description for this task.
8. Change the project of this task by the Project B. With this change,
the collaborative pad is actived for this task since the Project B has
the pad, and then the description in the pad is empty rather than have
the content that we have just written.

task-2515150

closes #70401

X-original-commit: d2b55c775d705128fa65c859c5f47bdaf4b705fe
2021-05-17 18:32:53 +00:00
Antoine Vandevenne (anv) 26527370a2 [FIX] payment_paypal: fix post-refactoring issues
- fix missing access rights when handling feedback data
- redirect customers to the payment confirmation page when notification
  data are not acknowledged by PayPal, rather than displaying an
  internal server error

task-2494916

closes odoo/odoo#70885

X-original-commit: 948c22243c88dd905f1a7838f6fba75f44f06b2a
Related: odoo/enterprise#18349
Signed-off-by: Antoine Vandevenne (anv) <AntoineVDV@users.noreply.github.com>
2021-05-17 14:22:14 +00:00
Antoine Vandevenne (anv) e2db444a1f [FIX] payment_ogone: accept tokenizing cards with missing number
In Ogone's backend, it is possible to remove `CARD.CARDNUMBER` from
Flexcheckout's feedback data (Configuration -> Technical information ->
Transaction feedback -> Alias gateway and Tokenization -> Dynamic
parameters). Since this is the configuration that was suggested to Odoo
customers migrating from a previous version, we must be able to process
feedback data when the card number is missing.

This commit creates an anonymous card number ('XXXX...') if one is not
provided by Ogone.

task-2494916

closes odoo/odoo#70896

X-original-commit: 272c4259624d88e2d061c6418109d4e0c2dbfb2d
Signed-off-by: Antoine Vandevenne (anv) <AntoineVDV@users.noreply.github.com>
2021-05-17 15:25:40 +00:00
Ivan Yelizariev a4424c9058 [REM] delete UFO comment
Apparently, it was added by mistake 7 years ago in https://github.com/odoo/odoo/commit/e9d047e6119d8065a8d31a7d3b374630ab90c40d

closes odoo/odoo#70892

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-05-17 15:12:32 +00:00
Nasreddin Boulif (bon) 866c90926b [FIX] base_address_extended: split 'correctly' street name
Issue

	- Install "Contacts" & 'base_address_extended' modules
	- Go to contacts and create a contact with value:
	  - street name : Chaussee de Namur
	  - House : 40
	- Save and edit again
	- Set country to 'Netherlands' then save.

	Address not splited well (wrong values for street name and house).
	The issue is not present in UI but is in tests.
	(Issue in UI from odoo 14.0+)

Cause

	There is 2 '_split_street_with_params'
	(inverse function that set street fields):
	- partner_autocomplete_address_extended (removed in 14.0)
	- base_address_extended

	The 'spliting' logic is not the same in both function.

	In UI, looks like it does not call '_split_street_with_params'
	from 'base_address_extended' since no super(Partner, self)...

	However in testing, it does call it from module
	'base_address_extended' and therefore trigger the issue.

Solution

	Adapt _split_street_with_params function
	(in 'base_address_extended' module):
	If previous field (from 'street_format') to parse
	in 'street_raw' is 'street_name', then:
	- set `tmp` to: splitted (max 1 split) street_raw
	  with current field seperator
	- set `append_previous, sep, tmp[0]` to:
	  splitted tmp[0] (first part of splited street_raw) with `rpartition(' ')`
	- add 'append_previous' to 'street_name' value
	- join 'tmp' values and set it to street
	  (should equal to what left from `rpartition(' ')` split
	  + seconf part of first normal split)
	- continue normal parsing flow

opw-2476096

closes odoo/odoo#70886

X-original-commit: 74116c982a5ddef65a05ef90017ac4ce63bdf58f
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2021-05-17 14:28:24 +00:00
Ivan Yelizariev a7d1617d81 [FIX] purchase: speed up search for purchase_vendor_bill_id
When partner is not selected, Odoo sends name_search request
`[..., ('partner_id', 'child_of', [False])]`. It's not obvious what does such
domain mean ( see #70584 ). This commit clarifies what do we expect to get:
we want all records without restrictions on `partner_id` value.

This also fixes performance issue because domain leaf `('partner_id',
'child_of', [False])` is converted to where-clause `<table>.partner_id in <all
or almost all ids>`

---

opw-2524010

closes odoo/odoo#70873

X-original-commit: 39e0f1fb0f60f309be7f65562911b1236167dce7
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
Signed-off-by: Ivan Yelizariev // IEL <yelizariev@users.noreply.github.com>
2021-05-17 12:52:59 +00:00
sofiagvaladze a2d078c17f [FIX] hr_expense: Fix traceback caused by empty company_id
task - 2475520

closes odoo/odoo#70871

X-original-commit: fa38e56e605406f0c97a3e2c260d2a1b2a19dea5
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2021-05-17 12:06:28 +00:00
Yannick Tivisse 11388ae492 [FIX] hr_payroll: Recompute work entries/payslips on contract update
closes odoo/odoo#70814

Forward-port-of: #18075
X-original-commit: ee398e1abe44caca8bab74f27614dabd9b45590e
Related: odoo/enterprise#18322
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-05-17 09:36:00 +00:00
Yannick Tivisse d3c498c4b3 [FIX] hr_contract: Display incoming employees as "under contract"
X-original-commit: 7669eb6436fe84119359350f3621fc943305bc89
2021-05-17 09:36:00 +00:00
Anjali a0ddf651b8 [FIX] crm: fixed form view for leads in reporting
When clicking on "CRM -> Reporting-> Leads (Leads Analysis)" list and form
views are not correctly set, leading to opportunity views. In this commit we

  * have changed the list view from ``crm_case_tree_view_oppor`` to
   ``crm_case_tree_view_leads`` to ensure we use the right view;
  * we are now able to open form view from the list view like all other views;

When clicking on "Teams -> Reporting (on a team vignette) -> Leads" list
view used is the opportunity one. We fix it by correctly setting action
views for ``action_report_crm_lead_salesteam`` reporting action.

Task-id : 2497936

closes odoo/odoo#69575

Related: odoo/enterprise#18338
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-17 10:28:38 +00:00
Aurélien Warnon 9fe442f384 [IMP] mail: change strategy for onchange_on_keydown from throttle to debounce
The FieldChar and the "Emoji" fields support a "onchange_on_keydown" attribute
that allow triggering the onchange event when the user types into the field.
(Instead of having to wait for a blur event).

This is especially useful, for example, in the social module to refresh the
post preview when the user is typing his message.

The current strategy to avoid spamming this onchange event was to throttle the
method to trigger it at most once every second.
However, triggering it every second could still be problematic in terms of
performances and could cause loading issues (e.g: if you have a large GIF in
your post preview)

To try to mitigate this issue, we changed the strategy from throttle to
debounce and changed the delay to two seconds.
Meaning the onchange will be triggered 2 seconds after the user is done typing,
which still gives a nice "live update" effect without triggering the onchange
too much.

Task-2500821

closes odoo/odoo#69023

Related: odoo/enterprise#17573
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-17 10:32:55 +00:00
Sébastien Geelen (sge) fa2e0a6349 [IMP] web_editor: Add rel="ugc" to some user generated links
See odoo task : https://www.odoo.com/web#action=333&active_id=1695&cids=1&id=2319575&menu_id=4720&model=project.task&view_type=form

closes odoo/odoo#70614

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2021-05-17 08:58:50 +00:00
Antoine Guenet c910976162 [FIX] web_editor: update odoo-editor lib to commit 1021d47 2021-05-17 08:58:50 +00:00
Anjali d70af67954 [IMP] website_slides: show relevant info while viewing partners' courses
Currently, when you click the stat button "x Courses" on a contact, you land
on the dashboard of the courses that this user follows. But this information
in not much useful here. You'd like to see information like progress of this
member for each courses, or when the member was last active on a specific
course.

With this commit, when you click the 'x Courses' stat button from a contact,
you will see the list view of model 'slide.channel.partner', having the
default filter for the contact from which you clicked the button. This will
show the additional and relevant information you need, and by removing the
filter, you'll be able to see info about all the attendees and their progress
on courses they follow (Note that here if the partner is a company, you
won't get default filter set but the records will be filtered by domain,
because we need to show courses of current contact and it's children, and
so we have to set domain in action, instead of adding default filter in
action context).

The same way, on the Attendees View of a course (when seeing attendees from the
course dashboard), we add 'Last Action' field, and instead of fixed domain, we
use filter to view attendees of a particular course, removing which can allow
us to view information about all the attendees from all courses.

We also introduce new 'Attendees' menu under 'eLearning > Reporting' that will
show information about all the attendees from all courses, with a default group
of channels

Task Id-2409447

closes odoo/odoo#64152

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-17 09:12:26 +00:00
Qiuyu (QHO) 7a2b3362cb [FIX] im_livechat: Add missing file in external_lib bundle
The module `@web/js/libs/pdfjs` was imported in the legacy file by PR #70375.
So the file has to be added in external_lib bundle.

closes odoo/odoo#70755

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-05-12 14:44:53 +00:00
Antoine Guenet 9d0c754437 [FIX] web_editor: properly display list buttons as a dropdown in toolbar
The list buttons in the toolbar were stacked, messing up the layout of
the toolbar. This restores them as they were before
https://github.com/odoo/odoo/commit/b2dd95937346561495ab86b90715210ffd9a474a
somehow messed it up.

closes odoo/odoo#70644

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2021-05-11 09:32:31 +00:00
nounoubensebia d01e5c5cdb [IMP] calendar, crm, hr_holidays: move meeting stat button to calendar
Move the meeting stat button and kanban pill from CRM to Calendar, purpose is to
allow its usage even if CRM is not installed as this makes more sense since this
field is usually related to Calendar.

Increase query number limit in company leave test, in order to take into account
the newly introduced query in Calendar.

UPG-PR: https://github.com/odoo/upgrade/pull/2423

Task-2514473

closes odoo/odoo#69846

Related: odoo/upgrade#2423
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-04-28 14:05:07 +00:00
Swapnesh Shah 907d129bdd [IMP] stock: allow to use return picking model
Before this commit, 
We were checking for multiple `active_ids` before checking for `active_model` in context,
which was blocking point if user want to use this model with `active_ids` with 
different `active_model`.

With this commit,
we are checking condition of multiple `active_ids` if `active_model` is `stock.picking`.
so other users can use this model with `active_ids` without changing any flow.

closes odoo/odoo#70772

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-05-12 16:02:09 +00:00
Aaron Bohy a58192fae4 [FIX] sale_timesheet: fix randomly failing tour
Before this commit, the wrong many2one value could have been
selected in the tour, making it fail later on with the following
error:

```
AssertionError: The test code "odoo.startTour('sale_timesheet_tour')" failed
Tour sale_timesheet_tour failed at step Click on this stat button to see
the SO linked to the SOL of the task. (trigger: button[name="action_view_so"])
```

closes odoo/odoo#70789

X-original-commit: 4210d7663600027d39ccb88b0bcd6e1422f2d452
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-05-12 18:08:24 +00:00
Julien CHEVREAU (JCU) 2d5b4ca4b2 [IMP] account: Improve Journal Entries view From Bank Statements
Beforehand, when display the journal entries from a bank statement,
some fields (Due Date, Next Activity, Payment status) that are not very
relevant were displayed.

Now, we use the bank & cash view to display the bank statement in a more relevant manner.

closes odoo/odoo#70811

Task: 2459562
Signed-off-by: William André (wan) <wan@odoo.com>
2021-05-14 13:58:53 +00:00
oco-odoo e3eeabe616 [FIX] l10n_lu: fix tax report lines' codes for XML export 2.0
When exporting the tax report's monthly xml with enterprise, the file wasn't accepted by the government in case 0% taxes were used.

Grid 033 is optional, and can be used for custom tax rates. If specified, it MUST always go with grid 403 (giving the tax rate) and 042 (giving the tax amount). In Odoo, we made the choice to use it for 0% taxes, so 403 and 42 will always be present, and always 0.

In community, grids number were missing on the lines' labels, and the codes (used to retrieve the value of each grid when generating the XML) were not correct.

closes odoo/odoo#70792

X-original-commit: add187862f627c4340ef7ca49d8a75e149cb12f5
Related: odoo/enterprise#18305
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-05-12 19:11:09 +00:00
Adrien Widart dfbebbc09e [FIX] web: remove bottom border of first table raw
When using the boxed layout, if the business document has a table, its
first row (after the table head) will have a bottom border and the last
cell in the row has a white background.

To reproduce the error:
(Need timesheet_grid. Use demo data)
1. In Settings > General Settings, Change Document Template:
    - Select the second template
2. In Timesheets, select list view
3. Select several lines
4. Print > Timesheet Entries

Error: In PDF, the first timesheet line has a bottom line and its last
cell has a white background (instead of grey).

The bottom line should only be applied on row in table header. The
background color should also be applied on first row in table body.

OPW-2478311

closes odoo/odoo#70771

X-original-commit: 88a10bdd8f1d46a8b52be59fe3284cbe284a74f2
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-05-12 16:02:01 +00:00
Andrea Grazioso (agr-odoo) f35631d350 [FIX] account: avoid change of payment type on 0 amount
Create a draft payment with payment type and 0 amount.
Save.

The payment type will be overwritten

opw-2495461

closes odoo/odoo#70626

X-original-commit: 86a2819697d5d9d1c32ba902d8a1089acf6110f2
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2021-05-10 16:32:05 +00:00
Thibault Delavallée d4fd55a931 [FIX] crm: fix query counters: 2 tests sometimes at +3 on runbot
/shrug

closes odoo/odoo#70794

X-original-commit: 84d0cd28a4d701ae509d6152759a64942dcf5c2e
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-12 19:51:23 +00:00
Thibault Delavallée 8cf094ed0d [FIX] crm: improve assign test asserts
Purpose is to avoid randomly failing tess depending on how leads are allocated
through teams. We achieve that purpose by

  * creating more leads, easing their repartition through teams;
  * adding a lower and upper bound test for team allocation to ensure weights
    are globally ok;
  * changing member assign domain to fit more closely test lead data;

We also improve test by using the ``crm.assignment.commit.bundle`` config
parameter that has an impact on lead duplicates removing and therefore
performances.

LINKS

Task ID-2528906
COM PR odoo/odoo#70756
Followup of Task ID-2489951 (assign process improvements)
Followup of odoo/odoo#70172 (smoother assign process)

X-original-commit: 8fdf97b6498adc0a2fb15e360ebbbaa1672534e5
2021-05-12 19:51:22 +00:00
alt-odoo ca71ebad9b [FIX] project: incorrect creation of recurring tasks
In case X several recurrences are processed in the same cron execution,
only the last recurring task was created X times, while the other tasks
were not created. There is also a missing id preventing a correct use of
the default stage for the new created task.

closes odoo/odoo#70784

X-original-commit: 5ea2fcbecf572be24af9b2aac76de9e5d5709d2c
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
2021-05-12 17:10:46 +00:00
Florent de Labarre c93dffc39a [FIX] mail: impossible to update image of partner on large database
On large database with million of messages made by one partner.
When you try to update the image of partner, it take lot of time (CPU time limit).

closes odoo/odoo#70786

X-original-commit: b44272a662468d164277b265d33ba6f46e631118
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-12 17:21:05 +00:00
Julien Banken 1ba6312f29 [FIX] slides: Verifying the returned value of re.search before accessing the capture groups.
The `search` function of the `re` package can return `None` if the
provided string does not match with the provided pattern
(https://docs.python.org/3/library/re.html#re.Pattern.search).

On the `_parse_youtube_document` function of the `slide.slide` model,
we are directly accessing the capture groups from the returned value
of the `search` function without checking that the returned value is
actually a 'match' object. As a result, an exception can be throw if
there is no match as, in that case, the `search` function will return
`None` and the `group` function will not be defined on `None`.

To avoid throwing an exception, we will check that the returned value
of the `search` function is not `None` before accessing the capture
groups via the `group` function.

LINKS

Task id: 2525007

closes odoo/odoo#70763

X-original-commit: 575a524474fe8866cc71b3befc6bbbde8d73075e
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-12 15:02:41 +00:00
Odoo's Mergebot 93f02129b8 [FW][MERGE][REF] crm: ensure teams and salespersons pipe constant filling
RATIONALE

All unassigned leads should be assigned to teams as soon as possible to ease
lead analysis.

Purpose of assign thresholds is to ensure sales people receive at least this
amount of leads within 30 days, counting lost and won leads. Giving them leads
regularly is also one goal of automatic assign.

SPECIFICATIONS: TEAM ALLOCATION

Team assignment has to be updated as we may have team domains that overlap.
We therefore remove maximum number of leads to allocate to teams. Instead all
available unassigned leads are allocated within teams.

  - Solution: assign all available leads and not a count based on team's
    capacity. This notably reverts the main goal of odoo/odoo@6df2f0c
    (see odoo#48422)

This assignment process is done proportionally to the team capacity. It is
computed as the sum of each member's maximum assignment counter. This means
that with a team having twice as much sale capacity than another team sharing
the same domain: first team should receive about 2/3 of leads while the second
one should receive the remaining 1/3.

  - Solution: assign lead one by one. Choose a team randomly using a weighted
    random algorithm, based on team's members capacity.

SPECIFICATIONS: MEMBER ASSIGN

Counting every lead whatever its state may lead to an inconvenient situation.
Moreover salespersons may opt-out from assign by setting their max capacity
to 0, for example when going on holidays.

When doing that lead assignment is not smooth and getting back to a full
pipe may take several days. To solve that issue a compensation is added in
assignment quota done to sales people. Salespersons having few leads will
get a boost in assign as soon as they get back in assign process. When being
near maximum compensation is nearing 0 and daily quota is given.

ENSURE SALES PERSONS PIPE FILLING

Counting every lead whatever its state may lead to an inconvenient situation.
If a salesman always reaches its maximum every days he will always receive the
number of lead he got 30 days ago. For example if the salesman goes in holidays
for few days and set the max to 0 he receives no lead during his vacation.
Then after a few days of assign he reaches its maximum and receive 0 leads
for a few days. This leads to having windows of leads that repeat themselves
every 30 days.

   * Solution: do not limit at maximum capacity anymore. Compensation is voided
     if limit is achieved. However asked assignment is done. Salesman could
     receive more than its max capacity but 30 days window ensure old leads
     are regularly going out of count.

``assignment_max`` is now more a mean target of leads to be assigned during
a 30 days window than a real maximum capacity. Field is renamed accordingly.

WORK DAYS / CRON TIME CONFIGURATION

When running the cron is should assign leads based on its frequency. If cron
runs once every day, work_days given to sub methods should be 1. If it runs
more than once day it should be less than 1. We therefore remove the *2
multiplier and support fraction of days.

As assign process changes in this merge, assigning more strictly compared to
salespersons capacity will not be an issue anymore. Assign process is best
designed to run every few hours (~4 times / day) or each few days. Code and
work_days are updated accordingly.

PERFORMANCE

During team assignment setting team on leads one lead at a time may cause
performance issue. As PLS is computed at each flush we want to flush after
a bunch of lead. For that purpose we need to avoid too much commits and
also avoid to search for duplicate at each assignation.

We therefore perform the search for duplicates before going into allocation
and use a cache through loops to ease using pre-fetched information.

Unlinking duplicates at each iteration is also sub efficient as it causes
recomputation or invalidation. We therefore aggregate all duplicates to
unlink and unlink them in the main team-based loop instead of the sub loop
that is lead-based.

LESS AUTO COMMITS

During team assignation, assigning lead one by one may cause performance issue.
Since PLS is computed at each flush, so we want to flush after a bunch of lead.
To solve that we obviously need to not commit at each assignation but
also avoid to search for duplicate at each assignation, that why the
search for duplicates is done at the beginning of the process and stored
in memory.

ASSIGN WON / LOST LEADS USAGE

In this merge we also

  * use stage instead of probability to exclude won duplicated leads in order
    to include leads with 100% but still not won;
  * count all leads in lead_month_count used in assign to effectively compute
    sales persons workload;
  * keep team when assigning and deduplicating leads instead of erasing
    master opportunity team;
  * crm: correctly filter out won and lost leads for assignment using
    stage;

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

closes odoo/odoo#70723

Forward-port-of: odoo/odoo#70664
Forward-port-of: odoo/odoo#70172
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-12 19:10:08 +02:00
Thibault Delavallée c6cba59de8 [IMP] crm: add assignment optout test
Add a test ensuring ``assignment_optout`` works as intended. Salespersons
being opt-out from assign process should not receive any leads. This replaces
setting ``assignment_max`` to 0 (which is still a working trick). This commit
is a followup of odoo/odoo#68476 (done in a rush), and done in a specific
commit to avoid messing with forward-port.

Task ID-2497077
COM PR odoo/odoo#70664

X-original-commit: 813016e77b6abf9032059725a8725f693b132b58
2021-05-12 14:23:55 +00:00
Thibault FrançoisandThibault Delavallée eca1b7aeaf [IMP] crm: ensure constant lead filling when assigning
PURPOSE

All unassigned leads should be assigned to teams as soon as possible to ease
lead analysis.

Purpose of assign thresholds is to ensure sales people receive at least this
amount of leads within 30 days, counting lost and won leads. Giving them leads
regularly is also one goal of automatic assign.

SPECIFICATIONS

Counting every lead whatever its state may lead to an inconvenient situation.
If a salesman always reaches its maximum every days he will always receive the
number of lead he got 30 days ago. For example if the salesman goes in holidays
for few days and set the max to 0 he receives no lead during his vacation.
Then after a few days of assign he reaches its maximum and receive 0 leads
for a few days. This leads to having windows of leads that repeat themselves
every 30 days.

   * Solution: do not limit at maximum capacity anymore. Compensation is voided
     if limit is achieved. However asked assignment is done. Salesman could
     receive more than its max capacity but 30 days window ensure old leads
     are regularly going out of count.

``assignment_max`` is now more a mean target of leads to be assigned during
a 30 days window than a real maximum capacity. Field is renamed accordingly.

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

X-original-commit: 3d1841f26ce64f0106122e48750d2c653ea9790f
Co-authored-by: Thibault François <tfr@odoo.com>
Co-authored-by: Thibault Delavallée <tde@odoo.com>
2021-05-12 14:23:55 +00:00
Thibault Francois fe8c5b9b01 [IMP] crm: change in assignation process and limit
PURPOSE

All unassigned leads should be assigned to teams as soon as possible to ease
lead analysis.

Purpose of assign thresholds is to ensure sales people receive at least this
amount of leads within 30 days, counting lost and won leads. Giving them leads
regularly is also one goal of automatic assign.

SPECIFICATIONS: TEAM ALLOCATION

Team assignment has to be updated as we may have team domains that overlap.
We therefore remove maximum number of leads to allocate to teams. Instead all
available unassigned leads are allocated within teams.

  - Solution: assign all available leads and not a count based on team's
    capacity. This notably reverts the main goal of odoo/odoo@6df2f0cfc0
    (see odoo/odoo#48422)

This assignment process is done proportionally to the team capacity. It is
computed as the sum of each member's maximum assignment counter. This means
that with a team having twice as much sale capacity than another team sharing
the same domain: first team should receive about 2/3 of leads while the second
one should receive the remaining 1/3.

  - Solution: assign lead one by one. Choose a team randomly using a weighted
    random algorithm, based on team's members capacity.

SPECIFICATIONS: MEMBER ASSIGN

Counting every lead whatever its state may lead to an inconvenient situation.
Moreover salespersons may opt-out from assign by setting their max capacity
to 0, for example when going on holidays.

When doing that lead assignment is not smooth and getting back to a full
pipe may take several days. To solve that issue a compensation is added in
assignment quota done to sales people. Salespersons having few leads will
get a boost in assign as soon as they get back in assign process. When being
near maximum compensation is nearing 0 and daily quota is given.

PERFORMANCE

During team assignation, assigning lead one by one may cause performance issue.
Since PLS is computed at each flush, so we want to flush after a bunch of lead.
To solve that we obviously need to not commit at each assignation but
also avoid to search for duplicate at each assignation, that why the
search for duplicates is done at the beginning of the process and stored
in memory.

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

X-original-commit: 83f72711e7affa8b0ad997b9ee262326e9577d54
2021-05-12 14:04:03 +00:00
Thibault François 74d6455cdb [IMP] crm: better support cron time configuration
When running the cron is should assign leads based on its frequency. If cron
runs once every day, work_days given to sub methods should be 1. If it runs
more than once day it should be less than 1. We therefore remove the *2
multiplier and support fraction of days.

As assign process will soon change, assigning more strictly compared to
salespersons capacity will not be an issue anymore. Assign process is best
designed to run every few hours (~4 times / day) or each few days. Code and
work_days are updated accordingly.

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

X-original-commit: c59ba43d1e9eb0c016b9a113c9475dec28fa413b
2021-05-12 14:02:23 +00:00
Thibault FrançoisandThibault Delavallée 05316742c0 [FIX] crm: correctly filter out won and lost leads for assignment
Automatic assignment is performed on leads that are unassigned and not won
nor lost. This commit fixes the condition that should be based only on
stage being set to a stage with ``is_won`` being True.

Current code fails with won unassigned leads that are assigned even if it
should not. This happens rarely as won leads have probably been taken care
of. However having the right condition ensure filtering won and lost leads
is not correctly done.

Followup of odoo/odoo@5016b47a06 (see odoo/odoo#48422)

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

X-original-commit: d9fe86ec2ca6459a34b31e65c0702d8a80a7ec61
Co-authored-by: Thibault François <tfr@odoo.com>
Co-authored-by: Thibault Delavallée <tde@odoo.com>
2021-05-12 14:02:22 +00:00
Thibault FrançoisandThibault Delavallée 99bc9420a5 [REF] crm: use a duplicate cache when assigning to teams
PURPOSE

Purpose is to try to reduce friction between searches in loops, team assign
on leads and unlink during merge process that unlink leads and forces flush
/ cache reset, as well as PLS computation.

SPECIFICATIONS

During team assignment setting team on leads one lead at a time may cause
performance issue. As PLS is computed at each flush we want to flush after
a bunch of lead. For that purpose we need to avoid too much commits and
also avoid to search for duplicate at each assignation.

We therefore perform the search for duplicates before going into allocation
and use a cache through loops to ease using pre-fetched information.

Unlinking duplicates at each iteration is also sub efficient as it causes
recomputation or invalidation. We therefore aggregate all duplicates to
unlink and unlink them in the main team-based loop instead of the sub loop
that is lead-based.

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

X-original-commit: c5310102210fb9afc6ab786f4c8f6eaf5aee59bb
Co-authored-by: Thibault François <tfr@odoo.com>
Co-authored-by: Thibault Delavallée <tde@odoo.com>
2021-05-12 14:02:21 +00:00
Thibault François f2ff222fba [FIX] crm: keep team when assigning and deduplicating leads
New leads are automatically assigned to sales team and salesman during assign
process. Some of those leads are duplicates of existing opportunities. If a
new lead is merged into an existing opportunity, the opportunity is the master
data and the lead is duplicated. However the opportunity should keep its sales
team and not be assigned to the team being under automatic assign.

Before this commit, the merge was forcing the crm team to the 'current' team
during auto assignment and thus it was changing the team of the opportunity.
In this commit we now assign team to lead to merge before the merge and do
not force the crm team during merge process.

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

X-original-commit: 356a55053eb1cc49ae6eed0e58338cff08eddc42
2021-05-12 14:02:19 +00:00
Thibault François d92ca08fd7 [IMP] crm: count all leads in `lead_month_count` used in assign
PURPOSE

Goal of ``assignment_max`` is to make sure sales receives this amount of leads
within 30 days. Counting lost or won leads is therefore necessary to effectively
count all leads received those last 30 days.

SPECIFICATIONS

Change ``lead_month_count`` computation to take into account archived and won
leads. We consider now that goal of ``assignment_max`` is to make sure sales
people receive this amount of leads within the 30 days at max.

This allows to avoid archiving leads to get a new batch of leads to handle.
Also done leads should be counted as it is part of the month job.

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

X-original-commit: 23feb1a467e0a441eb775be26c96af697d74506f
2021-05-12 14:02:15 +00:00
Thibault François 6106642cb5 [IMP] crm: use stage instead of probability to exclude won duplicated leads
Change domain of ``_get_lead_duplicates``: lost and not win lead currently
means lead with a probability != 0 and != 100. This is not always accurate as
you may have a lead with 100% win probability but that is still not won.
Instead search for active lead and with stage_id.is_won = False .

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

X-original-commit: 31e8d3cf03025085b5ae9db67536a1110bf3e484
2021-05-12 14:01:28 +00:00
2f829b0e28 [REF] crm: cleanup test environment to prepare changes in assignment process
This commit contains two main preparatory changes in tests

  * 1) lead_month_count will be changed to count lost lead as well. So
    archiving leads before running the test doesn't reset the counter.
    Lead needs to be unlinked in order to make tests reproducible;

  * 2) assertMemberAssign checked the validity of the team domain. Normally
    all lead assigned to the member should match the domain of its team.
    This assert is not always verified since we force the team after a
    merge of duplicated leads. Final merged lead may not match team domain
    anymore as final properties depend on all merged leads.

Some tests are also added :

  * add tests for master lead team_id and user_id values when merging leads
    in assign process;
  * add tests using email_normalized check in duplicate finding to ensure that
    normalized emails are used for duplicates and not only exact match;
  * add tests for won / lost inclusion in ``_get_lead_duplicates``, as well
    as different between probability=100 and stage.is_won = True . This is
    going to change in upcoming commits, hence some test to highlight it;
  * add tests counting existing leads for assignment purpose;
  * add tests for assignment_max maximum leads allocation as well as max=0
    meaning salesperson is opt-outed from assign;
  * add tests for default user / team / stage computation for leads;
  * add tests about leads taken into account in assign process (currently
    failing with won unassigned leads);

We also add some flush to ensure some fields notably related to probabilities
are flushed before counting queries.

LINKS

Task ID-2444908 (assign fixes)
Task ID-2489951 (assign process improvements)
COM PR odoo/odoo#70172

X-original-commit: bd3444085974f4e12287c2f5da4fb33308cd6180
Co-authored-by: Thibault François <tfr@odoo.com>
Co-authored-by: Thibault Delavallée <tde@odoo.com>
2021-05-12 14:00:58 +00:00
Thibault Delavallée 71f19d55fa [FIX] phone_validation: add country trigger on sanitize phone computation
If country is updated on a record inheriting from mail.thread.phone
its sanitized number should be computed again. Indeed without this
trigger it is not computed and may lead to inconsistencies between
phone numbers and sanitized number.

Task ID-2528169

closes odoo/odoo#70734

X-original-commit: odoo/odoo@d00b291167
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-12 13:59:36 +00:00
Thibault Delavallée a8fafbf02e [FIX] crm: correctly compute phone_sanitized without having crm_sms installed
Currently phone_sanitized computation on lead model works only if crm_sms
is installed. Indeed an override of ``_phone_get_number_fields`` is missing.
However ``_sms_get_number_fields`` coming with ``crm_sms`` and its ``sms``
dependency hides the issue as those modules are auto-install. However if
``crm_sms`` is uninstalled phone_sanitized is not correctly computed anymore.

Task ID-2528169
Oversight of odoo/odoo#45315

X-Original-Commit: odoo/odoo@45ae2922e5
2021-05-12 13:35:03 +00:00
Romain Derie e3295ed8ab [FIX] product: correctly consider context key for display_name
Regarding of the `display_default_code` context value, `display_name` is
supposed to return the product code or not, eg:
> product.display_name
> '[FURN_6666] Acoustic Bloc Screens'
> product.with_context(display_default_code=False).display_name
> 'Acoustic Bloc Screens'

But since the context was not considered when accessing this field, it would
always return the cached value, which was set from the first time that field
was read, with the `display_default_code` value used at that time.

tl;dr: `display_name` was ignoring the context once cached.

One of the critical issue was that internal code were displayed on the eshop
cart (not the eshop itself), see `name_short`.

task-2517830

closes odoo/odoo#70739

X-original-commit: b5b4d38adf1f3960cda21b795a26e67b978b2901
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
2021-05-12 11:54:06 +00:00
oco-odoo c353923b68 [IMP] l10n_generic_coa: add missing default tax closing accounts on CoA
closes odoo/odoo#70705

X-original-commit: cf975e44547126ba4a71b52c8bed92008c498efb
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-05-11 16:31:39 +00:00
Laurent Smet 4c39d517f2 [FIX] account: Partial revert of https://github.com/odoo/odoo/commit/39fb6b2990e5d6fda0d5f12dbd64d26ef77b9d0c
It seems some ppl are sharing the same bank account accross multiple journals.

issues:
2527148
2527994
2527894
...

closes odoo/odoo#70704

X-original-commit: 9b3506523659b06440b46664eeb83952cc30694e
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-05-11 16:30:11 +00:00
Raf Geens 66c766cdd1 [IMP] hw_drivers: Document pitfalls of update_iot_devices logic
closes odoo/odoo#70657

X-original-commit: 8c584aa86518565a652daf71e3d1824af1fb867a
Related: odoo/enterprise#18267
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2021-05-12 08:38:01 +00:00
Raf Geens 23dc8fc59c [FIX] hw_drivers: InterfaceMetaClass violates CPython constraints and breaks import
Currently, none of the classes derived from Interface use `super`. If
it's added, for example by adding this to `SocketInterface`:

```
def __init__(self):
    super().__init__()
```

, a deprecation warning will appear in Python 3.6 and 3.7:

```
2021-04-30 13:14:25,000 24736 WARNING ? py.warnings: /home/pi/odoo/addons/hw_drivers/iot_handlers/interfaces/SocketInterface.py:11: DeprecationWarning: class not set defining 'SocketInterface' as <class 'SocketInterface.py.SocketInterface'>. Was classcell propagated to type.new?
  class SocketInterface(Interface):
```

In Python 3.8 this is no longer a warning and becomes a `RuntimeError`.

The reason this happens is that `InterfaceMetaClass` caches the results
of the `__new__` calls it does in `interfaces`. CPython's data model
specifies that when calling `__new__`, the cell for `__class__` needs to
be passed along to the parent class: https://docs.python.org/3/reference/datamodel.html#creating-the-class-object .

See https://docs.python.org/3/c-api/cell.html for a definition of what
a cell is.

Because of the caching, this doesn't happen when `__new__` is called
multiple times for the same class. In the case of the `SocketInterface`
example, `__new__` is called twice: first when it's imported directly by
`load_iot_handlers` (https://github.com/odoo/odoo/blob/841c016913a87133bf7257c62ae5f6bf7d99e06d/addons/hw_drivers/main.py#L81)
and second when `IngenicoDriver` imports it. The `__class__` cell is
different each time in that case. With the caching present, this means
the second cell isn't propagated correctly, resulting in the warning /
error.

After `load_iot_handlers` has finished, the `Manager`'s `run` method
iterates over `interfaces`, instantiating and starting the loaded
classes. Because of this, simply removing the caching appears to be
sufficient to avoid the issue while keeping the end result the same.

This issue was encountered while forward-porting a V13 PR, which adds a
`super` use to `SocketInterface`. The issue didn't occur in V13, because
the metaclass doesn't have a cache there.

I found a second problem resulting from the caching. I had noticed that
the `socket_devices` dict the `IngenicoDriver` had access to did not
have the same contents as the one the `SocketInterface` was operating
on. This means that whenever you called the `disconnect` function on the
`IngenicoDriver`, which deletes its entry from `socket_devices`, it will
always fail. The bluetooth driver seems to be impacted by the same.

It turns out the reason for that is how downloaded modules get loaded in
`load_iot_handlers`. That logic (using `exec_module`) doesn't actually
import the module, it just executes the code (registering the interfaces
and drivers as a side-effect). This means the module doesn't get cached
in sys.modules. That means that when another module (`IngenicoDriver`)
imports that same module (`SocketInterface`), Python will execute the
entire contents again, in this case effectively replacing socket_devices
with a new dict, which `IngenicoDriver` gets a reference to, while the
`SocketInterface` thread that runs is still using the old reference to
the original dict. Meaning the two are out of sync. See
https://docs.python.org/3/reference/import.html#the-module-cache for
details on how the import caching works.

The reason the classes get out of sync is because the metaclass doesn't
update interfaces when the second actual import happens, so the
`SocketInterface` class that gets instantiated holds a reference to the
old `socket_devices` dict. Removing the caching removes that problem as
well. If there's no caching, both the `SocketInterface` class and
`IngenicoDriver` will hold a reference to the same instance of
`socket_devices`.

X-original-commit: edffdd10f3ceb3826bf8897f93fa8290d7fce1ec
2021-05-12 08:38:01 +00:00
Raf Geens ec1f064b09 [FIX] hw_drivers: Start iot_devices thread after registering it
This commit was originally part of a larger commit related to an
Ingenico double connection deadlock bugfix in V13, but in V14 most of
the related code has moved to enterprise. When a driver thread is
running, calling `disconnect` on it will delete it from iot_devices. If
the driver thread gets added to iot_devices in the Interface thread
after starting it, this means there is a tiny window of time where
`disconnect` could be called and the thread wouldn't be in iot_devices
yet, resulting in an exception. This change puts the driver thread in
iot_devices before starting it, avoiding that scenario and the need to
check in `disconnect` for that happening.

X-original-commit: 6c24d30c3910e67ed751327d1554e2e8cf5e958b
2021-05-12 08:38:01 +00:00
Florent de Labarre 1e764eb2b2 [FIX] website : prevent bad query
In database with front end, there are lot of bad query like this:
bad query: UPDATE "website_visitor" SET "timezone"='Europe/Paris',"write_uid"=116,"write_date"=(now() at time zone 'UTC') WHERE id IN (15414)

closes odoo/odoo#70709

Error: Could not serialize access due to concurrent update
X-original-commit: d0db984990679a63714ca62e6b605d94af7d5c28
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-12 07:25:22 +00:00
Donatas 89f9649d6b [FIX] purchase_stock: PO line related stock moves getting stuck
When purchase order line is removed, related stock moves procure method stays as "Advanced" which doesn't allow reservation from stock

closes odoo/odoo#70708

X-original-commit: 17d0d1bc6294578e035e29a550a7e90ae7ef2f5f
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-05-11 16:59:39 +00:00