Commit Graph
1383 Commits
Author SHA1 Message Date
Christophe Simonis 362f0489d0 [MERGE] forward port branch 11.0 up to fe22a0f9ca 2018-01-03 12:28:52 +01:00
Alexandre Kühn 8bc7cebd9c [IMP] web: many2many editable list with X remove icon (#20978)
In many2many lists, the remove record from the widget is a trash bin.
It is confusing, as people feel they are deleting it when they are
only unlinking it.

So in many2many, we propose to change the trash icon by a 'X'.

This icon appears in many2many relations and in many2many widgets:
even though hr.expense.sheet defines the expense lines as a one2many,
it uses a many2many widget, so we use a 'X' instead of the trash bin.

To avoid ambiguity, we decided to rename 'delete' to 'remove'.
2018-01-03 11:42:39 +01:00
Sanjay Jamod a8527a16b6 [FIX] web: Fix column_invisible issue (#21693)
[FIX] web: Fix column_invisible issue

This commit fixes an issue with the column_invisible attribute.

When we choose product variant for BOM for any particular product, 
at that time from the BOM Lines column "Apply on Variants" is hidden,
but when we unset product variant from BOM Form, 
at that time the column 'Variants" set to visible. but in this case, it is set to hidden always.

PR 21693, OPW 779555
2018-01-02 16:37:35 +01:00
Sanjay Jamod 0c1fc0b911 [FIX] web: Fix column_invisible issue (#21693)
[FIX] web: Fix column_invisible issue

This commit fixes an issue with the column_invisible attribute.

When we choose product variant for BOM for any particular product, 
at that time from the BOM Lines column "Apply on Variants" is hidden,
but when we unset product variant from BOM Form, 
at that time the column 'Variants" set to visible. but in this case, it is set to hidden always.

PR 21693, OPW 779555
2018-01-02 16:33:45 +01:00
Nicolas Martinelli 88afd055cf [FIX] web: currency digits
- Set the currency rounding to 0.001 (3 digits)
- Create an account move
- Add an account move line, set an account

When switching from edit/read-only mode, the rounding switches from 2 to
3 digits.

This is because, in edit mode, the format method is the method of the
float widget. Therefore, in this case, the formatting doesn't take into
account the currency rounding.

To avoid this, we simply use a `noSymbol` flag to avoid adding the
currency symbol, while keeping the monetary rounding.

opw-800279
2017-12-29 09:20:18 +01:00
Christophe Matthieu 091c86c21b [FIX] web: unselect row before resequencing in editable list
If a row is being edited, this row will be refocused when performing changes
(i.e. resequencing records). It can cause an issue if an onchange modifies the
record being focused.

To avoid this issue, the row is unselected before resequencing records. The row
isn't selected anymore but this behaviour wasn't expected anyway.
2017-12-28 12:08:12 +01:00
Christophe Matthieu 1c7e0df5a5 [FIX] web: deal with same sequence in editable list
Resequencing records with the same sequence wasn't correctly working in the
editable list because we only care about the range between the swapped ids. In
some cases, this isn't good enough.

For example, if we have the records 1,2,3 with sequence field = 10,10,10, then,
swapping records 1 and 2 should lead to resequencing 3 with the sequence values
11,10,12 (to guarantee that the third item is after the previous 2).

Resequence now checks if the list increases or decreases without interruption
to create the subset that must be changed ; otherwise the whole list is changed.
2017-12-28 12:05:25 +01:00
Aaron Bohy 4f4e686fb2 [FIX] web: graph: don't lose initial groupby at reload
Before this rev., when a graph view was reloaded (e.g. by clicking
on the graph view switcher), the inital groupby was lost if it
didn't come from the searchview (i.e. if it came from the context
or from the arch). For instance, go to Sales > Reporting > Sales
(the view is grouped by 'date', and there are two groups), reload
by clicking on the graph view switcher: there is only one group
left.

The reload RPC was actually fine. What was wrong is the 'state'
object given to the renderer after the reload, as it didn't contain
the correct groupby, so the view wasn't correctly re-rendered.
2017-12-22 15:43:04 +01:00
Nicolas Lempereur 46cf7f17a3 [FIX] web: resequence Undefined column w/ 12048bd6
There is a drawback in 12048bd6, if a kanban view with an
"Undefined" column (exist when a kanban view grouped on a relational
field and some record have this field unset) had a column resequenced a
traceback would happen if more than one column was displayed.

This happen because before we had a "undefined" ID for the "Undefined"
column and after 12048bd6 we get a framework unique ID which was not
managed.

note: this commit also adds `left`/`right` values in the dragAndDrop
test utility function so an element can be dropped at the right/left of
another element.

related to opw-782433
closes #21708
2017-12-19 14:51:40 +01:00
Géry Debongnie dbdd742d20 [FIX] web: better mode handling, prevent useless work in some cases
Before this commit, the way mode was handled was not optimal.  The end
result was correct (the widget were properly created/displayed in
edit/readonly as required), but useless work was done.  In particular,
if we have list/x2manys with widgets and modifiers, it could happen that
widgets were created in edit mode, then destroyed and recreated in
readonly mode.

This could happen in some important views, for example, any view with a
field many2many_tags with a readonly modifiers (pretty much all views
handling taxes)

In this commit, we add a 'editable' attribute to list renderer.  This is
necessary, because the list renderer is not actually editable when it is
in a x2many in a form view which is in readonly mode.  Also, we need to
manage the distinction between the fact that a list view is editable,
and the fact that some widgets are created in edit and other in readonly
mode, depending on modifiers, and on which line is being edited.

We also add a benchmark (courtesy of CHM) to be able to measure the
performance impact of edit/readonly/onchange in a larger form view.
Before this commit, running this form benchmark on my machine gave a
number of 0.4 op/sec, and after, it increases to 1.26 op/sec, so a
pretty large improvement.
2017-12-18 17:29:14 +01:00
Géry Debongnie fa9f58d6ce [IMP] web: tests: add a way to properly mock Widgets
This rev. introduces two helper functions for the tests: patch
and unpatch. Those function allow patching an Odoo Widget (e.g.
AbstractField), and unpatch it at the end of the test with the
guarantee that the Widget's prototype is exactly the same as it
was before the test.

This was necessary because the way it was done before was a little
bit too naive, and could lead to unexpected behavior. Indeed, doing

 var someFunction = AbstractField.prototype.someFunction;
 // test content
 AbstractField.prototype.someFunction = someFunction;

is correct if someFunction is actually define (or overriden) in
AbstractField, as in that case, it really exists on its prototype.
Otherwise, it isn't correct if it is not directly defined on the
prototype before the test, as it will be after..
2017-12-18 17:29:13 +01:00
Nicolas Lempereur bed48ad960 [FIX] web: mobile tab wrong if "Undefined" column
If a kanban view is grouped on a many2one, records with the field unset
are displayed in a column "Undefined" displayed first.

But the tab in mobile view doesn't respect this, so we can get:

columns: Undefined colA colB
tabs: colA colB Undefined

So we always get always on the wrong column wrong when clicking on a
tab: clicking on colB we get on colA, clicking on Undefined we get on
colB, ...

note: in this commit the "false" tab has been set to a translatable
"Undefined" name.

issue found when working on #21199
2017-12-18 09:30:48 +01:00
Nicolas Lempereur 12048bd68a [FIX] web: kanban column id may be based on value
A kanban column has two identifiers:

- db_id: framework unique identifier for the column

- id: either the record res_id (grouped on x2o) or the value

The issue is that sometimes the value may be a any string which
would be source of issue unexpected for an ID (and there was one
issue in mobile renderer).

This code change this so "id" is either the record res_id or
`undefined` value, and when used in XML we use id or fallback on db_id
when we need an identifier.

So in the XML data-id on a colum is always either the ID of the record
the group is based on, or the db_id in the form.

opw-782433
closes #21199
2017-12-18 09:30:48 +01:00
Géry Debongnie 377705aada [IMP] web: tests: add a way to properly mock Widgets
This rev. introduces two helper functions for the tests: patch
and unpatch. Those function allow patching an Odoo Widget (e.g.
AbstractField), and unpatch it at the end of the test with the
guarantee that the Widget's prototype is exactly the same as it
was before the test.

This was necessary because the way it was done before was a little
bit too naive, and could lead to unexpected behavior. Indeed, doing

 var someFunction = AbstractField.prototype.someFunction;
 // test content
 AbstractField.prototype.someFunction = someFunction;

is correct if someFunction is actually define (or overriden) in
AbstractField, as in that case, it really exists on its prototype.
Otherwise, it isn't correct if it is not directly defined on the
prototype before the test, as it will be after..
2017-12-15 13:07:34 +01:00
Christophe Simonis 4708812b6c [MERGE] forward port branch 11.0 up to b37cc1f9b7 2017-12-12 18:50:59 +01:00
Christophe Simonis b37cc1f9b7 [MERGE] forward port branch saas-16 up to a2ea4ba095 2017-12-12 18:39:43 +01:00
Adrien Dieudonne 35c4057422 [FIX] web: FieldMany2One: don't re-render if dirty
The 'main_flow_tour' noticed an error that we
had already corrected for the input fields.
See here: @a71f2237

In fact the same error can occur in the many2one fields
for the exact same reason.
It's why the 'main_flow_tour' crashed at the following step:
".ui-menu-item > a:contains('the_flow.customer')"
2017-12-11 10:17:15 +01:00
Lucas Perais (lpe) 6c024d1ef0 [FIX] web: give context to fetch x2m batched
Before this commit M2Mtags widget did not translate.
This was because no context was given to the rpc that fetched the fields
Hence, the lang was not passed.

After this commit, M2Mtags translate well

OPW 784396
2017-12-11 08:32:04 +01:00
Géry Debongnie 3b3f68030d [FIX] web: send proper context when fetching m2o namegets
When fetching batched namegets (typically after a default_get), we need
to evaluate the context that we send to the server.  This may be
important for models with a custom name_get method. (note: overriding
namegets should be avoided if possible)

With the new views refactoring, this was not done properly and the
'view' context was sent instead.  This is not really critical, the proof
is that it took a few months before getting some complaints, but this is
definitely a bug.

To reproduce, simply add a context attribute to a m2o field in a form
view, with a non empty value in a default get, and look at the context
sent to the server.
2017-12-07 16:20:46 +01:00
Christophe Simonis 8ef7af6afe [MERGE] forward port branch 11.0 up to f96a797fe6 2017-12-06 12:02:58 +01:00
Christophe Simonis f96a797fe6 [MERGE] forward port branch saas-16 up to b8540eefe3 2017-12-06 11:59:38 +01:00
Lucas Perais (lpe) 519555054a [FIX] web: BinaryFile not download when new record
Let's have:

- on res.company a binary file field named x_file
- on res.users a related binary field to company_id.x_file, and make it readonly
- On the res.users form view, display the new field
Before this commit in create mode, upon clicking on download the file, the server crashed, because the record id was empty.
Then, the JS crashed in turn because of the unhandled 404 from the server.

Since the id of a new record will always be unset, we choose to disable the download option in this very specific case

OPW 777042
2017-12-05 08:19:08 +01:00
Géry Debongnie 5faec34a3c [REF] web: update widget to new guidelines
- make delegate/undelegate events private
- remove $el before start
- make replaceElement private
- remove one _ from __render_and_insert... method
- update documentation
- remove make and improve make_descriptive (also, it is private)
- ...
2017-12-04 10:03:00 +01:00
Aaron Bohy 595a405b76 [IMP] web: tests: patch _.debounce and _.throttle
... to allow them to be called several times without having to
wait for the delays.

This was already done for _.throttle, by default for the whole
test suite, and it couldn't be parameterized in individual tests.
This was enough for _.throttle, but the same solution couldn't be
applied for _.debounce, because some tests actually test that some
handlers are correctly debounced.

Those function are now patched in addMockEnvironment, and two
parameters can be set: 'debounce' (default: true) and 'throttle'
(default: false).
2017-12-04 10:01:22 +01:00
Christophe Simonis 2b957f8d01 [FIX] web: correct test 2017-11-28 18:58:09 +01:00
Christophe Simonis 29590a61cd [MERGE] forward port branch 11.0 up to 8fb25e185b 2017-11-28 16:57:58 +01:00
Christophe Simonis 5851a69aa3 [MERGE] forward port branch saas-16 up to 3f66814a0d 2017-11-28 15:12:31 +01:00
Martin Geubelle cc031bd226 [FIX] web: Form: handle attributes and modifiers on header
This is done for all other tags (except <form> and <sheet>) but this one has been
forgotten.

Closes #21258
2017-11-27 14:01:50 +01:00
Martin Geubelle 76ba56e60d [FIX] web: List: handle custom class on button
It should be possible to set a custom class on a button in the list view.

Closes #20620
2017-11-27 14:01:50 +01:00
Géry Debongnie d6ff8c8351 [FIX] web: better support for async field widgets
Most field widgets are synchronous, but some of them have to do extra
work before being ready (for example, the pad widget, or widget which
needs to lazy load JS/CSS files).  Because of that, the new views have
been well tested with synchronous widgets, but not completely with async
widgets.

Some code depended upon the fact that the widget was ready immediately
after being created.  This was incorrect, and is fixed in this commit,
by adding a new hook that is called in (basic) views after a widget is
ready (meaning, start and willstart are done)
2017-11-24 14:59:14 +01:00
Géry Debongnie cc560531b9 [FIX] web: better support for async field widgets
Most field widgets are synchronous, but some of them have to do extra
work before being ready (for example, the pad widget, or widget which
needs to lazy load JS/CSS files).  Because of that, the new views have
been well tested with synchronous widgets, but not completely with async
widgets.

Some code depended upon the fact that the widget was ready immediately
after being created.  This was incorrect, and is fixed in this commit,
by adding a new hook that is called in (basic) views after a widget is
ready (meaning, start and willstart are done)
2017-11-24 14:55:53 +01:00
Nicolas Martinelli e703d07e68 [FIX] web: read_group RPC
Example of failing request:
```
rpc.query({
    model: 'link.tracker.click',
    method: 'read_group',
    args: [[links_domain, ['create_date', '>', interval]], ['country_id']],
    kwargs: {groupby:'country_id'},
});
```

The RPC request built contains the following:
```
args: [[["link_id", "=", 1]], ["create_date"]]
kwargs: {groupby: "create_date:day", domain: [], fields: []}
```

This will be interpreted server side as:
```
model.read_group([['link_id', '=', 1]], ['create_date'], groupby=['create_date:day'], domain=[], fields=[])
```

2 arguments match `domain` and `fields`, which causes a crash.

opw-781300
2017-11-24 14:16:13 +01:00
Alexandre Kühn fb6c9c2443 [IMP] web: FieldChar trim its value by default
With this commit, we change the behaviour of the web client with respect
to spaces in char fields.  Most of the time, starting and ending spaces
have no value, and worse, make the data not so reliable.

After this commit, field char will trim by default (so, if the user input a
char as ' abc ', the string 'abc' will be sent to the server instead).
Note that this only applies when the value of the field is changed.  If
someone open a form view, then switches to edit mode and save, nothing
will change.

This is the desired behavior most of the time.  However, in some rare
cases, this is actually harmful.  For example, if we trim the
'decimal_point' field, it will not be possible to enter a whitespace as
decimal separator.  In those cases, we introduce a new attribute 'trim',
which allow the developer to desactivate that feature.
2017-11-24 13:09:10 +01:00
Lucas Perais (lpe) 16f7a15325 [FIX] web: on_open_record stop propagation
on pricelist, open a pricelist form
click on one country group [country group form opens]
click on a pricelist again

Before this commit, a traceback appeared, saying the pricelist record was null
YET the pricelist's form on which we clicked before opened.

After this commit, the form of the pricelist opens, and no traceback is thrown.

OPW 783896

[FIX] web: test circular many2many

closes #21148
2017-11-23 14:48:45 +01:00
Aaron Bohy 463a214699 [REF] web,*: give evaluated contexts to load_views
*board,sale_timesheet

This rev. changes the API of load_views, as it now assumes that
the given context has no longer to be evaluated. This is more
convenient that way, as we can now call load_views with contexts
that are dict, and not instances of the Context class.
2017-11-23 11:00:55 +01:00
Aaron Bohy baae272ffd [REF] web: tests: make load_views RPCs go through mockRPC
This allows to inspect those RPCs and the given arguments as well.
2017-11-23 11:00:53 +01:00
Aaron Bohy b4609e3c25 [REF] web: test_utils: handle logging in mockEnvironment
instead of createView. This allows to log info like RPCs or
uncaught Odoo events even if we are not in a view.

Also remove the logLevel param from MockServer as it wasn't really
used.
2017-11-23 11:00:21 +01:00
Aaron Bohy 0670a635ac [REF] base,web: use correct Widget in settings JS tests
... instead of hacking test_utils.
2017-11-23 11:00:21 +01:00
Martin Geubelle aad9a1593f [FIX] web: correctly display modifiers in tooltip
Since odoo/odoo@da136d8 the modifiers in the widget attrs are parsed.
`stringify` thus needs be to used when displaying them in the debug tooltip (to
avoid to display [Object object]).
2017-11-22 16:47:29 +01:00
Alexandre Kühn 732f176fe1 [FIX] web: readonly monetary field onchange currency
Before this fix:
    A readonly monetary field was not updating
    its currency symbol when selecting another currency.

Scenario:
    1. Activate multi-currency with $ (default) and €
    2. In hr_expense, go to My Expenses to Submit
    3. Create a new expense
    4. Select 'EUR' as currency
        => Unit Price is correctly updated with €, but not Total.

With this fix:
    Total displays the correct currency in edit mode.

Explanation:
    Monetary fields in readonly are relying on _formatValue() to
    display their value.
    _formatValue() uses this.formatOptions.currency, which stores
    the currency at loading of the field. We must update its value
    whenever there is a change of currency.

opw-783378
2017-11-22 14:16:00 +01:00
Martin Geubelle 10175daeaf [FIX] web: add tooltips for buttons
The rev. odoo/odoo@952c17b added tooltips for buttons but only header buttons.
These tooltips can also be present on other buttons.

Closes #18790
2017-11-22 12:01:14 +01:00
Lucas Perais (lpe) 5c9f4fd67d [FIX] web: fieldDependency should be in fields too
Commit f45edfbe6d fixed a bug on image fields
but was a partial fix.

The problem is that while adding field dependencies to fieldsInfo,
it did not add them in the fields of the view, making the view crash.

After this commit, views and subviews contain fieldDependency as both info and actual fields of the view

OPW 780021, 781620, 779649

[FIX] web: tests on many2many subviews

closes #20891
2017-11-21 13:31:56 +01:00
Géry Debongnie fd7b767637 [FIX] web: empty field char should be set to false
With the new views, empty char fields were sent to the server as ''
(empty string) instead of false.  This is not the correct behaviour, and
actually cause some problems.  For example, if you have a char field
with a unicity constraint, then you cannot set it to '', since there is
only one record that can take that value.
2017-11-20 16:29:11 +01:00
Martin Geubelle a96c07a765 [FIX] web: make broken test in firefox pass
The attribute `autocomplete` is set with the jQuery function `attr` but
the test was using the function `prop`.

This seems to work in Chrome but apparently not in Firefox.
2017-11-20 11:53:30 +01:00
Géry Debongnie 6cd17d575c [FIX] web: properly refetch x2manys in some cases
Consider the following situation: a form view with a one2many which
contains sub x2many fields (for example a m2m_tags). Suppose that the
one2many has more than 40 records.  Before this commit, trying to delete
one of these records caused a crash.

The reason is that when we delete a record, we need to reload the
missing records in the one2many field.  We actually do that with a
_readUngroupedList.  However, the _readUngroupedList method did not
process x2many fields, so the information stored in the datapoints was
'raw', and the rest of the web client expected it to be a datapoint.

To reproduce the issue in the testing environment, i had to use
onchanges and a readonly attrs, to reach a situation where a crash could
occur.  This shows that, while the issue is critical, it was not totally
trivial to be impacted by it.
2017-11-20 11:05:46 +01:00
Géry Debongnie 5d1640edff [FIX] web: add support for limit attr in arch in sub tree view
Before this commit, the 'limit' attribtue worked properly for list views
(but was not documented), and was ignored for inline tree views.  There
was no good reason for that limitation, so we fix this issue.
2017-11-20 11:05:41 +01:00
Alexandre Kühn 23e6dd36d7 [IMP] web: hide in kanban tag's color (#20815)
New feature:

   - New Transparent tag visual (grey border & text, white bg),
   - By default, newly created kanban tags are transparent,
   - Tag's colorpicker has now a 'Hide in Kanban' checkbox,
     to select the transparent color.

Toggling off 'Hide in Kanban' sets the color of the tag as follow:

   - Previous color, if 'Hide in Kanban' was toggled on on the
     same formview session.
   - Color 1 (dark orange), otherwise.
2017-11-20 10:47:43 +01:00
Martin Geubelle 5ba6d93810 [FIX] web: Kanban: prevent drag&drop for readonly
If the kanban view is grouped by a readonly field, it should not be possible
to drag&drop the record from one column to another as this will trigger a
write on this readonly field.

It should however be possible to resequence records so the option `containment`
is used in the records.

Closes #19390
2017-11-17 16:21:01 +01:00
Christophe Simonis 21dd24c071 [MERGE] forward port branch 11.0 up to ca3390fd05 2017-11-17 14:22:46 +01:00
Alexandre Kühn 11ff01af9b [FIX] web: delete attribute on list view
Before this fix, when adding the attribute delete=0
on a listview, it was still possible to delete records
via the menu 'Delete' in the sidebar.

After this fix, this should not be possible to delete
records when delete=0.

The attribute delete was hard-coded to true, as there was
a traceback when it was set to false. It was simply due
to a misplaced closing brackets that was hiding an
assignment, which resulted to calling a method on undefined.
2017-11-17 12:34:25 +01:00