Commit Graph
10944 Commits
Author SHA1 Message Date
Romain Derie 98678199a3 [FIX] *: fix translations inconsistency in 't-set'
This commit fix most `t-set` errors that either led to:
  1. unwanted text to be considered as translatable.
     eg: `<t t-set="classes">text-left bg-100 p4</t>` would create an
     `ir.translation`.
  2. text that should be translatable were not.
     eg: `<t t-set="text" t-value="'Both'"/>` would not create an
     `ir.translation` while it should.

If a text should be translatable, it should never be inside a `t-value`:
  - `<t t-set="text">Both</t>`
If a text should not be translatable, it sould either be inside `t-value`,
`t-valuef` or the `<t>` tag should have `t-translation="off"`:
  - `<t t-set="classes" t-translation="off">text-left bg-100 p4</t>`
  - `<t t-set="classes" t-valuef="text-left bg-100 p4"/>`
  - `<t t-set="classes" t-value="'text-left bg-100 p4'"/>`

https://github.com/odoo/odoo/pull/43660
https://github.com/odoo/enterprise/pull/7839
https://github.com/odoo/design-themes/pull/203

closes odoo/odoo#43660

Related: odoo/enterprise#7839
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2020-01-21 15:32:08 +00:00
Aaron Bohy 7ab364b627 [IMP] web: properly throw errors in MockServer
Otherwise, they could be catched (by a guardedCatch) and thus would
not make the test fail.
2020-01-21 11:59:22 +00:00
Aaron Bohy 50bf8309f8 [FIX] web,*: fix race condition with m2o quick create
*sale,sale_product_configurator

Let's assume a form view containing a many2one with an onchange
that updates the value of a one2many. Do a quick create in the
many2one. While the name_create request is pending, add a row to
the one2many but do not leave it. When the name_create returns, and
the onchange has been performed, the one2many is reset, and the row
is no longer in edition (worse, it could be invalid, i.e. in a state
that the user could not have reached in a normal situation).

This commit fixes this issue by considering the whole [name_create +
onchange] operation as one. This operation is executed in the mutex
of the model, so the other request (adding a row to the one2many) is
delayed until the many2one value has been correctly set.

This fixes an issue with the sale and rental tours (on sale_order),
that had been deactivated for a while.
2020-01-21 11:59:22 +00:00
mcm-odoo 01e3a5996f [REF] web: pivot: use owl_compatibility tools
This commit changes ControllerAdapter to a mixin that inherits
WidgetAdapterMixin and RendererWrapper now extends ComponentWrapper.

This commit also changes PivotController base class/mixin and uses
the Odoo legacy custom_events because of the adapter.

closes odoo/odoo#43256

Related: odoo/enterprise#7744
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-01-21 10:22:50 +00:00
mcm-odoo 083ba2a811 [IMP] web: WidgetAdapterMixin: add some tests 2020-01-21 10:22:50 +00:00
Aaron Bohy ed0b5c2638 [IMP] web: add a few WidgetAdapterMixin tests 2020-01-21 10:22:50 +00:00
mcm-odoo a8e65f22ed [IMP] web: Owl compatibility: add WidgetAdapterMixin
and ComponentWrapper

This commit adds the necessary tools to use when an Odoo legacy
widget has to instantiate Owl components.
2020-01-21 10:21:08 +00:00
Aaron Bohy 671a5471cd [IMP] web: Owl compatibility: add ComponentAdapter
This commit adds the ComponentAdapter, an Owl component meant to
be used as universal adapter for Owl components that embed Odoo
legacy widgets.

This component will be a precious tool during the transition phase
of converting our JS codebase from the legacy (widget) framework to
Owl.
2020-01-21 07:17:31 +00:00
Aaron Bohy 45246a3b96 [FIX] web: utils: fix typos in patch and unpatch
The use of 'this' to call other utils adds a restriction on the
way utils are called from the outside:

  utils.patch(...); // works fine

  const patch = utils.patch;
  patch(...); // doesn't work
2020-01-21 07:17:31 +00:00
51b36c3dbb [IMP] base: add default image for users + placeholder if unassigned
1/ When the new database is created without demo data, the admin has a
   'silhouette' as a default picture. When a new user is created without
   picture given by the current user, the new user will have a 'silhouette'
   as a default profile picture.

2/ web: image for fa-user-slash. This image will be used when a record is
   unassigned.

3/ web, *: Change placeholder by default when record is unassigned.
   We want to have a fa-user-slash icon when a record is unassigned instead
   of 'placeholder.png'. A method is created in the BaseModel to have a
   generic method to change easily the placeholder for other models.

4/ Adapt kanban test to keep the same behaviour. Attention the behaviour is
   a bit different. Because, now the default image is given by the server to
   change easily the default image when a record doesn't have an image.
   Thus, we don't say if it's the default placeholder, but we can say it's
   not the same image of the record (in this test, the record, it's the
   partner).

5/ misc: display 'Unassigned' in the hover on kanban cards if record is unassigned

closes odoo/odoo#41356

Taskid: 2060206
Related: odoo/enterprise#7758
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: jdoutreloux <jud@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
2020-01-21 09:22:46 +00:00
qsm-odoo 54a95099bf [REF] web: remove custom frontend code since done by crashmanager
The handling of unhandledrejection in the frontend was done with
dedicated code since the crashmanager was not in the frontend. This is
the case now so that dedicated code became useless.

closes odoo/odoo#42927

Signed-off-by: fja-odoo <fja-odoo@users.noreply.github.com>
2020-01-08 11:41:33 +00:00
David Beguin 860768b79b [IMP] portal, web: move wrapwrap flex style rules from portal to web
This commit moves the flex rules of #wrapwrap div to web so it can be used in
survey.

This is needed to make the survey footer stick to the bottom of the screen
even if main has not enough content to fill the page.

This commit prepares survey redesign.

Task ID: '2150291'
PR #43237
2020-01-17 14:54:58 +00:00
Nicolas Lempereur b048a6fc27 [FIX] web: widget noreset if rerendered for modifier
If we have a many2many_tags widget that is writable then becomes
readonly, we can have in the code this chain of event:

- get list of widgets we need to reset some data for
- apply modifiers
- reset the widgets

but applying modifiers can delete a widget (eg. an editable field that
becomes readonly), so when resetting we could call code on a deleted
widget which caused an error.

For example, if we have an attribute:

 `<field widget="many2many_tags" attrs="{'readonly': 'condition'}"/>`

if the field goes from editable to readonly and is affected by an
onchange, we will call `setIDForLabel` on the deleted instance of the
widget which will cause an error.

Added test without fix fails with error:

  TypeError: Cannot read property 'attr' of undefined
    at Class.setIDForLabel (/web/static/src/js/fields/abstract_field.js:324:35)

because as said, the function is called on the editable widget that is
removed and replaced with readonly widget at that point.

opw-2154471
closes #43137

closes odoo/odoo#43244

X-original-commit: 6f5ca16524be7c5bb45b03e7421154a20edc4cf6
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-13 17:59:30 +00:00
Julien Mougenot dc716ea42b [ADD] web: add getCookie in test_env
Allow components to access a default empty function when calling getCookie.

closes odoo/odoo#43125

Related: odoo/enterprise#7643
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-15 11:31:17 +00:00
Julien Mougenot c146af8a6d [REF] web: home menu template event names to kebab
Changed the event names to comply to Owl standards.
2020-01-15 11:31:17 +00:00
Pierre Rousseau 1900abf233 [FIX] web: correctly manage attach-detach callback
d06e67e748 introduces tools to use owl renderer
for a view. However, on_attach_callback and on_detach_callback were not
called on super (AbstractController), so not applied to the controlPanel
and searchPanel.
This commit fixes this issue

Task-ID 2171436

closes odoo/odoo#43165

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-14 10:26:31 +00:00
Pierre Rousseau a44d7722bc [FIX] web: correctly destroy owl renderer
d06e67e748 introduces tools to use owl
renderer in a view. However, this owl renderer is never destroyed.
This commit fixes this issue.

Task-ID 2171436
2020-01-14 08:38:24 +00:00
Jason Van Malder d758596911 [FIX] sale, web: fix product quantity display in ecommerce
Issue

    - Install eCommerce
    - Select Zap theme
    - Go on a product in the shop

    The quantity is hidden behind the buttons
    The quantity height is not the same than the buttons

Cause

    By default, there is a max width of 125px on the div containing
    the buttons and the quantity label. As this theme increase the
    button size, the quantity is hidden.

    The quantity label has `.form-control` class who override
    his height, so it's not using flex anymore.

    More details from QSM in design-themes closed PR #199:
        Bootstrap is not correct about input-group form-control height
        -> bootstrap_review.scss fix for the height of input-group
           form-controls

        Our max-width on css_quantity is not right, it should be a
        max-width on the internal input

Solution

    Restore the initial height in bootstrap_review for input-group form
    control

    Set the max-width only on the internal input.

OPW-2166311

closes odoo/odoo#43099

X-original-commit: 81e06ec43fdf90758556a654cedd75001ff654c1
Signed-off-by: Jason Van Malder <jvm-odoo@users.noreply.github.com>
2020-01-14 08:28:27 +00:00
Romain Estievenart baf5ec854c [MOV] base,web: move "base settings" mobile related code
This code is not useful since https://github.com/odoo/odoo/commit/9831ed08fe
Note that this part of code will be refactored in web_enterprise.

Task ID: 2085899

closes odoo/odoo#38499

Related: odoo/enterprise#6077
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2020-01-13 13:25:01 +00:00
Romain Estievenart a077985123 [MOV] web: move "kanban view" mobile related code
This code is not useful since https://github.com/odoo/odoo/commit/9831ed08fe
Note that this part of code will be refactored in web_enterprise.

Task ID: 2085899
2020-01-13 13:25:01 +00:00
Ipsita Borisagar 7ecae33571 [IMP] mail, web: add the activity icon on partner kanban card
This commit adds "Next Activities" on kanban card of partners,
like on the app Contact.

Task-Id 2152180

closes odoo/odoo#41793

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-01-13 11:46:40 +00:00
Julien Mougenot 1d58b76032 [FIX] web: correctly handle display/hide of dialogs
Before this commit: all dialogs would go through the static method (OwlDialog.hide)
when destroyed, regardless of wether they had been opened or not.

Now, only dialogs having an 'el' property set (= having been opened) will use
the 'hide' method.

Task 2170705

closes odoo/odoo#43124

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-01-10 12:48:41 +00:00
Alexandre Kühn b58c649d72 [FIX] web:tests: remove promise constructor antipattern
Revision on https://github.com/odoo/odoo/commit/141b34f152f36d970d4ff78abe53f563555a8e69

Having async/await as a new promise constructor is an antipattern.

The reason is that it may lead to unnoticed errors: if an inner
promise is rejected, it won't propagate the error to another promise
that will handle the error. As a result, this error becomes unnoticed
and the initial promise is pending indefinitely, which also may lead
to more bugs [1].

[1] https://stackoverflow.com/a/25569299

Closes #43072
2020-01-13 10:13:10 +00:00
Andrea Grazioso (agr-odoo) bbe944c829 [FIX] web: avoid parsing value if already number
When accessing stock_barcode module to validate pickings, is not
possible to add floating point quantities for any localizaton which uses
',' as decimal separator.
The numeric field is now defined via browser tags <input="numeric"> to
make the numeric keyboard popup automatically on mobile devices
(commit 8f5840369b28962ab2be9edfce7331a836c3df22)
Adding the override to avoid further processing when the input
is already anumber

opw-2154657

closes odoo/odoo#42748

X-original-commit: 1ccc60deeb067f8d461d48cbf51719317c22cb90
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-06 12:16:10 +00:00
Adrien Dieudonne f62d91670b [FIX] web: burger menu isn't automatically closed
This commit reverts a previous fix because we found a better one
in enterprise.
So we don't need this line anymore.

opw-2071605
Task ID: 2152160

closes odoo/odoo#43102

Related: odoo/enterprise#7647
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2020-01-10 09:19:29 +00:00
Jason Van Malder 6bb1a8cd61 [FIX] web: fix planning roles filter disappearing
Issue

    - Install planning
    - Go on a planning view where you have 2 filters (employee/roles)
    - Unselect all items of one filter

    All the filters disappear.

Cause

    By doing this:

    ```
    if (!_.find(options.filters, function (f) {return f.display == null || f.display;})) {
        return;
    }
    ```

    We break the function's recursion:
    ```
    return self._renderFiltersOneByOne(filterIndex + 1);
    ```

    So the others filters are not rendered.

Solution

    Return the next filter rendering instead of nothing.

OPW-2166932

closes #42703, closes #42433

closes odoo/odoo#43025

X-original-commit: dbab68a92ec48b2bb6f21244af1de56691cb43f1
Signed-off-by: Jason Van Malder <jvm-odoo@users.noreply.github.com>
2020-01-09 11:54:05 +00:00
Julien Mougenot 3c5194a00b [ADD] web: Custom File Input
New component: the custom file input. Its purpose is to define a input of type file
with a custom trigger (button, link, etc.).

Its construction is the following:
- attributes: behaviour of the actual input (route to call, multifile, allowed
    extensions etc.)
- inner template: the trigger that will fire the upload prompt when clicked
Once a file has been uploaded, the component will emit a 'uploaded' custom event
containing the files.

closes odoo/odoo#38423

Related: odoo/enterprise#6031
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-01-06 14:37:16 +00:00
Julien Mougenot 34bbdd88c0 [ADD] web: Owl Dialog
New Owl component: Dialog. It does not rely on Bootstrap but behaves the same
and does not conflict with legacy dialogs.
To call this component, you need to define it in the XML parent template instead
of calling it in the JS file, and put a flag in the parent state to toggle the dialog.
Old dialog file has also been slightly updated to ensure compatibility between both
versions.

This commit also updates a list view test which did not wait for click events to
properly trigger and would cause the new dialog system to crash.
2020-01-06 14:37:16 +00:00
Julien Mougenot ab37648cb1 [ADD] web: useFocusOnUpdate hook
Added a new custom hooks: useFocusOnUpdate.
This hook returns a function taking a DOM selector as an argument.
That function will focus the first matching element on the next repaint of
the component.
2020-01-06 14:37:16 +00:00
Julien Mougenot 3cf49e1913 [IMP] Owl: update to 1.0.0-beta5
Update of the Owl library.
Also added "_lt" to the default test environment properties.
2020-01-06 14:37:16 +00:00
malex-emesa b02c46c5ae [FIX] crm: check if name is present in measures
Fix an error which occurs during an attempt to access the string
attribute of a non existing measure
If a pivot view is defined with a "string" attribute of a field of
type "row", e.g.

   <field name="stage_id" string="Stage" type="row"/>

an error was raised "TypeError: measures[name] is undefined"

closes odoo/odoo#42971

X-original-commit: de1dbc9bfba3ec205c75590d3e38b20d30b39c39
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-01-08 15:47:09 +00:00
wan c1e3439462 [REV] web: remove absolute position on autoresize
Reversal of ef46378cd3
The bug we tried to fix with the reverted commit was fixed by 3023cd24af
but it was causing other issues, like the text field translate button
badly positionned

closes odoo/odoo#42953

X-original-commit: d98dde0704f04e1e929bc689fe00814142a9cd40
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-08 14:11:45 +00:00
Jason Van Malder ddfa8768cc [FIX] web: fix question error message translation
Issue

    - Take a v13 runbot
    - Open survey's app
    - Open one of the surveys
    - Click on edit
    - Click on a question
    - Open 'option tab'
    - Make sur the field 'mandatory answer' is true
    - Try to translate field 'error message'

    -> Error

Cause

    this occur because because we try to update the model survey.question
    from the list coming from survey.survey which mean that the
    record.viewType is list and not form.

Solution

    As we are looking for the field name we can simply use
    ev.data.fieldName.

    Another solution should be to use this.viewType instead of the record
    one.

OPW-2157631

closes odoo/odoo#42952

X-original-commit: ad115d2710aec2b4ff7d4077714a1816cdfb433e
Signed-off-by: Jason Van Malder <jvm-odoo@users.noreply.github.com>
2020-01-08 14:10:19 +00:00
Mohammed Shekha 5c7892fe6b [IMP] web: update pdfjs to 2.2.228
after this commit:
Worker disable is no longer supported by pdfjs since version 2.0, so
remove disabling worker code.
Used pre-built version of pdfjs as source version dependency with other
lib like SystemJS and we can not add dependency of these libs, so used
pre-built version which don't require any other dependent lib.
pdf.worker.js is always loaded and as we are using pre-built version we
don't need odoo's loader, previously we need it because worker loader of
pdfjs was loading files separately so to avoid it as we were loading
files in asset bundle we had odoo's loader file but we don't need it
anymore.

task-2124443
2020-01-07 05:21:22 +00:00
Debauche Stéphane e3ff893bb7 [MOV] web: move the widget `color_picker` from "planning" to web
Task #2088538
2020-01-08 09:11:50 +00:00
Carlos MayoandAaron Bohy 9f49709ef3 [FIX] web: many2many_checkboxes: react to domain changes
Let's assume a many2many_checkboxes widget in a form view with a
dynamic domain (depending on another field in the view). At first
rendering, the widget contains a checkbox for each value matching
the domain.

Before this rev., if the user changed the value of the field used
in the domain, the many2many_checkboxes wasn't redrawn, so it still
displayed the values matching the previous version of the domain.

Closes #38509
Closes #40173

closes odoo/odoo#42867

X-original-commit: 1ace56f9a8cb56fb39235468dd13447bcbbee40a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-01-07 14:37:06 +00:00
Julien Mougenot 2e861cc8ee [FIX] web: boolean widgets in list views
Before this commit, pointer events were prevented on all checkboxes in readonly
list views. That meant that the boolean_toggle widget for instance could not be
properly toggled in a non-editable list (which was the purpose of such a widget).

Now, pointer events are enabled only if the checkbox :
- is in a selected row AND does not have a readonly modifier
    OR
- has a widget applied on the field.

Also ensured that the field widgets in the list view multi edition confirmation
modal are not interactive.

We cannot test the `pointer-events` property interactions as it does not affect
manual event triggering used in tests.

Task 2154055

closes odoo/odoo#42848

X-original-commit: c7ee164d572e01fcb565001fd5e62fe1278b5cd8
Signed-off-by: Julien Mougenot (JUM) <Arcasias@users.noreply.github.com>
2020-01-07 12:49:33 +00:00
Arnaud Joset c411bdfe4d [FIX] web: human readability of negative numbers.
Before this commit, negative numbers are never rendered as human readable (e.g. 34000 -> 34k).

closes odoo/odoo#42789

Taskid: 2160790
X-original-commit: b51877c4c4c9d8cd873dd0205954fd807d62ee01
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-06 15:46:28 +00:00
Tiffany Chang (tic) 3e37ec8844 [IMP] web: add 'create' attribute to calendar view
Previously it was always possible to create within the calendar view.
For some modules this did not make sense and lead to confusing behavior,
for example: a new model instance created in the calendar view that was
not viewable in the calendar view, but was viewable in other views. By
adding a 'create' attribute (to be used in view xml), we allow users to
choose whether or not they want a calendar view to be able to create.

Note that this change does not affect the edit ability of calendar views
for existing instances.

Part of
Task: 2126530
2020-01-03 10:34:54 +00:00
Laurent Mignon (ACSONE)andAaron Bohy ae7f574e54 [FIX] web: calendar: allow to use fields.Reference
Before this change, fields.Reference displayed into the popover of
a calendar view was always empty. This was because the popover view
generated from a double click on an element in the calendar view
creates its own recordModel in JS and the function to create this
record did not handle the reference field case.

This commit detects if a reference field is defined into the record
and adds the necessary processing to process its value and creates
the corresponding dataPoint.

opw 2151635
Closes #41262

closes odoo/odoo#42707

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-01-03 15:46:17 +00:00
Aaron Bohy 1e3f688256 [FIX] web: form: fix broken layout with o_td_label
Rev. bc131c0cfb aimed to handle the case of several
(conditional and exclusive) <label> tags for a same field.
The idea was to wrap those <label> tags into a div with
className 'o_td_label' (typically set by the framework), and
let the framework move it to the td wrapping the div.

However, it causes an css issue (only in community), as the
presence of two o_td_label classnames (one on the td, and
one on the div), produces two right borders.

This commit fixes the issue by removing the classname on
the div (we simply 'transfer' it to the td).

Closes #42589

closes odoo/odoo#42667

X-original-commit: f71979a681d95d98db19a80feb59fdf684ec361f
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-03 09:18:09 +00:00
Adrien Dieudonne 67721931f9 [FIX] web: avoid horizontal scroll on kanban mobile
Steps to reproduce:
1. Open 'Project' on mobile
2. You can scroll x while the content fit the screen.

This issue occured because of negative margins on
'o_kanban_manage_toggle_button' class.
In general, using negative margins should be avoided.

So in this commit we simply avoid to have negative margins by
removing unwanted borders. It keeps the same design.

Similar issue:
https://github.com/odoo/enterprise/commit/805ab4d4a329c0fdf7d1cade6c5d7e8428f3a634

closes odoo/odoo#42518

X-original-commit: 38702215e6dff4e562a389ec03cdeb8683cd111c
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2019-12-30 18:04:57 +00:00
Vishnu Thuletiya acc063f870 [FIX] web: my profile opens in background on mobile
Purpose of the task is, in mobile view when you click on my profile button it
open profile in back ground and menu(burger menu) will stay open.

so close the burger menu in mobile when clicks on my Profile or Preferences.

Task: 2152160
Closes: #41899
Enterprise PR: https://github.com/odoo/enterprise/pull/7275

Related: odoo/enterprise#7275
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-12-17 05:00:47 +00:00
Jason Van Malder f8f872c7c2 [FIX] web: fix M2M tags rendering
Issue

    - Install CRM & Studio
    - Edit CRM kanban view
    - Add tags > select "tags"

    Traceback

Cause

    _render is called multiple times, there is one case where
    `this.$el` is undefined.

Solution

    Checking if `this.$el` exists before using it.

OPW-2156964

closes odoo/odoo#42382

X-original-commit: 05f31289c1bb1d8c4b8e1f72f519e8e35e5ecb8c
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-12-26 10:01:27 +00:00
Damien BouvyandRaphael Collet 220eb4db39 [IMP] base, web: support x_active for archiving
While x_name has long been automatically supported as an equivalent
of name, x_active was not.

This commit adds this behaviour OoB, both in the ORM and the web client.

On the ORM-side, a new `_active_name` attribute is supported on models.
This attribute specifies the field that should behave as an active marker
for records of the model. It is supported the same way `active` has been
until now (filtering by the `active_test` context key and toggled by the
`action_archive`, `action_unarchive` and `toggle_active` methods).
Although no check has been added on the field's type, it is assumed to
be a boolean field (the same way no check is present on the `(x_)name`
field).

On the client-side, the list view and form view now both support
detecting the presence of either `active` or `x_active` on records,
automatically adding an '(Un)Archive' button in the Action menu if such
a field is detected.

Note that the ORM implementation does actually need the field to be named
in any specific way, but since the web client has no mechanism to load
information regarding a model (the lifecycle of an action loading
includes loading the action, view and record(s) but no generic
information about the model itself besides what is included in the
views), we restrict the field's name to `(x_)active` to avoid confusion
as any other name would work at the ORM-level but not in the client.

In the future, the client might be able to more elegantly get
information about models, but this was not the scope of this change and
this solution should cover most cases.

Note that the `active` field will always takes precedence over the
`x_active` field to avoid confusing the polarity, even if both fields
are present on the model.

In the case of a custom field, it might be slightly annoying that the
default value of a Boolean field is `False`, which means that upon
adding the column, all existing records are automatically archived. This
can easily be worked around using an `ir.default` record for that
particular field and an update of existing records (e.g. through the
list view). The goal of this change was not to make it easy to add
support for custom active fields, but to make it possible - we have
therefore kept this implementation which introduces few changes while
adding enough flexibility for developers.
See https://twitter.com/zubair_shafiq/status/1202587553871880192?s=20
for more info regarding supporting any `_active_name` in the web client.

Co-authored-by: Raphael Collet <rco@odoo.com>
2019-12-20 11:16:01 +00:00
Alexandre Kühn 141b34f152 [FIX] web: tests: nextTick awaits render with requestAnimationFrame
Revision on [1].

Commit above made changes to test helper `nextTick()`, so that it
waits for `window.nextAnimationFrame()` (shorten, 'rAF'). This was
useful to wait for OWL rendering, since OWL renders on next animation
frame.

From a theoretical standpoint, the helper should wait at least as
much time as before, as it adds either no slowdown (rAF is readily
available), or a few milliseconds wait (rAF waits for next available
animation frame).

However, some old tests show non-deterministic behaviours, resulting
to crashes [2]. It suggested, for some reasons, that `nextTick()` did
not wait long enough for re-render... Which is surprising considering
explanation above!

Some of these tests have been fixed, assuming it was caused by un-
guaranteed order of successive `setTimeout(0)` [3]. Unfortunately,
this does not explain why it never crashed before the change on
`nextTick()`...

After investigation, we think that this behaviour comes from rAFs
having their own task queue, which no longer guarantees that queued
tasks happen after queued micro-tasks:

When the requested next animation frame is readily available, the
callback of `requestAnimationFrame()` is immediately called and waits
for `setTimeout(0)`. The `setTimeout(0)` await is resolved before any
other queued async micro-tasks, so that `nextTick()` is resolved
sooner than expected. This would explain how `nextTick()` does not
wait long enough for rendering from the loads of resolved Promises,
even though there is a promise resolution after `setTimeout(0)`.

This commit fixes the issue by moving the await `setTimeout(0)`
before the rAF call, so that it correctly waits render from chain of
resolved promises (since the `setTimeout(0)` is awaited in the same
main task queue).

[1] https://github.com/odoo/odoo/commit/b0941d19a07b08fabc64a284b58e57edc46203dd
[2] http://runbot.odoo.com/runbot/build/771505 and http://runbot.odoo.com/runbot/build/752855
[3] https://github.com/odoo/odoo/commit/6cbfdbce2d0f1b567b6a6d6f637fe2a476980acc

closes odoo/odoo#42123

Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-12-20 09:53:26 +00:00
Damien Bouvy febd360ff0 [FIX] web: color for calendar views without color attribute
The `color` attribute allows specifying a field by which the calendar
view will color the event entries in the view.

In views where this attribute is not defined, the event was instead
given the `text-white` class, which rendered the event invisible in the
calendar, save for a slight left-border.

This commit just use the 1st color class by default in such cases,
ensuring all events are visible.

opw-2145652

closes odoo/odoo#42200

X-original-commit: 375b34be6ef198753f52a650159edee4d1883006
Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
2019-12-19 16:06:04 +00:00
Adrien Dieudonne 4e2fb178ce [FIX] web: too small tap area for optional columns dropdown on mobile
Before this commit, users encountered some difficulties to tap/click
on the "optional columns" dropdown in list views.
This issue only occured on Chrome: rather annoying to use the mobile app.

"width: 10px" was used in inline list view but didn't have any sense
in the other case. Worse still, Chrome miscalculated the size of the
clickable area by a smaller one.
This is due to the fact that we add some padding that exceed 10px.
See:
https://github.com/odoo/enterprise/commit/2f1320557ec67a741201d73a23a9782ec8f9b3bb#

opw-2071605

closes odoo/odoo#42210

X-original-commit: 28b6e9c99c77230dc19808718cd6f6f8aec0db5d
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2019-12-19 16:46:14 +00:00
Mathieu Duckerts-Antoine 9d539cd8c5 [FIX] web: take care of "groups" attribute in search view arch
The attribute "groups" on filters and fields in a search view arch was not taken
into account anymore.
Now items that should be invisible are not anymore available for selection
in the interface (as expected) but are still activable as search defaults
(and the corresponding facets appear if needed).

Task ID: 2081450

closes odoo/odoo#42125

X-original-commit: ca2514a9fbcd693752367cb566d5c11165b40bd4
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2019-12-18 13:13:10 +00:00
Alexandre Díaz 37138a8977 [FIX] web: Changed mobile message html element in multi-company dropdown
Without this commit the multi-company dropdown breaks the page on mobile

closes odoo/odoo#42080

X-original-commit: e074dca861bedb89952d3788e711e261ce903295
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2019-12-18 02:17:04 +00:00