Commit Graph
5154 Commits
Author SHA1 Message Date
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
qsm-odoo d0573de2b6 [IMP] website_sale, *: save the layout mode in the user session
* website

Part of https://github.com/odoo/odoo/pull/31147
task-1925327
2019-05-28 15:05:42 +00:00
Romain Derie 04b4818d84 [FIX] website: onchange new record adaptation
Before this commit, when you go on website config settings, you can't save.
This is because the website default lang field is not set anymore (supposed to
be set in onchange), and since it is hidden in the view if only one language,
there is no clue about the error field.

Following d0bb596f1d, x2many fields of new records are new records, meaning
that:
`self.many2one in self.x2many`
is not true anymore since self.x2many is a new record.

Also:
`self.many2one = self.x2many[0]`
is not working as before, the new record is not saved in the many2one

closes odoo/odoo#33716

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-05-28 10:13:36 +00:00
Sébastien Theys 277c30e7e6 [IMP] web_editor, website: clean up media dialog
Restructure the code in a more logical manner. No functional change.

PR: #33509
2019-05-27 16:32:52 +00:00
Martin Geubelle c54caca54d [IMP] website: Cache translations forever
Generate a unique URL for translations and cache them forever in the
browser. This reduces the number of requests, in exchange for computing
the hash of the translations when the session object is added to the page
2019-05-22 07:52:07 +00:00
Christophe Simonis 8dd5a85267 [MERGE] forward port branch saas-12.3 up to 60e71302a3 2019-05-13 15:26:12 +02:00
Christophe Simonis 60e71302a3 [MERGE] forward port branch saas-12.2 up to 243a4ae5cb 2019-05-13 11:02:27 +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
Christophe Simonis 243a4ae5cb [MERGE] forward port branch saas-12.1 up to 330b99f60c 2019-05-10 15:20:01 +02:00
Christophe Simonis cc3a2c1bf3 [MERGE] forward port branch 12.0 up to e11bacfe51 2019-05-09 21:07:44 +02:00
Christophe Simonis a97037c6d4 [MERGE] forward port branch saas-12.2 up to 78b3b650b0 2019-05-06 12:27:51 +02:00
Odoo Translation Bot 78b3b650b0 [I18N] Update translation terms from Transifex 2019-05-05 06:07:56 +02:00
Christophe Simonis 04acf0cc7c [MERGE] forward port branch saas-12.1 up to 2420492c26 2019-05-03 18:47:49 +02:00
Christophe Simonis 62017de41e [MERGE] forward port branch 12.0 up to d7c0c5c127 2019-05-03 09:16:50 +02:00
Odoo Translation Bot c924356d9e [I18N] Update translation terms from Transifex 2019-05-05 01:35:12 +02:00
Kishan Gajjar 8e7a9b5046 [FIX] website: restore Facebook snippets in edit mode
Facebook snippets' related widgets must be instantiated in edit mode.

This was broken when the feature which disables the widgets in edit mode
by default was introduced with https://github.com/odoo/odoo/commit/335a505d1f9b6a978c0fe0f6ea760a45b0d0a67f.

closes odoo/odoo#32921

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-04-29 10:23:35 +00:00
Kishan Gajjar f670d4103b [FIX] website: adapt Facebook snippet to API changes
Facebook API does not accept float values for height and width
parameters anymore.

closes odoo/odoo#32970

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-04-29 10:15:05 +00:00
Odoo Translation Bot 3ac23bef79 [I18N] Update translation terms from Transifex 2019-04-28 01:34:21 +02:00
Denis Ledoux b11930047f [MERGE] forward port branch 12.0 up to c9913152ec 2019-04-26 18:14:18 +02:00
Nicolas Martinelli 77c708c516 [FIX] website: sign-up in multi-website
- Create 2 companies A & B
- For each company, create a website linked to a different URL and
  activate 'Free sign up' and 'Specific User Account'.
- As a public user, go to website of company B
- Go to 'Sign in > Don't have an account?' and create an account

The user is created in company A (the company of the user template)
instead of company B (the company of the website).

We set the company of the user based on the company of the website.

opw-1962197

closes odoo/odoo#32823

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-04-19 08:54:22 +00:00
Odoo Translation Bot a73206c0b1 [I18N] Update translation terms from Transifex 2019-04-21 01:20:56 +02:00
Christophe Simonis 15b8d353c7 [MERGE] forward port branch 12.0 up to 2830b93a3a 2019-04-17 19:47:37 +02:00
qsm-odoo 75f16ee07f [FIX] web, website: adapt menu loading to jQuery 3
Javascript is responsible of showing the menu, potentially with some
parts regrouped in an extra dropdown, on page load (this is what we
call the "autohide" feature). This was done on both the menu and the
affix menu. It worked on the affix menu because the affix menu widget
was initialized before (by luck: alphabetical order).

Since the jQuery 3 update https://github.com/odoo/odoo/commit/bb004e3d7f3df5a5af6b2e994ec0af79e2da890f
deferred are always delayed (even if their resolve condition is met on
creation). This made the animations to be initialized in the same order
as before but their 'start' method to be delayed (as the willStart was
delayed). So what happened before was:

1) Find menus to enable affix
2) Enable affix on found menus (duplicate the menus to do that)
3) Find menus to enable autohide
4) Enable autohide on found menus (both the menu and the duplicated one
   were found)

And since jQuery 3:

1) Find menus to enable affix
2) Find menus to enable autohide
3) Enable affix on found menus (duplicate the menus to do that)
4) Enable autohide on found menus (the duplicated one was not found at
   step 2 since it did not exist yet)

In fact, widget starting should never have relied on alphabetical order.
The fix only consists of starting widgets on the duplicated menu once it
is ready. This is what this commit does.

However, doing this revealed another bug: if the widgets are started
only for a DOM portion like a '.a' element, a widget with a multiple
parts selector like a '.a .b' selector will not be considered, as
searching inside a '.a' element will not allow to match elements with
a selector containing a '.a'. This is in fact not really a "bug" but a
limitation, so unless we get problems because of this in stable
versions, we can only "fix" this for the current saas. This is fixed
thanks to `dom.cssFind` which already existed. This commit however
improves it to try making it more efficient.

closes odoo/odoo#32465

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-04-19 12:07:14 +00:00
Meghna JaswaniandNicolas Lempereur 8df4bbf1ed [FIX] website{,_sale_link_tracker}: ecommerce graph today
The UTM graph data in Website > Dasboard > Analytics is not getting
properly filtered on the basis of values of date_from and date_to on
website_sale dashboard.

The field confirmation date which is of type datetime while date_from
and date_to are of date string in local browser timezone.

Hence date_domain is not perfect as shown below on local date 29th april
2019, we would send:

('confirmation_date', '>=', '2019-04-22'),
('confirmation_date', '<=', '2019-04-29')

But in reality we could want a from midnight of week before the current
UTC day, and to current UTC now or 23:59:59 of current UTC day.

This way, the data sent back matches more what is expected, instead of
the preceding domain, we would then have the following:

- if UTC now corresponding to local now is on '2019-04-29'

 ('confirmation_date', '>=', '2019-04-22 00:00:00'),
 ('confirmation_date', '<=', '2019-04-29 23:59:59')

- if UTC now corresponding to local now is on '2019-04-28':

 ('confirmation_date', '>=', '2019-04-21 00:00:00'),
 ('confirmation_date', '<=', '2019-04-28 23:59:59')

- if UTC now corresponding to local now is on '2019-04-30':

 ('confirmation_date', '>=', '2019-04-23 00:00:00'),
 ('confirmation_date', '<=', '2019-04-30 23:59:59')

And each one will be displayed as days 22 up to 29 in line chart (with
local today 29 being the last day of the chart and contening orders of
the current UTC day).

With these change in the UTM pie chart:

- a local date that is before a UTC date => we see the sales from up to
  today UTC instead of from up to before yesterday UTC

- a local date that is the same as an UTC date => we see the sale from
  up to today UTC instead of yesterday UTC

And in the line chart (that already had half of the fix in f6fc7c2319):

- a local date that is before a UTC date => we see the sales from up to
  today UTC instead of from up to yesterday UTC

- a local date that is after a UTC date => we see the sales of current
  UTC day + range of days (eg. for a week 7) instead of current UTC day +
  range of days minus 1 (eg. for a week 6).

opw-1971539
closes #33041

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>


Co-authored-by: Nicolas Lempereur <nle-odoo@users.noreply.github.com>
2019-05-03 11:29:34 +00:00
Christophe Simonis 6d4940675f [MERGE] forward port branch 12.0 up to ea1fc124ef 2019-04-09 11:11:48 +02:00
Christophe Simonis fef49061ea [MERGE] forward port branch saas-11.3 up to 4c61621efb 2019-04-08 19:52:29 +02:00
Christophe Simonis 4c61621efb [MERGE] forward port branch 11.0 up to 9a7e3c8b49 2019-04-08 17:45:00 +02:00
Martin Trigaux 02a321cffb [FIX] web: use specific font for Arabic, Hebrew and Cyrillic alphabet
The basic font-family offered on Odoo do not support a large set of characters
and rely on the system fonts for non-latin languages
On a system without specific fonts installed, the characters were replaced by �
For Hebrew, the system sans-serif font (at least on Windows pc) was too small.

Rely on the unicode-range range CSS descriptor to load a font only for a
specific range of unicode code.
https://developer.mozilla.org/en-US/docs/Web/CSS/%40font-face/unicode-range
This way, the fonts are ignored for English text (and you don't have to load
the fonts of every possible language).

Add Noto fonts that covers many charsets.
There is an heavy version for many charset and lighter ones for Arabic and Hebrew
More ranges can be added later

Serve the fonts on our CDN to avoid shipping several MB of fonts for everyone
but lazyload it when needed.

Fixes odoo/odoo#32228
Fixes odoo/odoo#21781
2019-04-15 12:14:14 +00:00
Nicolas Martinelli 8906807669 [FIX] website: submit form
Example where the issue occurs:
- Publish an event
- Go to the website, register for that event
- At confirmation, when the email address is requested, click quickly
  several times on the 'Continue' button

Several registrations are created since nothing prevents multi-clicks.

The stateful button feature of the `button.js` jQuery plugin has been
dropped in Bootstrap 4 (see [1]).

[1] https://getbootstrap.com/docs/4.1/migration/#buttons

opw-1958580

closes odoo/odoo#32571

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-04-15 06:29:05 +00:00
Christophe Simonis e145f2b0c8 [MERGE] forward port branch saas-12.2 up to 2694174b41 2019-04-10 15:10:24 +02:00
Christophe Simonis 6c8e30cae6 [MERGE] forward port branch saas-12.1 up to 6d4940675f 2019-04-09 12:16:06 +02:00
Odoo Translation Bot 7887dd8727 [I18N] Update translation terms from Transifex 2019-04-07 06:20:48 +02:00
Christophe Simonis 3f95b074e9 [MERGE] forward port branch saas-12.2 up to f2be461f09 2019-04-05 18:46:10 +02:00
Odoo Translation Bot 37378592db [I18N] Update translation terms from Transifex 2019-04-14 01:26:47 +02:00
Christophe Simonis f2be461f09 [MERGE] forward port branch saas-12.1 up to f2d0995362 2019-04-05 10:50:56 +02:00
Christophe Simonis d32420397d [MERGE] forward port branch 12.0 up to 251021796c 2019-04-04 11:20:03 +02:00
Martin Geubelle f391b8c5a5 [FIX] web_editor: restore ace style
The recent refactoring odoo/odoo@f296992 wrongly moved the ace editor
style from `web_editor` to `website`, even though ace is in `«eb_editor`.

The editor is also used in Studio (which does not depend on website) so
the style was missing in this case.

Task 1951290

closes odoo/odoo#32384

Signed-off-by: Christophe Matthieu <Gorash@users.noreply.github.com>
2019-04-03 12:46:57 +00:00
Kaushalya Mandaliyaandqsm-odoo 3f18d67f9e [IMP] website: improve customize dialog UI for font selection
Replace the font selection UI by a dropdown. Make the system generic
so that a dropdown can be used for any set of options.

task-1942241

closes odoo/odoo#32437

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>


Co-authored-by: qsm-odoo <qsm@odoo.com>
2019-04-30 14:30:09 +00:00
Sébastien Theys f159ba8f31 [IMP] tools,website: correctly handle favicon and .ico files
Previously the image that we uploaded as a favicon of the website was not
resized, so it could be extremely excessive in size and resolution, and it also
was not guaranteed to be a square.

Now we always resize it appropriately and save it as an ICO file.

The default favicon is now applied to all websites instead of only the first.

task-1958000
PR: #31811
2019-04-29 13:45:34 +00:00
Odoo Translation Bot 18c735361a [I18N] Update translation terms from Transifex 2019-03-31 06:20:38 +02:00
Christophe Simonis 28cce6ce3a [MERGE] forward port branch saas-12.1 up to c0cf4049b2 2019-03-29 19:47:46 +01:00
Christophe Simonis 2a06f4dcf3 [MERGE] forward port branch 12.0 up to 09fb2469b4 2019-03-29 18:10:57 +01:00
Nicolas Lempereur f2c301557d [FIX] website: "Visits" no overlap "active users" in dashboard
The current style on "Active users: {number}" placed it 60 pixels over
were it should be, so this was:

- overlapping "Visits" title
- not sparing vertical size (since we use "position:relative")

opw-1961605
closes #32245

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-03-29 12:53:12 +00:00
Martin Trigaux 0f6038e777 [I18N] *: export 12.0 source terms
Some changes were not reflected in 12.0.
Changes made in .pot in previous versions were not forward ported

Closes odoo/odoo#32238
2019-03-29 10:39:17 +00:00
Odoo Translation Bot 4ccdddcf6b [I18N] Update translation terms from Transifex 2019-04-07 01:27:03 +02:00
Odoo Translation Bot 610ab82b51 [I18N] Update translation terms from Transifex 2019-04-07 03:14:49 +02:00
Nicolas Lempereur 8557bcfa30 [FIX] website: language prefixed URL on website bis
Reintroduces 5324284f5 that was reverted because in the case of an URL
like /payment_stripe/static/src/js/stripe.js directly inside a QWeb
template, we would possibly get:

  /fr_FR/payment_stripe/static/src/js/stripe.js

Which is not accepted by werkzeug SharedDataMiddleware we use to serve
static data in /{module_name}/static/ directories.

Added test without changeset failed with:

- test_process_att_no_request_lang: <AssertionError>
  line: self._test_att('/en_US/', {'href': '/'})
  wrong result: {'href': '/en_US/'}
- test_process_att_with_request_lang: <AssertionError>
  line: self._test_att('/', {'href': '/fr_FR/'})
  wrong result: {'href': '/'}
- test_process_att_matching_cdn_and_lang: <AssertionError>
  line: self._test_att('/en_US/a', {'href': 'http://test.cdn/a'})
  wrong result: {'href': 'http://test.cdn/en_US/a'}
- test_process_att_no_route: <AssertionError>
  line: self._test_att('/my-page', {'href': '/fr_FR/my-page'})
  wrong result: {'href': '/my-page'}
- test_process_att_url_crap: <IndexError: list index out of range>
  line: request.httprequest.app._log_call[-1],

opw-1922051
closes #32095

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-04-02 14:45:24 +00:00
Odoo Translation Bot 1b932b339a [I18N] Update translation terms from Transifex 2019-03-24 06:23:04 +01:00
Antoine Guenet 1d5daff152 [FIX] web_editor: prevent overriding of toolbar CSS by themes
While waiting for a larger fix of the themes, force prevent overriding
of the web editor's UI CSS by themes. This is achieved by applying
`!important` on all web editor UI CSS. This is a temporary fix until
the themes CSS is fixed and/or the new web editor library is ready.

closes odoo/odoo#31721

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-03-21 12:57:57 +00:00
Christophe Simonis 4eff0af02e [MERGE] forward port branch saas-12.1 up to 6878c9f342 2019-03-21 13:58:37 +01:00