Commit Graph
109760 Commits
Author SHA1 Message Date
Martin Geubelle fc82e1e40a [FIX] mrp: correctly replace inputs in pdf_viewer widget
In the extended template `HiddenInputFile` there are actually two inputs
(one for image only and another one).

This widget needs to replace both of them otherwise the file selector will
be opened twice.
2017-05-24 08:25:23 +02:00
Aaron Bohy 460c21f765 [FIX] web: Kanban: various bugs in grouped mode
This rev. fixes the next three bugs:
 - the dataPoints representing each group didn't have the parentID
   attribute set
 - when quick creating a record, the res_ids and count attributes
   of the group, and of the parent weren't correctly updated
 - when quick creating a record, the environment (view_manager)
   wasn't correctly updated

The combination of thoses bugs produced the following crash. Open
a grouped kanban view (e.g. project.task), quick create a record,
open that record in form view (note that the pager was wrong, it
indicated 0/x, where x number of records), delete the record ->
the form is supposed to load the next record, but it
crashed because it couldn't get its id (trying to read id null).
2017-05-24 08:25:22 +02:00
Aaron Bohy 38dfe6c51d [FIX] board: properly render with twice same action
Before this rev., the dashboard wasn't rendered correctly when
the same action (same action id) was several times in the
dashboard.

For instance, if the dashboard contained the list and kanban view
of an action, both views were rendered in the same block, leaving
the other one empty. Moreover, (un)foldeing one automatically
(un)folded the other one.

This was because the action id was used to identify each view, but
this id is not unique in the dashboard. We now use a generated id
instead, which is unique.
2017-05-24 08:25:22 +02:00
Adrien Dieudonne a1e1b0b933 [FIX] web_editor: allow html widget for html fields
Before this commit, it was not possible to set the 'html' widget
for a field in Studio.

Even if this is the default widget for the form view, it not the
case for the kanban view. You need to precise each widget you
want to use (for performance reasons).

opw-744254
2017-05-24 08:23:05 +02:00
David Monjoie 374295bf84 [FIX] web: save should not re-read fields if none were changed
Previously, it used to reload its data when the user clicked
multiple times on save, even though there were only changed
fields during the first initial save, all the other queued
ones have no changes at all and, as such, should not trigger
additional reloads.
2017-05-23 11:41:17 +02:00
David Monjoie 3460bda520 [FIX] web: disable stat buttons until action resolution
Previously, it was possible to click multiple times on stat
buttons while still waiting for the result of a previous button
click. This could end up with the web client in strange states
or, worse, lead to tracebacks. Because of this, we decided to
disable the buttons once one of them is clicked and restore
them afterwards.

By doing this, we encovered a place in the code where a failed
deferred would not be properly forwarded back to the caller,
which meant, in our case, that the buttons would not be
enabled back in case the action failed. This is now fixed.

Initial methods to fix this issue used to break the test below.
Because the label of the assertion this used to break was
contradictory with the value it was actually expecting, we
decided to fix it as well.
2017-05-23 11:41:15 +02:00
David Monjoie e783844f5b [FIX] web: fix missing tests for discard buttons update
Previously, the buttons were not updated properly after discarding
from an editable list view. The user was stuck with "Discard" even
though there was nothing to discard anymore, and he could not create
a new record either since the "Create" button was invisible.

This was fixed by 3aad756. I originally did a different fix which
has since been rendered useless, but the tests I wrote are still
meaningful since they are testing a different case than the commit
which fixed the issue.
2017-05-23 11:41:14 +02:00
Harshad Modi 109b319d64 [FIX] web: send date string in server compatible format
Languages like Arabic (ar_SY), Hindi(hi_IN) do not use english digits to describe dates, and moment.js format function will keep these characters.  So, the server will get date strings, and will be unable to use them.

To see the problem, just type moment().locale('ar_SY').format('YYYY-MM-DD') into a browser console.

In this commit, we simply force the locale to 'en' before sending data to the server.

PR #17156
2017-05-23 10:34:08 +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
Aaron Bohy 967978c96e [FIX] web: Kanban: correctly mute 'Create' button
In Kanban views, the 'Create' button must be muted (btn-default)
in grouped mode, if there is no column and if the column quick
create feature is enabled (as in this case, the first action
should be to create a column).

Before this rev, it was actually muted if there were no record, no
matter if there were columns or not.

This was because the 'count' attribute of dataPoints was used to
determine the number of columns, but this attribute represents
the number of records in the dataPoint (i.e. the sum of the number
of records in each groups).

This particular case was tested, but the test passed thanks to
another bug (we incremented the 'count' attribute in the kanban
model when creating a new group, whereas we shouldn't).
2017-05-22 13:06:47 +02:00
Aaron Bohy 95b853ad2d [FIX] web: List: right align aggregate values
... in group headers, and in footers.
2017-05-22 13:06:10 +02:00
Aaron Bohy 3bb2b69d4a [FIX] web: Form: right align subtotals
The subtotals displayed in the oe_subtotal_footer (e.g. sale.order
form view) should be right aligned. Before this rev. this wasn't
the case for monetary fields, they are now displayed 'inline-flex',
whatever the form mode (before the new views, they were
'inline-flex' only in edit mode).

Credit goes to @qsm-odoo.
2017-05-22 13:06:10 +02:00
Yannick Tivisse 3a9d3a735d [IMP] website_customer: Add Sector of Activity on customer references
- Add a "Filter by Industry" filter on top of the "Filter by Country" on the main /customers page. It should work similarly to the filter by "Level" in the /partners page of crm_partner_assign, but would filter on the customer's industry (With "All Industries") etc.
	- (Cfr www.odoo.com/customers vs www.odoo.com/partners for live examples)
- The search input field on the main /customer page should search on the Industry field as well
- Add the "Industry" info to the /customers index, e.g. like a badge: http://i.imgur.com/Nzjeck9.png
- Add the "Industry" info to the website_customer.details template, e.g. like a badge or in the address block on the left
2017-05-22 11:30:11 +02:00
Yannick Tivisse 9a572f8eec [IMP] base: Add a new model 'Sector of Activity' used on partners
purpose
=======

We need to store and produce reports about customer activity sectors to improve references mechanism.

Specification
=============

- add a new model res.partner.industry "Sector of Activity"
    - fields:
        - name (translatable)
        - full_name (translatable)
        - active
    - add minimalist form and list views (à la Contact Tags)
    - menu: Sales/Settings/Contacts/Contact Industries  (Technical Settings only)
    - ACL: R for group_user, CRUD for group_system
- add a default XML data file to preload res.partner.industry with the ISIC 2008 aka NACE rev.2 level 1: https://docs.google.com/a/odoo.com/spreadsheets/d/1IrGbHIaaDDkBAS2uGABeNRPndtYbyVBVoYYpQNXnhnY/edit?usp=sharing
    - Note: we leave it as an option for end-users to import their own industries, because there are many competing standards: ISIC, NACE, NAICS, OKVED, etc.
    - Each standard also has different hierarchical levels, and we only use the top level one by default.
- add a m2o industry_id ("Sector of Activity") on res.partner towards res.partner.industry
    - add industry_id in partner form view, in Sales & Purchase > Misc, only visible when contact type is Company
    - No quick create for this field
2017-05-22 11:30:11 +02:00
Géry Debongnie ed603399f9 [FIX] mrp: always use sequence on 'unbuild' creation
The mrp.unbuild model creates a name based on a sequence if no name is
given in the value dictionary.  This was fine before the new views,
because the field name (in the form view) was marked readonly, so the
value 'New' was not actually sent to the server.

However, this was changed with the new views: readonly fields are always
sent on create/write operations, if they have been modified.  This is a
problem for the mrp.unbuild model, because this means that each new
record as effectively the same name: 'New'.

So, we simply always use the sequence-based names in the create
operation, when the name is 'New', instead of the value given as parameter.
2017-05-22 11:29:35 +02:00
Géry Debongnie 8b94bf8b28 [FIX] web: form: remove o_field_invalid class when not necessary
Before this commit, the o_field_invalid class was not removed once an
invalid field becomes valid, until the user saves the form view (which
will rerender the full view anyway)
2017-05-22 10:07:33 +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 5e913677a5 [FIX] web: prevent crash when downloading pivot view
The download feature in the pivot view was broken since we introduced
the new views.  Simply clicking on the download button caused a
traceback.
2017-05-22 09:34:49 +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
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
Aaron Bohy a845ecffa1 [FIX] web_editor: field html: save changes done in code mode
Summernote doesn't call the onChange callback when changes are
done in the code mode, so the html field isn't aware of those
changes. It means that if the user does some changes in code mode
and then save directly (without coming back to normal mode), those
changes are lost.

This rev. ensures to save every changes by manually come back to
the normal mode before saving, as this will correctly trigger the
changes. Actually, it simply restores some code of the previous
implementation (before new views) of this widget.
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 f77e86b67b [FIX] mass_mailing: read_group: grouped on selection field
The model MassMailing overrides read_group to handle the case when
it is grouped by field state, which is of type selection. However,
it sets as value for each group the array [key, name] of the
selection option, which is incorrect (it should set key as value,
like the default read_group does, and as the name is known client
side anyway).

This case was handled by the old views, but it isn't by the new
ones, which are less permissive. We choose to fix the read_group
override instead of allowing both cases in JS, as it is always
better to have a clear and single API.
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 787daee41f [FIX] stock_account: inventory valuation: default value
... for 'compute_at_date' field (default 0, 'Current Inventory').

Before the new views, this value was selected by default by the
FieldRadio, but it was a mere coincidence. Indeed, as the field
had no default value, no value was specified in the default_get,
and for no reason, the widget selected 0 as value.

Anyway, as this behavior was wanted, we simply specify a default
value in the action.
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
Sanjay Jamod 8dac9cfc93 [FIX] web: website tour and website seo are using ajax_service
so load ajax_service service into assets_common instead of assets_backend (#16993)
2017-05-16 15:05:16 +02:00
Géry Debongnie c3ca877d81 [IMP] web: better error logging for qunit tests
Before this commit, when a test in the qunit test suite failed, the
error displayed by the runbot was not really interesting.  It just said
that test_01_js failed.  With this commit, each assertion error is now
logged as an error, which means that they are displayed in the short
error log by the runbot.
2017-05-16 14:41:03 +02:00
Géry Debongnie 15a227375a [ADD] web: add benchmark support
With this commit, we introduce a benchmarking infrastructure: a new
controller, accessible at the route /web/benchmarks which will render a
new template (web.benchmark_suite).

This template uses benchmark.js and qunit.js to display a list of
benchmarking informations.  For example, the number of op/s for
instantiating and destroying a list view.

I hope that this is the start of the beginning of taking the habit to
check our JS code performance sometimes, and making sure we do not have
large regression without a good reason.
2017-05-16 14:41:00 +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 878fbc75ff [MERGE] Forward-port saas-14 up to a6e2b3929f 2017-05-16 13:27:08 +02:00
Olivier Dony a6e2b3929f [FIX] website: remove extra % char in forward-port 2017-05-16 13:25:56 +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
qsm-odoo 1545995b39 [FIX] web_tour: tips were overlapping the chat windows
Before this commit, the tour tips were overlapping the chat windows.
This was due to the fact they always had a z-index of 1051 wherever
they were. If a tip was placed in a location where none of its
ancestors created a new stacking context, the closed tip was then
positioned above everything else, including the chat windows.

A simple solution would have been the one proposed by this commit:
https://github.com/odoo/odoo/commit/856e78b35a47a8732e5bd4da1cce247df70e5414
However, as it explained, this would not be entirely correct. In the
website, elements are using z-indexes and would thus hide closed
tooltips when it is not wanted if those have no z-index at all.

The solution this commit is making is to force the creation of a
stacking context for tooltips' parent. The z-index will still exist
on all tips (closed and not closed) to force them above every other
elements, but now only elements of the same parent. This is indeed
more correct (but maybe still not entirely): website tooltip are
often placed in the body (as it is the element which scrolls) and
are thus still placed above elements like the navbar as their
z-index is left high. However, when placed in the appswitcher, they
will now be placed above appswitcher elements only (and thus not
above outside elements which are themself above the appswitcher
(e.g. the chat windows)).

opw-743330
2017-05-16 11:17:13 +02:00