Commit Graph
23 Commits
Author SHA1 Message Date
Aurélien Warnon 9620721884 [IMP] partner_autocomplete,crm_*: unify displayed "clearbit" information
PURPOSE

We make multiple calls to the clearbit API and the returned information are
shown in various different templates, although they contain the same
information.

The purpose of this commit is to unify the templates into a single one to
reduce code size and improve coherence.

SPECIFICATIONS

Currently, we have 3 ways of reaching out to the IAP clearbit api:
- When creating a partner (autocomplete service)
- When enriching an existing lead based on its email address
- When generating leads using the "Geneate Leads" button or using the website
  visitors

Every time we use the service, we log a note in the model's chatter containing
all the information returned by the cleabit service (estimated annual revenue,
media links, sector, ...).

Though using different endpoints and methods, all the calls essentially return
the same data, and the templates could be unified for consistency.

This is the goal of this commit.

We merge the 3 separate templates of each modules into a unique template that
always renders the same information to the end user.

To do that, we had to find a common module to store the template, we chose
"partner_autocomplete" as it's installed anyway as soon as "crm_iap_lead_*" is
installed.

LINKS

PR #40349
Upgrade PR odoo/upgrade#775
Task 2081471
2020-04-15 07:37:43 +00:00
Goffin Simon 7dd24ec90b [FIX] iap, partner_autocomplete: Autocomplete without IAP account token
Steps to reproduce the bug:
- Go to Settings > Technical > IAP account >
- Remove the access token
- Go to Contact
- Try to create a company called 'Proximus' and click on the autocomplete

Bug:

A traceback was raised because the IAP account token was not set.

opw:2087607

closes odoo/odoo#39099

X-original-commit: bc6357f0b95d354afa602eecce24a3c265819101
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-10-21 09:08:27 +00:00
Pierre Rousseau cef2bbd12f [FIX] partner_autocomplete: display insufficient credit notification.
Before this commit the error 'Insufficient Credit' was not triggered by the python side, so the notification was never displayed.

closes odoo/odoo#37649

Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
2019-10-01 06:42:52 +00:00
Pierre Rousseau b969018475 [FIX] partner_autocomplete: correctly manage empty country data
Steps to reproduce:
1) Enter a vat number in a customer field (for exemple Sales Order)
2) Click on the suggestion
=> Traceback

Task-ID 2059940

closes odoo/odoo#37180

Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
2019-09-20 11:15:55 +00:00
Christophe Simonis 3faea8fbf8 [MERGE] forward port branch saas-12.4 up to f26de445e5 2019-08-21 10:10:11 +02:00
Christophe Simonis f26de445e5 [MERGE] forward port branch saas-12.3 up to 6f55fd65da 2019-08-20 12:17:04 +02:00
Christophe Simonis 168e54d488 [MERGE] forward port branch 12.0 up to 32039b2ab4 2019-08-19 18:57:08 +02:00
Jorge Pinna Puissant cb3c2e64c3 [FIX] partner_autocomplete, web: autocomplete error when suggested company has a country
- Change the company's country to Finland;
- Go to Contacts and click on Create;
- Tick the Company box above the Name field;
- Start typing into the Name field;
- Click on a company with a VAT number under its name.

Before this commit, a Traceback appears. This occurs because the
response of the request with the suggested company has the fields
'company_name' and 'company_code' and these fields are not in
res_partner.

Now, the suggested company is parsed to correctly field the country
field.

opw-2049636

closes odoo/odoo#35631

Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2019-08-12 08:39:07 +00:00
Christophe Simonis b792ba7d9a [MERGE] forward port branch saas-12.3 up to 752b2553c6 2019-08-08 11:52:13 +02:00
Christophe Simonis 0fadd586fa [MERGE] forward port branch 12.0 up to ff9ddfdacc 2019-08-06 15:57:57 +02:00
Christophe Simonis 140ee6b8f0 [MERGE] forward port branch saas-12.4 up to 98a55917a6 2019-08-14 16:48:10 +02:00
Fanny He 9022f2154c [FIX] partner_autocomplete: UserError instead of traceback when no credits
When creating a res_partner company, with "Auto-populate company data",
if there is 'Insufficient Credit', AccessError, ConnectionError are caught,
but not UserError.
The user can therefore gets a vague js error
"Uncaught TypeError: Cannot read property 'type' of undefined"
We thus add exceptions.UserError among the caught exceptions.

opw 2040646

closes odoo/odoo#35366

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
2019-08-01 05:54:54 +00:00
Yannick Tivisse f5dfe4727c [IMP] api.py: Rename company_id/company_ids into company/companies
The goal is to be coherent with the user property.

Actually, company_id and company_ids on the environment are no fields.

Calling env.company_id returns a browse record, not an id.
2019-05-29 08:09:15 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00
Yannick Tivisse a5b6f31cf2 [IMP] base: Contextualize the multi company
Purpose
=======

Allow the user to select the allowed companies for which he wants to see records
on top of selecting his current company.

It is confusing for users to see the records from the company he is connected to
and the records of the children companies.

Instead of using the hierarchy of companies to access records across companies,
the user can now select (from his set of allowed companies) the companies for
which he wants to access records.

/!\ This means that the user will interact with records from company A when in
company B.
Example: a SO has been created and confirmed in A. When in B, I create the
invoice from it.

Specifications
==============

1/ Deprecate the parent/children hierarchy on the res.company model. The fields are
kept on the res.company model to ensure the retro-compatibility, but won't be used
accross the standard code anymore. The only functional usage for this mechanism
was to allow to see records from several companies by creating a virtual parent
company, which will be possible with the new mechanism.

2/ By default, a user will only see the records of the company he is connected
to (or records without a company). (It is still editable by the user if needed).
For that, put this information in the user context, to allow having different
configurations on different browser tabs. Instead of having domains like
['|',
('company_id', '=', False),
('company_id', 'child_of', user.company_id.id)]
you'll have something like
['|',
('company_id', '=', False),
('company_id', 'in', company_ids)]
Note that the 'company_ids' is a value that is passed in the evaluation
context on the record rule, as we already have user, or time.
company_ids is a list of the ids of all the enabled companies in the
user's context.

3/ Out of the generic improvements brought by this task, this will illustrate
issues that could exist since several versions. For example, it should not be
possible to create a scrap order for the company A with a package of the company
B, or it should not be possible to create an invoice on the company A with
payment terms from the company B. Before the version 12.0, it was easy to
encounter this kind of issues as the admin was the SUPERUSER_ID. A positive side
effect of the fact that the SUPERUSER_ID has become an inactive user was to
make it more difficult to introduce mismatch on the records, but haven't solved
the issue, as it was still possible to do it with parent companies
configuration. Some of these issues have been fixed in this commit, but all the
business flows should be re-tested to check if an ir.rule should be introduced
(eg: a multi company rule for stock.quand.package), if the company of a record
is correctly transfered to another record created from the first record (eg:
From a SO, create an invoice and a payment, the company of the sales order
should be transfered on the invoice and the payment, even if the company of the
sales order is A and I'm logged into the company B with the company A enabled.

4/ Currently, if I click on a button on a notification email (example 'View
Task'), I face a traceback if I'm not logged into the company of the record.
Now, if you click on a button and if you have access to the record, the correct
company will be automatically set.

5/ If I display a kanban view with several records from several companies (and
an image), all the images should be displayed.

6/ Currently if you copy paste an url, this will crash if you're not in the
correct company. This won't be fixed because it's quite impossible to do it in
a clean way. This task brings a workaround. Copy/Paste -> Traceback -> Log into
the correct company, re-copy/paste -> Ok.

7/ 2 property methods have been added on the environment to retrieve the company
on which the user is logged in and the companies the user enabled, on a specific
tab.
That way, when creating a record, instead of doing
default=lambda self: self.env.user.company_id
do
default=lambda self: self.env.company_id
On the other hand, to retrieve the enabled companies, do
companies = self.env.company_ids

8/ Modify the Company Switcher widget to allow to log into another company
WITHOUT writing on the res.users (and thus bringing cache invalidation issues
and so on). Also allow to enable several companies and see records from several
companies, and independantly of the other browser's tabs.

9/ When focusing on a tab, save the current company configuration on the local
storage. That way, when doing 'CTRL+T' or a middle click, the context is
propagated to the new tab.

10/ Improve the error message in case of multi company access errors. Now, when
the user is in debug mode, display the related names of the records and the name
of the user who brings the issue.

11/ Remove the context erasing when writing on a res.users
This is probably coming from the migration to new API of the base module.
The context was not propagated at this moment, which was a common mistake at
that time. When migrating the module, probably by using the 'black box' method,
as the context was not propagated, it was erased on the new version. This is
now an issue because the context (i.e. the enabled companies) was erased when
writing on a res.users, leading to tracebacks.
See: https://github.com/odoo/odoo/commit/7eab8e26d3d46c53f4be924d6a34e80a66e74960#diff-4c2e738ee8f64f11806c889ea097b5e7R624

12/ Fix the crash manager on redirect warnings. The issue is the following
- Create an invoice on a company without a configured CoA.
- Set a partner
- On the onchange_partner_id, a redirect warning is raised to propose you
to configure a CoA
- Click on 'Go to the configuration panel'
- A generic warning says something like 'Do you want to discard your changes?'
- Click on yes, the page refreshes, but not on the redirect action.
Now, set correctly the action on the hash, and reload instead. The breadcrumb is
lost for example, but you reach the correct action at least.

13/ Introduce a res.group to enable/disable the multi company per tab
feature.

14/ To help the users to know which tab is in which company, add the
possibility to have a favicon per company. When creating a company,
the classical 'O' icon is colored by default in a random color.

15/ Remove the company switcher on the frontend. This was mainly there
to allow a user to swicth to the company linked to the website.
This behavior is now transparent to the user. If the website A is
activated, then the company set on the context is the company of the
website.

16/ Deprecated the _company_default_get method on the res.company
model. Remove the method _get_company on the res.users model.

17/ Add 'allowed_company_ids' and 'current_company_id' on the pyeval
context. You can now use those variables on domains in the views to
access directly to the activated company.ies on the current tab.

TaskID: 1960971

closes odoo/odoo#32341

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-05-13 08:57:49 +00:00
Antoine Prieels (ANP) 8b930c648d [IMP] partner_autocomplete: Notify when user out of credits
closes odoo/odoo#29309
2018-11-28 10:32:20 +00:00
Antoine Prieels (ANP) 96a795f177 [FIX] partner_autocomplete : Do not crash other tests when partner_autocomplete server fails
Add a check to see if we're in test mode that returns an InsufficientCreditError to avoid failing other tests if partner_autocomplete server fails

closes odoo/odoo#28324
2018-10-31 16:11:31 +00:00
TWA 0dd92f7f21 [FIX] partner_autocomplete: No auto-create IAP Account in the settings
Instead of forcing the creation of iap account to consult its balance,
since it will most likely be 0 at creation, we only generate it on
explicit user action (e.g. Click to recharge the account).
2018-10-01 16:29:45 +02:00
TWA c257b8f0a9 [FIX] partner_autocomplete: prevent possible concurrent flag update 2018-09-27 10:45:30 +02:00
TWA e609a6ad4c [IMP] partner_autocomplete: improved additional informations template 2018-09-27 10:45:30 +02:00
Rémi Rahir 7838bde2a8 [IMP] partner_autocomplete: diverse improvements
- CRON changed to 60min
- Fixed display/rendering issues with autocomplete widgets.
- Moved 'Insufficient credit' banner
- Editable endpoint for partner_autocomplete service
2018-09-25 22:28:43 +02:00
Yannick Tivisse c67ac34ee4 [IMP] base: Add missing _description on models 2018-09-21 16:13:59 +02:00
Antony Lesuisse a6e1eb9f0a [ADD] partner_autocomplete: Added autocomplete on partners fields
For Name field or M2O, gives a list of companies
Data comes from Odoo IAP Service
2018-09-21 14:02:22 +02:00