Commit Graph
7553 Commits
Author SHA1 Message Date
Aaron Bohy da152cfdbf [FIX] web: SelectCreateDialog: don't erase domain
When a SelectCreateDialog was opened with a given domain, this
domain was completely lost if the user wrote a new domain (or
groupby) in the searchview, whereas they should be concatenated.
2017-05-19 15:51:57 +02:00
Aaron Bohy 702835682e [FIX] web: fetch specialData of fields in x2many form
Suppose that there is a one2many list in a form view containing
a field F, displayed with no widget, and that F is also displayed
in the one2many form view (opened when clicking on a record of the
list), but that in this form view, F is displayed with a widget
requiring specialData (additional data to fetch alongside the
record), e.g. widget="domain".

Before this rev., it crashed when this happened because those
specialData weren't loaded when opening the related record.

Credit goes to @pga-odoo for reporting the bug and reproducing it
in a test.
2017-05-19 15:51:57 +02:00
Aaron Bohy c929a81e8f [FIX] web: DebounceField: do nothing after widget destruction
DebounceFields debounce the function that notify field changes to
their environment (using _.debounce). It may happen that this
function is called once the field widget is destroyed (e.g.
type something in a char field and quickly click on Save, the
function is called directly by _commitChanges, but the debounced
call is still pending). It may be a problem if the subsequent
code does something like this.getSession().some_key, as if the
widget is destroyed, it has no parent that can provide it the
session, and thus it crashes.

Also rename attribute _debouncedStarted into _isDirty as it makes
much more sense.
2017-05-19 15:51:57 +02:00
Martin Geubelle 7524b8ef92 [FIX] web: allow passing multiple ids in call_button
Passing multiple ids wasn't correctly handled as the argument `record_id`
was wrapped in a list of list, which is not hashable.

The wrapping is now handled by the caller.
2017-05-19 15:04:16 +02:00
Martin Geubelle ea7ff8f6fa [FIX] web: Form: handle attributes and modifiers on notebook
Before this commit, the renderer interpreted the special tag, but ignored
modifiers and attributes.

Most nodes are rendered by the `_renderGenericElement` method, so this behaviour
is automatic. However, special tags need to do it explicitely.
2017-05-19 15:02:21 +02:00
Géry Debongnie 92409cdfe5 [FIX] web: apply onchanges for sub fields for new records
Before this commit, when creating a new record, we only looked at the
main fields to determine if a call to onchange was needed.  This was not
enough, since sub fields (fields in a one2many for example) can have an
onchange.

This was an issue only for new records with onchanges in sub fields, but
no onchange on main fields.  For example, the merge contact wizard.

To solve this issue, we had to propagate the current view type from the
field to the basic model, because otherwise, the main viewtype was used
to compute the onchangeSpec, and that is not always correct.
2017-05-19 12:14:49 +02:00
Aaron Bohy 8af3d452f4 [FIX] web: BasicModel: read_group on selection field
When grouping on a selection field, the read_group may return a
group for value false (containing records with the selection field
unset, typically). When this happened, there was a crash because
the BasicModel didn't handle that case (it assumed that the value
of the groups was always a valid key of the selection).
2017-05-18 13:55:46 +02:00
Aaron Bohy abacdd9776 [FIX] web: FieldRadio with numerical keys encoded as strings
Before this rev., the FieldRadio didn't work on selection fields
with keys like "0", "1"... i.e. strings that can be converted to
numerical values. This was due to an automatic conversion of those
keys to their numerical value by JQuery, so when the user changed
the value, an unknow key was sent to the server (e.g. 1 instead of
"1"), causing a crash.

This rev. changes the logic a bit so that the keys are no more
written in the DOM, but their index in the selection are.
2017-05-18 13:55:46 +02:00
Aaron Bohy 94c91374e3 [FIX] web: selection field with value 0
The server doesn't make a distinction between an unset selection
field, and a value 0 (integer). So when 0 is a valid key for the
field, the server returns false as value if the field is unset, or
if its value is 0, which is not really convenient.

As a consequence, when the value is 0, it appears as unset in the
interface. To circumvent this, we automatically converts false
value of selection fields to 0, if 0 is a key of the selection.
2017-05-18 13:55:46 +02:00
Géry Debongnie 3dd97db07f [FIX] web: properly loads default values for many2manys
Many2many default value can be a list of ids, and in that case, we did
not properly load data.

It could be seen by selecting a few contacts (in list view), then
opening the 'Merge contact' wizard in the sidebar (action menu).  Before
this commit, the wizard did show a list with some empty rows (for the
field partner_ids).
2017-05-18 11:33:32 +02:00
Aaron Bohy ba6a3a91ae [FIX] web: MonetaryField: read currency_field in options
In the xml definition of views, a 'currency_field' can be specified
in the node options:

<field name="amount" widget='monetary'
       options="{'currency_field': 'currency_id'}"/>

It indicates which field the monetary widget has to use to
determine the currency to display.

Before this rev., the widget didn't look for the 'currency_field'
in the options, but directly in the node attrs, so this simply
didn't work. This was for example the case on the crm.lead kanban
and form views.
2017-05-17 12:36:16 +02:00
Aaron Bohy 59584283c5 [FIX] web: properly escape field values when necessary
This rev. removes some html injections issues:
  - in char and text field widgets
  - in phone field widget in mobile
  - in list views (when no widget is instantiated)
2017-05-17 12:36:09 +02:00
Aaron Bohy 0f9e986c46 [FIX] web: BasicModel: discard changes when reloading
... from a new record.

Steps to reproduce the issue:
  - go to a multi-record view (e.g. list) of basically any model
  - click on 'Create' -> it opens a form view in edit mode
  - click on 'Discard' -> it goes back to the list
  - click on an existing record -> it should open the selected
    record in readonly.
However, it didn't display the data of the selected record, but
the default data of a new record (the result of a default_get).

This was because the changes weren't properly discarded when
reloading from a new record (it rather restored the record to its
initial state, i.e. to the result of the default_get).
2017-05-17 08:10:49 +02:00
Olivier Dony 5afe894f44 [MERGE] Forward-port saas-15 up to 878fbc75ff 2017-05-16 17:09:45 +02:00
Aaron Bohy 0c8d1f6089 [FIX] web: Form: col width of x2many lists inside groups
The form renderer defines inline style on the groups it renders to
set the width of their children according to the col and colspan
attributes specified in the view.

However, before this rev., this impacted inner list views (for
x2many fields), as their columns get an harcoded width as well,
whereas they shouldn't.

This was for example the case in the stock.location.route form
view, for the push rules and procurement rules o2m fields.
2017-05-16 14:07:49 +02:00
Olivier Dony 61c2b8efd5 [MERGE] Forward-port of saas-14 up to 9b3ca1af23 2017-05-16 12:47:44 +02:00
Olivier Dony 9b3ca1af23 [MERGE] Forward-port 10.0 up to 1545995b39 2017-05-16 12:12:30 +02:00
Olivier Dony ab8c81a96f [MERGE] Forward-port saas-11 up to 0570033ae7 2017-05-16 10:30:23 +02:00
Aaron Bohy ac092e9ccd [FIX] web: List: force grouped lists to be non editable
Editable grouped list views isn't a supported feature. Before this
rev., grouped lists weren't automatically set as non editable, so
it could cause crashes when the user clicked on rows of grouped
lists with editable="top" or "bottom".

This was for example the case in Timesheets > All timesheets ->
go to list view.
2017-05-16 08:49:26 +02:00
Aaron Bohy 55de60db6e [FIX] web: BasicModel: missing fields in data for x2m
The 'data' attribute of exported datapoints (using 'get') must
contain a value for each field in the view, and the default value
is false when those fields are unset. The code manipulating those
datapoints supposes that this is the case and it makes it easier
and clean.

However, it wasn't the case for x2manys in new records for which
the default value contains CREATE commands with missing fields:
in that case, those missing fields weren't added in data.

This caused a crash in the Employee form view, in edit, if the user
clicked on 'Create and Edit' of the 'Working hours' field, because
some code in field_utils assumes that if the value of a date field
isn't false, it means that it is a moment instance (but in that
particular case it was undefined).
2017-05-16 08:49:26 +02:00
Christophe Matthieu 5f13b7f019 [IMP] web: update datepicker syntax with the new guidelines 2017-05-15 16:19:47 +02:00
Christophe Matthieu 932e887400 [FIX] web: datepicker did not select correct date after initial render 2017-05-15 16:19:37 +02:00
Martin Geubelle a7411165f3 [FIX] web: Kanban: update buttons after column creation
The buttons were not updated after column creation.
This was causing an issue in an empty kanban when you created a new column,
the 'Create' button was not highlighted.
2017-05-15 14:55:21 +02:00
Martin Geubelle a0217f4475 [FIX] web: BasicModel: update parent data after record deletion
After the record deletion, the parent should be updated to take the deletion
into account.

This was causing an issue in the Kanban view: after a column deletion, it appeared
again if you created a new one.
2017-05-15 14:55:21 +02:00
Martin Geubelle 2fb4cf46d2 [FIX] web: Kanban: correctly destroy old widget after update
The attribute `widgets` has been renamed in rev https://github.com/odoo/odoo/commit/7ff8aa73e17b281b3e2bc4c7275d020eab0204e7#commitcomment-22116249
However, KanbanRenderer still uses a `widgets` attribute, not for the fields
widgets but for its columns (or records if ungrouped).

These widgets weren't correctly destroyed since then.

This was causing an issue when you were trying to quick create a record after a
column creation (that generates an update): the quick create was added in the
first old column (which was not in the DOM anymore) so you couldn't see it.
2017-05-15 14:55:21 +02:00
Martin Geubelle feb4a8986d [FIX] web: Kanban: correctly add the created record in group
The kanban group expects to have local ids in its data and not the whole
datapoint.

This was causing a traceback when adding a new column after adding a record.
2017-05-15 14:55:21 +02:00
Christophe Matthieu ef35702cbc [FIX] web: remove some memory leak 2017-05-15 13:16:02 +02:00
Christophe Matthieu 1c5ea99b7b [FIX] web: display a translation alert when saving the form view
In the form view, when the user saves a record (with a multilang instance),
an alert is displayed to display all modified translatable fields.
2017-05-15 10:06:58 +02:00
David Monjoie b57283619c [FIX] web: display field node string in form dialog title
Previously, the string attribute of the field node was ignored
in the title of the form dialog and it always displayed the
string value of the python field definition instead, which is
a default value instead.

Additionally, I took this opportunity to add tests for other
similar dialog titles which actually worked already with the
string attribute of the field node but were not tested yet.
2017-05-12 14:53:48 +02:00
David Monjoie 42d95cbfc3 [FIX] web: keep focus on checkboxes after rerendering
Previously, when a checkbox was re-rendered, it was losing focus
since it was removed and re-created. Now, if the checkbox itself
is the origin point of the re-rendering, we give the focus to the
newly re-rendered checkbox, resulting in a seamless experience
just as if the checkbox was never removed and re-rendered.
2017-05-12 14:53:48 +02:00
Géry Debongnie 310588b813 [FIX] web: prevent duplicated footers in dialogs
In some cases, we had duplicated footers in form view dialogs.  It
actually happened when the view was reloaded, which is not particularly
frequent, but happens most of the time the user clicks on an action
button, which does not close the window.

To reproduce the issue, you can open the lunch module, click on the
'Feeling Lucky' button.  It will open a form view with a special button
in the footer: 'I'm feeling lucky'.  Clicking on that button will return
an error (no order matches the criterion), and will trigger a form
reload.  Then, you will see two footers: one in the modal footer, the
other one in the form renderer.

The solution to this issue is to make sure, when we update the view and
a footer tag is found in the form renderer, to replace the current
footer buttons by these new buttons.
2017-05-12 14:05:17 +02:00
qsm-odoo 40a026d5b2 [FIX] web: implement <newline/> form tag behavior
Before this commit, the new form view implementation was rendering
<newline/> tags as real <newline/> DOM element. The wanted behavior
is now restored:
- As outer group direct child, produce a <br/> tag, forcing the next
  group children to be on a new line
- As inner group direct child, produce nothing but forces the creation
  of a new <tr/> (for the next group children)
2017-05-11 15:09:25 +02:00
qsm-odoo 97517a1cc2 [REF] web: label creation on form view rendering
The original goal of the commit was to implement a missing behavior
for label tags in form view. This finally need some deeper refactoring
for it to work so this commit does not introduce any change in behavior,
only comments explaining the problem.
2017-05-11 15:09:25 +02:00
qsm-odoo 23beee818a [FIX] web: do not lose field/label pair on field rerendering
When a field widget switches between readonly and editable states, it is
fully rerendered. Labels have sometimes to get a specific class when
their associated field is (become) readonly and without any value. This
condition was evaluated on the initial widget and not on rerendered
ones.

Note that this commit only restores an already implemented behavior
broken by https://github.com/odoo-dev/odoo/commit/8f9362809e91ff7c2876ab464017abb13a4e0974
... but this time a test will prevent a new breaking
2017-05-11 15:09:25 +02:00
Martin Geubelle ef643783a5 [FIX] web: deal with malformed default_order
Even if the `default_order` attribute should be like 'name,id desc,coucou'
we want to support the syntax 'name, id desc, coucou' (i.e. with spaces after
the comma).

The commit also patches the mock server.
2017-05-11 14:48:35 +02:00
Martin Geubelle c8d063d357 [FIX] web: use o_tag_color outside of badges
Since rev https://github.com/odoo/odoo/commit/250e716c3a12e88acb4a199b427dc47d4ec55d5d
the colors have been mistakenly moved in a too restrictive rule and could only be
used in a badge.
2017-05-11 11:21:00 +02:00
qsm-odoo 69d572a015 [FIX] web: restore col(span) feature for form groups
Current new implementation of the form view ignored several properties
linked to <group/> elements:

- groups' col attributes were considered to always be 2
- groups' children colspan attributes were considered to always be 1
- elements different than <field/> and <label/> in groups were forced
  to their own row
- it was not possible to have a group hierarchy deeper than 2
- <td/> elements widths were not properly set
- ...
2017-05-11 10:39:06 +02:00
Aaron Bohy 4e8e546ed7 [FIX] web: DebugManager: open view: search and qweb views
can't be opened that way.

For now, only views that can be opened with a view manager are
supported, i.e. views like form, list, kanban, graph...

So this fix filters out the views of type qweb and search from the
list.
2017-05-11 08:52:24 +02:00
David Monjoie e1edd62320 [FIX] web: toggle checkboxes when clicked in editable list view
Previously, the checkbox was not checked when it was clicked in
editable list view, it only opened the row but did not check the
checkbox.
2017-05-10 15:20:03 +02:00
Géry Debongnie 84187f972a [FIX] web: prevent view_dialogs from changing env
With this commit, we prevent view dialogs from changing the 'global'
environment in the view manager.  Here is how it could cause a problem:

* open a form view for a bill of material
* click on one of the component, it will open a form view in a dialog
  (and will change the environment with a wrong res_id)
* click on the many2one product -> it will open a new action in the
  background, and change the environment again
* click on the breadcrumb to come back to the bill of material: the view
  manager will try to restore the correct res_id (which is the wrong id
  from the component form view), the form view will do a read (when
  reloading the data), will get an empty result, will update its
  information with no data, then will be in a wrong state which means
  that the basicmodel will fetch a x2many with a wrong res_ids list
* boom
2017-05-09 17:03:30 +02:00
Martin Geubelle 0ac2d8f015 [FIX] web: add o_input class on m2o dialog input
Since the rev https://github.com/odoo/odoo/commit/250e716c3a12e88acb4a199b427dc47d4ec55d5d
the class `o_input` needs to be set on an input to correctly style it.
2017-05-09 15:19:00 +02:00
Aaron Bohy 7e98e32959 [FIX] web: traceback when quickly clicking on back button
Before this rev., there might be a crash when the user quickly
clicked several times on the browser's back button. This crash
occurred in the code saving/restoring the scroll position of the
current action.

When clicking fast on the back button, several actions are
executed but don't wait for each other (those actions are triggered
by the hashchange event), so when it is fast, and mainly when the
appswitcher is involved, it may happen that we try to get the
scroll position of an action that isn't loaded yet.

opw~741814
2017-05-09 14:54:15 +02:00
qsm-odoo 111465c318 [FIX] web: numbers in list views should be right-aligned
Before this commit, numbers in list views were right-aligned
depending on the widget they were using (float/monetary). Now, the
input text alignment is inherited from the parent which should
solve the problem.
2017-05-08 17:12:11 +02:00
qsm-odoo 0764bc41aa [FIX] web: list rendering was not properly updated after discard
Before this commit, when hitting the "Discard" button in an editable
list view, the line switched to readonly mode but with the undiscarded
data (even though the data was properly discarded and not saved).

Fortunately, the fix is in fact making the save/discard/update system
more consistent. Here are some reasons why:
- the `_confirmSave` method is now used after a save or a discard
    (while it was before only called on readonly views where a change
    was made by a special field widget).
- Abandonning a record (discarding a new unsaved one), is now the
    responsability of `discardChanges` (and not `_setMode`).
- The renderer `updateState` method is used when its state is updated.
- ...

Note that setting the renderer mode is now taking care of deferreds
properly (the widgets deferred are now considered when switching
a row to readonly/edit mode).
2017-05-08 14:02:40 +02:00
Géry Debongnie c8d77f93e5 [FIX] web: display empty input fields properly
Before this commit, it was not possible to see the difference between an
unset float field (with a 'false' value) and a set field (for ex, with
value 0)

This was due to the fact that the formatFloat/formatMonetary functions
format false values as the number 0, unlike many other formatting
functions.
2017-05-08 13:56:18 +02:00
qsm-odoo c1377f5972 [FIX] web: properly handle field navigation for all fields
Before this commit, only fields which were specializations of the
`InputField` were handling up/right/down/left navigation in editable
list view. As m2o field is not an `InputField` (yet?), it was not
possible to navigate from one of those for example.

Now, navigation events are handled by the `AbstractField` class. If a
given field has to handle navigation a different way, it is its
responsability to stop the associated navigation event. For example,
`InputField` instances are stopping the left/right event if the cursor
is not at the start/end of the <input/> element.

Also, before this commit, there were many events ("move_down",
"move_left", "move_next", ...). Now there is only one event for
navigation: "navigation_move". This event is given a "direction" data
("left", "next", ...). It also comes with a "target" data which is a
reference to the last `AbstractField` instance the navigation event
has crossed.
2017-05-08 10:38:05 +02:00
Aaron Bohy c04b840a45 [FIX] web: FieldMonetary: don't loose focus after edition
... in x2many editable list views.

Field widgets can detect that they are at the origin of a
field_changed event, so that they don't re-render themselves when
they are being edited.

This didn't work for fields inside x2many list views. This wasn't
a big problem for most of the fields, because the cursor position
was automatically reset after a re-rendering, but it wasn't
working for monetary fields that empty their $el before each
re-rendering.

This rev. fixes the issue by making the field widgets inside
x2many list able to detect that they are the origin of a change,
and thus removes the now useless code that restore the cursor
position.
2017-05-08 08:10:00 +02:00
Géry Debongnie c75680c527 [REF] web: optimize basic model (improve perfs for most views)
The 'get' method in the basic model is called very often (too often, but
that is another issue).  For a large list with many columns, it can be
quickly be called more than 10k times.

In that function, we had to protect our integrity by performing a deep
clone with $.extend, so noone else can be allowed to change something in
our internal structure.  This is good in theory, but not so good in
practice, as $.extend is a really expensive operation.

Also, we try to have the smallest external API by deleting useless keys.
But instead of keeping a blacklist of private keys, it is simpler to
have a whitelist of public keys.

So, what we do is to explicitely construct the object returned by key,
since we know the types of every values involved.  This is more
explicit, and at the same time, much faster.

Also, we propagate the options for elements of type list.  This is why I
had to change the isFieldSet method.

In a benchmark I just ran, loading and rendering a large list (200 rows,
7 columns) went from about 2.7s to 0.7s.

We still do way too much work, but at least it is much faster...
2017-05-07 22:38:27 +02:00
Christophe Simonis c0e4ab8080 [MERGE] forward port branch saas-14 up to bac4d13d47 2017-05-05 17:17:02 +02:00
Martin Geubelle 4d6aff97b6 [FIX] web: List: display invisible cells
An invisible cell should be visible in the list renderer otherwise
the cells are not correctly aligned anymore.
2017-05-05 17:05:53 +02:00