Commit Graph
68 Commits
Author SHA1 Message Date
Khoi Nguyen f2c7e44efe [FIX] web: no M2ODialog when pressing enter in a many2one
Before this revision, pressing ENTER when inside a many2one field
triggers a 'focus out' event. In particular, if one creates a many2one
record and uses the ENTER key to click "Create and Edit", two dialog
windows appear: one to actually create the associated record, and a
second to alert the user that they are creating an associated record.
The latter appears every time the many2one field loses focus.

This commit changes the 'key up' event for many2one fields to ensure
that the ENTER key does not trigger a 'focus out' event.
2017-07-14 10:35:35 +02:00
Adrian Torres ed2a77e50e [FIX] web: Fix FieldRadio's o_horizontal/vertical (#18163) 2017-07-12 09:45:46 +02:00
Martin Geubelle e26ccdd0b6 [FIX] web: explicit color attribute for m2m_tags
Before this fix, the field 'color' was hardcoded in the m2m_tags widget,
which means that:
 - one couldn't specify another field (problem for custom models, with x_...)
 - if the related model didn't have the field 'color', a warning was raised
   by the server

Now, the color attribute needs to be specified on the widget options if one
wants to display colored tags.

If the color is not specified, the tags will be displayed in grey.
2017-07-07 13:40:36 +02:00
Géry Debongnie 56dae80994 [FIX] web: prevent crash with invisible x2m and onchanges
When an invisible x2many field is modified by an onchange, we had a
crash because the reset function did not return a deferred in that case.

This happens because the signature of _render in AbstractField allow for
an undefined return value, but the reset method should return a
deferred.

This was an issue for example in stock: editing the
pack_operation_product_ids one2many field in a stock.picking could
trigger an onchange on another invisible one2many (with no inline views).
2017-07-06 15:04:04 +02:00
Cedric Snauwaert 1e30b30a8f [FIX] web: onchange with domain should not crash if field is not in view
In some cases (onchange in a purchase order), the onchange can return a
domain for a field that is not in view.  It should not be the case, but
it is really simple to protect the web client anyway.
2017-07-05 14:47:13 +02:00
Aaron Bohy 8473bde80e [FIX] web: handle 'domain' key returned by onchanges
Onchange RPCs return an object that may contain a 'domain' key.
When it does, its value is an object whose keys are field names and
values are the new domain for the corresponding field.

Before this rev., the 'domain' key was totally ignored by the
BasicModel. This feature is used for example in the account.payment
form view (go to an open invoice, click on 'Register payment'): the
domain of field payment_method_id is updated by the onchanges (e.g.
when changing the journal_id). As the domain was ignored, it always
displayed all possible payment methods.
2017-06-29 14:58:04 +02:00
Aaron Bohy b954cd6483 [FIX] web: BasicModel: send correct context
... when reading and writing on a record (especially inside lists).

Before this rev., the context sent when reading a record, and when
writing records inside lists (editable list views) wasn't correct.
This caused an issue in Sales > Products (variant activated) >
open a product with variants > click on variant prices > edit the
prices of a variant: the value wasn't saved correctly (because the
inverse function requires 'active_id' to be in the context and it
wasn't the case).
2017-06-29 14:58:04 +02:00
Martin Geubelle ec3bc2eeaf [FIX] web: deal with reference fields
The reference fields haven't been correctly implemented with the new views.
This commit restores their behaviour.

Note that an small improvement has been introduced in this commit.
Before saas-16, a `name_get` was done for each record (so 80 if the field
was displayed in a full list view), which is not optimal. The calls are now
batched by model (so one `name_get` by model appearing in the field values).
2017-06-28 16:53:45 +02:00
Aaron Bohy 9fbed63406 [FIX] web: FieldSelection on m2o: unset value
When the value of a many2one field with widget selection was unset,
it's value wasn't actually set to false in the BasicModel. It was
set to a virtual id like 'virtual_294' instead. This caused a
traceback when this value was sent to the server, obviously.

This was for example the case of the Register Payment form view
(accessible from a customer invoice), when the user selected a
payment journal, and then unselected it (the virtual id was then
sent to the onchange RPC).
2017-06-27 14:12:31 +02:00
Aaron Bohy 4881f942cb [FIX] web: BasicModel: correctly eval x2manys in domains
When x2many fields have to be evaluated in domains (e.g. ['id',
'in', some_x2many_field]), they must be evaluated as the list of
ids in the relation (whereas in contexts, they are evaluated as a
list of commands). Before this rev., they were always evaluated as
a list of commands.

Note that this didn't work neither before the new views.
2017-06-27 14:12:31 +02:00
Aaron Bohy 17e198153e [FIX] web: BasicModel: store changes in x2many as operations
Datapoints of the BasicModel store the data fetched from the
server and changes done (not saved yet) by the user. For x2many
fields, datapoints are of type 'list' and have a 'res_ids' key
containing the ids of all records in the relation. They also have a
'data' key containing datapoints of type 'record', representing the
records in the relation that have been fetched (with a limit set to
40 or 80 depending on the subview used). So basically, the length
of res_ids may be different than the length of data.

Before this rev., the changes in x2manys were saved under the key
'_changes' as a duplication of the content of 'data', i.e. same
list of datapoints of type 'record', modulo the changes done (it
contained the new records added and didn't contained the removed
records, whereas the 'data' remained unchanged). This didn't worked
at all when there were more records than the limit in the relation.
Indeed, when this happened, the commands to send to the server
couldn't be generated correctly.

This rev. modifies the way changes are stored in those datapoints.
Now, each change is stored as an operation. An operation could be
of type 'ADD', 'REMOVE', 'REMOVE_ALL' or 'UPDATE'. As before,
'data' remains unchanged and always keeps the datapoints of records
that have been fetched (the ones that are currently displayed in
the list or kanban subview). This way, commands can now be properly
computed.

This had a nice side-effect of fixing two other bugs linked to
x2manys.
First, when used in a context (e.g. {some_key: some_x2many_field}),
the value of some_x2many_field (i.e. a list of commands) was always
[] if the field was invisible="1" in the view, because it's
subrecords weren't fetched, and the generated commands were based
on them. Now, they are generated from the list of res_ids in the
relation, so it works fine.
Second, the x2many records are supposed to be sorted client-side,
after being read, and after each edition. This was working in the
first case, but not in the second. Now it's working even after
a record edition.

This rev. also correctly sets the 'parentID' and 'static' keys in
datapoints.

Finally, we also fixed the pager in x2manys as it was badly
displayed (small less tweaks).
2017-06-27 14:12:31 +02:00
David Monjoie 3cbfc40303 [FIX] web: fix m2o with show_address
When the show_address option is enabled, the display_name of a
partner becomes a newline concatenated version of his name and his
address, so the internal value of the widget is this conglomerate.

However, if one uses a keypress that does not change the value of
the input in edit mode, say ESC for example, the keyup handler of
this widget will compare the value in the input with its internal
value. If the internal value is still the conglomerate, which is
the case if the user hasn't changed the input content since
switching in edit mode, we need to trim it to compare it to the
actual input value, which is the "standard" display_name, ignoring
the magic show_address feature which is only used in readonly.
2017-06-23 09:58:43 +02:00
David Monjoie 1192ca1048 [FIX] web: fix searching on datetime fields
Previously, one could not create a custom filter on a datetime
field without encountering a crash.
2017-06-23 09:58:42 +02:00
Martin Geubelle c62a4edcb0 [FIX] web: set 0 as default value for numeric fields
When creating a new record, the numeric field default value should be 0 in order
to avoid manually setting mandatory fields to 0.

This behaviour has been removed with the new views but one wants to restore it.

The `mockRead` function has also been adapted in this commit because the server
returns 0 for unset numeric fields.
2017-06-22 10:52:26 +02:00
Adrien Dieudonne 5fa51c5201 [FIX] web: basic_controller: avoid multiple name_create
Before this fix, multiple records were created if you clicked
on the quick create of a many2one in a modal.

The 'mutexify' event wasn't stopped and was thus handled by
the dialog's form controller and by the main form controller.
2017-06-21 13:30:40 +02:00
Aaron Bohy 8859d25bc5 [FIX] web: FieldWidgets: use correct format/parse functions
Field widgets must format and parse values according to the widget
type, not to the field type. For example, if a monetary field is
inserted in a form view with widget="float", the field's value must
be formatted with the float formatter, not the montetary one. This
wasn't the case before this rev.
2017-06-16 11:14:16 +02:00
Aaron Bohy 5c4485d182 [FIX] web: Many2one in X2Manys: quick create then save line
A problem occured with a required Many2One inside an X2Many (e.g.
order_line field in sale.order form view). If the user clicked on
'Add an item' to add a row, then typed some text in the Many2One,
then clicked on 'Create ...' to quick create a new product, and
then directly clicked on 'Add an item' to add another row (before
the name_create returned), the first row was discarded.

This was because before the name_create returns, the Many2one still
has no value, and as it is required, the row was considered invalid
and then discarded.

This rev. ensures to wait for the name_create to return before
trying to save the row and to create a new one.
2017-06-13 08:24:59 +02:00
qsm-odoo fc53b91b06 [FIX] web: adapt tests to 3741603495
The datepicker is now forced to be in the <body/>, so the tests had to
search it in there.
2017-06-09 17:55:52 +02:00
Aaron Bohy 99ae418bf2 [FIX] web: Many2one: wait for name_create before saving
The problem occurred in form views with a many2one field, when the
user reproduced the following steps:
 - type some text in the many2one
 - click on 'Create ...' in the many2one dropdown to quick create
   (name_create RPC) the record
 - before the name_create returns, click on 'Save'.

When this happened, the record was saved before the many2one was
updated with its new value. So the record was incorrectly saved,
and the view was again dirty as soon as the name_create returned,
even if it was in 'readonly'. So after saving, a 'Changes will be
discarded' dialog opened when the user tried to leave the form.

We fix this issue by making the controller wait for the name_create
to return, and for the many2one to update its value, before saving.

This issue could also occur in list views.
2017-06-08 10:48:31 +02:00
Aaron Bohy 67747e6fa5 [FIX] web: FieldOne2Many: re-activate 'Add an item'
The 'Add an item' button of one2many editable lists is deactivated
once clicked (since rev. f9a1241) to prevent concurrent record
creation. It is re-activated when the record has been created.
Unfortunately, it might happen that the record is actually not
created, so in this case the button is never re-activated.

This happens for example on the customer invoice form view, if
the user tries to add a line before selecting a partner.
2017-06-07 08:08:49 +02:00
Aaron Bohy e9de309511 [FIX] web: editable list: setRowMode returns a deferred
This function should return a deferred, as indicated in the
docstring. However, in some cases, it doesn't. It then crashed
as the FieldX2Many tries to call done() on undefined.

This happens for instance on the customer invoice form view:
create a new record, select a partner, add a line, select a
product, directly click on the invoice date field (this will
trigger an onchange which will totally override the value of the
one2many). The FielX2Many calls setRowMode to switch the edited
row back to readonly, but this row doesn't exist anymore as the
one2many value has been overriden by the onchange, so setRowMode
wrongly returns nothing, and it crashes.
2017-06-07 08:08:49 +02:00
David Monjoie 2d26ed05a7 [FIX] web: fix handle widget functionality
Also added tests for handle in list view and inside an x2many.
2017-06-02 15:12:55 +02:00
David Monjoie 31f5819724 [FIX] web: fix mock server dropping x2many on update
Previously, when an update operation was performed, the list of
ids in the x2many field was emptied beforehand.

It kinda worked in lots of cases where one would expect it to
fail because in thoses cases the widgets send link_to commands
along with the update one, thus re-adding the removed line.

Now the behavior is more consistent accross the board. We start
with the current list of ids and apply the requested changes.
2017-06-02 15:12:43 +02:00
Aaron Bohy 719e040dee [FIX] web: Many2One: search with input's value
When the user writes something in a Many2One input, after a short
delay, a name_search RPC is done with the value written in the
input, and results are displayed in a dropdown. Then, if the user
clicks on the input, the dropdown closes. If he clicks again, it
should do again a name_search RPC with the value of the input.
Before this rev., it was doing it with the empty string.
2017-06-01 20:45:06 +02:00
Aaron Bohy f9a1241721 [FIX] web: editable list: don't create invalid records
Clicking multiple times on 'Create' (in main list views) or 'Add an
item' (in o2m lists) might create invalid rows (i.e. rows with
required fields unset).

Creating a new record requires two sequential RPCs: a default_get
and an onchange (only if there is an onchange of one of the
record's field). When clicking twice to create a new record, that
sequence of RPCs is done twice in parallel, after unselecting the
current row (i.e. saving it if it is valid). However, in both
cases, there is no line to unselect yet (as both operations are
done basically simultaneously). When the first onchange returns,
a first new record is added to the list. When the second returns,
the second one is added and takes the edition, leaving the first
one, invalid, in the list.

This rev. ensures this doesn't happen by preventing concurrent
record creation.
2017-05-31 20:53:55 +02:00
Aaron Bohy 23613b411f [FIX] web: x2m editable list: wait for onchanges
... before saving a line.

Suppose that we have an editable list with one required field
(e.g. many2one) with an onchange. We add a record and select a value
for the many2one. Before the onchange returns, we click again on
'Add an item'. If we don't wait for the onchange to return before
unselecting the row (i.e. before saving it), a confirm dialog asking
if the changes can be discarded opens, because the line isn't valid
yet. This could easily be reproduced on the sale_order form view,
with some throttling.

This rev. ensures that we wait for the onchange to return before
saving the line, and thus before creating a new line.
2017-05-31 20:53:55 +02:00
Aaron Bohy 27463eadab [FIX] web: FieldMany2Many: don't save if nothing changed
Suppose that there is a many2many list (non editable) in a form
view. When one of the many2many subrecords is edited (from the
form view in a dialog), it is saved directly when the user clicks
on 'Save' in the dialog.

Before this rev., if the user clicked on 'Save' in the main form
view after editing a m2m subrecord, a 'write' RPC was done, whereas
there were nothing left to save (as the subrecord had already been
saved).
2017-05-29 20:53:40 +02:00
Aaron Bohy 45bce324f3 [FIX] web: BasicModel: correctly apply x2many changes
Suppose that we have a form view with a one2many list (non
editable) containing a record. In edit mode, the user clicks on
that record to edit it in a form view (in a dialog). In this form
view, there is an x2many field that isn't in the list. Before this
rev., it crashed when the user clicked on 'Save' in the dialog
after editing the value of the x2many.

This was because the basic model didn't use the correct fieldsInfo
in that case (it use the fieldsInfo of the list view instead of the
one of the form view, and the x2many field isn't in the list).

Also ensures that the record is correctly saved even if editing the
x2many is the only change done, as this wasn't the case before.
2017-05-29 20:53:40 +02:00
Géry Debongnie a3441cfb56 [FIX] web: handle 'required' attribute in x2many+onchange
Before doing an onchange in a x2many, the basic model tries to evaluate
if the line is valid or not.  In that computation, we used the
field.required property instead of using the required modifier.  This
commit had to move the modifier handling from the BasicRenderer to the
BasicModel, in order to use it in the _isX2ManyValid method.
2017-05-24 11:37:38 +02:00
Adrien Dieudonne 12bf5bb926 [FIX] web: FieldMany2ManyCheckBoxes: label not clickable
Before this commit, it was only possible to click on input to
change the value of the many2many_checkboxes widget.
For better consistency, we must allow to click on labels.
2017-05-22 14:55:47 +02:00
Géry Debongnie 4b8c34be15 [FIX] web: properly evaluate context with x2m
The motivation for this commit was to fix a wrong evaluation context for
x2m fields: it was using a list of res_id, which may contain virtual
ids.

For example, it could be seen in the form view for journal entries:
adding the first line (field line_ids) was fine, but clicking on 'Add an
item' a second time caused a crash.  The reason was that the line_ids
was explicitely added to the context in the view, and the second time we
add a line, the web client sent a list looking like this [35,
'virtual_43'] to the server, in the nameget context.

The proper behaviour is to send a list of commands for those fields.
This means that we had to do some non trivial changes in the
getEvalContext method: we stop using the get method with raw: true.  It
was nice to use the same method, but the eval context is actually
different that the values returned by the get method.  That was the
motivation to introduce the 'noUnsetNumeric' flag, but now, we simply
create another method and let each method do its own work.

TLDR: eval contexts are hard...
2017-05-22 14:25:30 +02:00
Géry Debongnie 3aad756d32 [FIX] web: properly handles ESC in editable lists
It is not really easy to handle discard operations.  We need to handle
the discard in editable lists, and in x2manys. This is not exactly the
same code, but most of this was done by moving the discard method from
the formcontroller to the basic controller.

With this commit, the user can now discard the changes for the current
record by pressing ESC.  If the record is new, it will remove it, if
not, it will ask for confirmation before.
2017-05-22 10:07:33 +02:00
Géry Debongnie a60ae43835 [FIX] web: prevent navigation when line is invalid in o2m
The issue that we fix in this commit is the following: open a form view
with a o2m with one required field, and the o2m is editable.  When
adding a new line, it is invalid (since the field with required), but
when pressing ENTER, the editable list tries to navigate away, which
will discard the current line (in the unselectRow method), before
completing the move_to_next_line.  So, at this point, the list editable
create a new (empty) record, and we are back to square one, but with a
visible flicker and no information on what happened.

To fix this issue, we simply check that the renderer can be saved when
moving to next line.  If it is not (the line is invalid), then we simply
abort the move.

Notes:
* this behaviour worked fine in list view, because the canBeSaved check
  is made by the saveRecord method in listController
* it looks like the protection should be put into unselectRow, but this is
  not true (at least, in the current state): in some cases, calling
  unselectRow with invalid state should result in discarding the current row
  (in a new line in a o2m, when the record is not dirty, for example), and
  the list editable renderer does not know if this is the case or not.
  However, if the unselect action comes from a navigation event, then we want
  to avoid discarding the current row.
2017-05-22 10:07:32 +02:00
Géry Debongnie 8436150ae5 [FIX] web: bad interaction between m2o, onchange and editable list
When a many2one (in an editable list) with an onchange was edited, it
could happen that a modal window asking for confirmation of the creation
of a record was opened when it should not.  Here is what actually could
happen:

* user focus a many2one
* user type something
* user press ENTER (keydown + keyup)
* user press ENTER again
* the onchange comes back
* modal window is open

Because of the onchange, the _reset method was called after the
_onInputKeyup method.  So, the m2o_value was not equal to the
$input.val() and the 'floating' flag was set to true (after the first ENTER).
The second ENTER caused a unselectRow in the editable list, so the input
was focusouted, and the modal is set.  This is basically caused by the
asynchronous behaviour of the onchange.

We simply fix the problem by setting the floating flag back to false in
the keydown method.
2017-05-22 10:07:32 +02:00
Géry Debongnie 3adfa84cd6 [FIX] web: improve many2one edition with onchanges
When a many2one (in an editable list) with an onchange was edited, it
could happen that a modal window asking for confirmation of the creation
of a record was opened when it should not.  Here is what actually could
happen:

* user focus a many2one
* user type something
* user press ENTER (keydown + keyup)
* the onchange comes back
* user press ENTER again
* modal window is open

Because of the onchange, the _reset method was called after the
_onInputKeyup method.  So, the m2o_value was not equal to the $input.val() and
the 'floating' flag was set to true, which means that the _onInputFocusout
method (called indirectly by the listeditablerenderer when unselecting the row)
was forced to open a confirm dialog.

We simply fix the problem by setting the floating flag back to false in the
reset method.
2017-05-22 10:07:32 +02:00
Géry Debongnie 28eadb3d6e [FIX] web: improve navigation in field many2one
Before this commit, when the user write some text in a many2one, then
press ENTER, the key event will trigger a navigation move, which will
validate the field, and move the focus to the next line.  The same issue
happens when pressing TAB.

With this commit, we simply stop the propagation, and preventdefault the
event that cause the selection.
2017-05-22 10:07:31 +02:00
Géry Debongnie af021f223b [FIX] web: apply onchange when m2o or m2m is edited
Before this commit, when editing a many2one (with an onchange) by
clicking on the small form button on the right, then changing something,
then saving the modal dialog, no onchange was triggered, because,
technically, the value of the many2one was not changed, only the values
from the record pointed by the many2one were.

The same remarks applies to many2manys.

To see this issue in odoo, you can open a product (technically, a
product.template) from the 'Catalog' menu in sales, then edit it, then
click on the small form view icon next to Internal Category.  This is a
many2one (categ_id) with an onchange.  In the form view dialog, change
something, for example costing method, then save.  The res_id of the
internal category was not changed, but an onchange should still be
triggered.
2017-05-22 09:31:15 +02:00
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
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
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 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
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
Aaron Bohy 18c3dbc2e9 [FIX] web: FieldMany2Many with editable lists: save changes
This rev. fixes 2 issues about many2many fields displayed with
an editable list view, occuring when the user edited some values
in the list.

First, the many2many field was re-rendered each time one of its
sub-widgets triggered a 'field_changed' event, and thus the row
the user was editing was no more in edition and the focused field
was no more focused. This was quite annoying.

Second, when the user saved changes made in the editable list view,
only a command 6 (REPLACE_ALL) was sent, so updates of subrecords
were never saved.
2017-05-05 13:31:48 +02:00
Aaron Bohy 7d26d244a4 [FIX] web: BasicModel: trigger onchange when x2m is valid
When a record is added in an x2many field with an onchange, the
onchange is only triggered once the new record is valid (i.e. when
all its required fields have a correct value).

However, there was an issue in the code checking the validity of
a record, as it checked, for each required field, that its value
wasn't falsy (!value). This is incorrect for several type of
fields:
 - numerical: a value of 0 is correct
 - boolean: should be always considered as correct
 - x2m: their value is a dataPoint, so it is never falsy, what
   should be check is the number of records inside the dataPoint.

This was an issue for example in the sale.order form view, as the
onchange wasn't triggered when an order line was added (with a set
product), so the total amount wasn't updated correctly.
2017-05-04 12:39:07 +02:00
qsm-odoo 250e716c3a [REF] web, *: restore views design
Since the new views merge, a lot of design elements were broken. This
was particularly impacting the fields in the editable list view; indeed
the editable list view is not using an inline form view anymore so the
fields in the list were not properly styled as the LESS was still
defined assuming the form view environment (for example the invalid
fields were red for o2m fields in form view but not in editable list
view even though they got the right CSS class).

This commit refactor the LESS following these rules:
- No more division of non-layout and layout rules. Dividing LESS rules
  in x_layout.less and x.less was a mistake. Many rules can be
  considered to be layout and not layout at the same time, developers
  always have to switch from one file part to the other, many CSS
  selectors (and rules!) are duplicated for nothing, ...
- Field style is extracted from x_view.less and put in the new
  fields.less file. As before, the fields_extra.less will contain the
  rules specific to community so that the enterprise repo can override
  those by replacing the whole file.
- Many classes have been renamed so that o_form_x_y becomes o_x_y as
  many classes can now be applied outside of form view. These classes
  should not be used in templates anyway.

The commit also changes the DOM of fields so that it is more minimalist
(no useless parent div, etc).

Input elements are not automatically styled anymore, they have to get
the o_input class explicitely. This allows to fix lots of small style
bugs of previous versions (required monetary field had not the proper
style, readonly m2m tags appeared as editable, ...). This also improves
the LESS code.

The editable list view should also completely stop flickering on chrome
and firefox.

The commit also removes the orange outline on list view dirty cells.

The commit also removes deprecated static xml, LESS and other code.

Notice there are still styles to restore/fix and LESS to improve.
2017-05-04 12:07:30 +02:00
Géry Debongnie 91d1fd8701 [FIX] web: prevent double onchange in some cases
When we unselect a line in a one2many list, we ask for all fields to
commit their changes (because many fields are debounced, so we may not
know their current last value).  This is good, except that it could
trigger an extra field change event, which may in turn trigger a second
onchange.

We solve this issue by improving the _setValue method and delegating the
comparison to a new _isSameValue method.

It is particularly relevant for field types such as integer, which are not
stored as a string.
2017-05-04 09:32:24 +02:00
Aaron Bohy c7fc74fb79 [FIX] web: BasicModel: fetch added x2many records
Suppose that there is a many2many (list) field in a form view,
and there is a many2many (e.g. many2many_tags) field inside the
list.

In edit mode, if the user adds a record in the relation, this
record and its relational data should be fetched.

Before this rev., the relational data wasn't fetched, so the
many2many_tags couldn't be displayed correctly.
2017-05-03 20:48:25 +02:00