In an editable list view, if there was a readonly field in the table,
positionned before editable fields, clicking on that readonly field
resulted in the editable field widgets being re-instantiated and
appended to the DOM (so there were several widgets per fields/cells).
The method 'setController' allows to change the default Controller
Widget used by the view. However, before this fix, calling it
changed the default Controller of all other Controller instances.
Before this commit, we only consider the BasicModel point of view to
determine if a record is dirty. It is good when we want to determine if
it is actually necessary to save the data, but not correct when we want
to know if some changes can be discarded.
With this commit, the form controller keeps track of its 'dirty' state,
coming from user interactions. It uses this flag to determine if
changes can be discarded.
With the new JS test framework, we had experimented with an autodestroy
feature, meaning that all views/widgets are automatically destroyed
after a while. By default, it was 50ms, because we could not hook some
code to run after the end of the current test.
For various reasons, this was not a good idea: some side effects, such
as modifications of the session or of the DOM (with modals) could
interfere with other tests. This commit disable the feature.
From now on, we will have to destroy each widgets created in a test.
The code for selectCell was active, when the user clicked on a td. No
test caught that, because we simulated a click on a tr, not on a td.
I guess that the lesson of the story is that our tests should be as
close as possible to the real conditions, so we should simulate the
click on the innermost element.
Before this commit, the form view opened by a one2many did not check
that the required fields were properly set, so it could lead to pretty
strange results.
Before this commit, the rawify function assumed that any object is
necessary a record object. This was true until recently, when we
decided that dates should be internally stored as a moment instance.
Some fields need to do some model RPC calls (name_search, name_create,
...). Before this commit, they did not use the performModelRPC method
but an explicit trigger_up so that the BasicController (the
FieldManagerMixin) catches it and ask the BasicModel to perform the
RPC. This was designed to let the BasicModel handle the context.
This commit makes the context be automatically binded without the need
to explicitely call the BasicModel for each route in the
FieldManagerMixin. It also ensures that the field own context is
properly merged with the user/action/search contexts.
Now, the fields use the performModelRPC method and the
FieldManagerMixin catches the associated "call_service" event. Then, it
can get the full context from the BasicModel instance and let the event
continue its propagation. To know which field context has to be fetched,
the performModelRPC method is overriden by AbstractField to
automatically add the dataPointID and the field name in the options
parameter.
Hopefully, this commit makes it consistent. There were two problems
with the previous implementation:
- Contexts from field attr (if asked thanks to the options.field
parameter) were not evaluated with the right evaluation ctx
- "raw" contexts (from parent) had to be evaluated with another
evaluation context
Also rename the options.field parameter to options.fieldName.
FieldMany2One was declared as an extension of AbstractRelationalField
AND mixins.ServicesMixin... which was wrong since the mixin is already
added to the Widget class. This caused the extension of the mixin
methods to be lost.
We replace a bunch of formatting and parsing functions by an object
(parse or format) which can be used to dispatch on the correct type. It
allows us to remove the format_field and parse_field functions.
Also, we camelcase our new code and add some comments.
The field_utils date method have been modified recently, and the idea
behind those changes is that the BasicModel keeps at all time a moment
instance as its internal representation of a date or datetime.
But the parse and format methods did not properly support unset dates,
so we have to slighlty change them to support the case where their values is
not set.
Before this commit, the BasicModel didn't parse the dates when loading
data for a list. But the rest of the web client assumes that data is
properly parsed into their correct types, so a moment instance for date
and datetime.
Also, uppercase field_utils and properly reorder imports
Until now, those tests failed if the window did not have the focus. We
solve the issue with 2 different fixes:
* instead of checking that the focus property is set, we can check the
activeElement instead, it seems to work.
* instead of calling the focus method, in some tests, we can trigger a
* 'focusin' event. I don't know why this works, but it does.
Note that this might make the tests work in phantomjs
Before this commit, the odoo web client used strings to represent dates.
Now, the date is parsed into a moment object when the value is read from the
server side. The widget formats the object to display the value. When the
widget value changes, the value is parsed to a moment object. The value is
automatically formatted to server value in ajax calls (toJSON method).
Commit cef659783514f8935cc46a496f71063d022e8dac changed the way domains
are computed but forgot to change the values representation used by the
Kanban view. This commit fixes that and adds tests to make sure it does
not happen again.
Before this commit, modifiers were partially processed by the mock
server. Now, it should be a better approximation of what the server
does:
- Take the invisible/readonly/required from "attrs"
- Merge invisible with the "states" ([["state", "not in", states]])
- Override if invisible/readonly/required attribute is present
+ Adapt some tests
With our new views, we broke almost all JS code, including the
reconciliation widget, which was (and still is) dependant on the field
widget. With this commit, we rewrite and simplify the reconciliation
code. We also add some tests, to help with the maintenance.
Work done by CHM
This commit introduce a full redesign of all JS views. We started
basically from scratch. The goal was to unify all the various views
under a common framework, to make them testable, to make then usable in
different conditions (in studio, or in the frontend), and to make our
lives easier.
Some important points are:
- we introduced new coding guidelines (camelCase, 80 chars width, ...)
- we have a brand new testing framework (still QUnit based)
- kanban view moved to the web addon
- calendar view (formerly web_calender) moved to web as well
- the tree view was removed
- all new code should be documented
We hope that this code is the start of a new era for the Odoo web
client, we want to have a high quality codebase, well documented, well
tested, well designed.
Work done by the framework team: mostly aab, ged, chm, dmo, qsm