Commit Graph
9888 Commits
Author SHA1 Message Date
Olivier Dony 695716efb0 [FIX] P3: remove pycompat.{keys,items,values} helpers
Now that we're closer to switching to P3 for good, these helpers have
outlived their usefulness, and mostly add noise.

All remaining dict.iter*() or dict.view*() must be converted to the
normal keys(), values() or items() calls.

Whenever the result is likely to be used for more than the scope of a
loop, or when the dict needs to be modified during iteration, the calls
must be wrapped in a ``list()``, to protect the new P3 semantics.
Those cases are very exceptional.

Also removed some dead code or improved the API to remove unnecessary
conversions.
2017-08-20 23:25:54 +02:00
Xavier Morel bc7dce254d [FIX] P3: text model, base_url is a string but query_string is bytes 2017-08-20 23:25:54 +02:00
Xavier Morel be7c5aefdf [FIX] P3: CSV reading & writing 2017-08-20 23:25:54 +02:00
Xavier Morel 7dd062f835 [FIX] P3: text model types
* remove references to basestring & unicode (use relevant pycompat
  helpers)
* remove some str calls (either entirely or replaced by relevant
  helper, either text or native)
* use better API to avoid unnecessary conversions
* remove some XML declarations in views
2017-08-20 23:25:54 +02:00
Xavier Morel 3824b5dcc1 [FIX] P3: fix base64 and StringIO uses
* StringIO removed from stdlib, replace with io
* try to correctly handle BytesIO/StringIO (one is for bytes the other
  is for text)
* fix base64: Python 3 removed bytes-encoding and bytes-bytes
  codecs (via #encode) so replace all calls to str.encode('base64'),
  also b64encode is a bytes->bytes conversion so attempt to properly
  handle that

issue #8530
2017-08-20 23:25:54 +02:00
Christophe Simonis 48b2ce60ed [MERGE] forward port branch saas-16 up to 85571bb78c 2017-08-10 17:01:05 +02:00
Christophe Simonis 85571bb78c [MERGE] forward port branch saas-15 up to dde62073ba 2017-08-10 16:22:36 +02:00
Aaron Bohy 87133a8235 [FIX] web: BasicModel: correctly reload new records
Commit 7cd2f6370 (in 10.0) recently added attribute special='cancel'
on the 'Cancel' buttons of the Settings views in Odoo. The attribute
wasn't really supported in this case by the old web framework, so
this commit also slightly adapted it, and made it reload the whole
webclient when such a button is clicked.

This commit now needs to be forwardported in saas-16, so we have to
handle the case in the new views as well. Before this rev., it
crashed, because the BasicModel tried to reload a new record (the
one of the Settings form view), so basically it performed a 'read'
RPC on a virtual ID like 'virtual_123', and the server didn't really
appreciate.

This rev. handles the case where a new record is reloaded, and
simply performs a 'default_get' instead of a read. Bonus point:
with the new views, we don't have to reload the whole webclient.
2017-08-10 13:56:22 +02:00
Aaron Bohy 1e8f6d01ff [FIX] web,*: send correct context on button clicked
*account_asset

When a button of type 'action' is clicked (execute a given action),
special keys must be set in the context (active_id, active_ids and
active_model). They must be computed regarding the record containing
the clicked button, i.e. if we are in a modal, it must be the id
and model of the record displayed in the modal.

Before this rev., we always sent the id and model of the record
displayed in the background (i.e. the id and model of the url).

This caused a bug in MRP that could be reproduced as follows:
- open a manufacturing order in form view
- click on edit
- click on one of the line of the one2many, and click on the green
  icon to edit a product
- click on the update product quantity button on top of it
- the product field must be correctly filled, which was not the
  case before this rev.
2017-08-10 08:48:32 +02:00
David Monjoie 50957038b9 [FIX] web: fix magic grouping on date fields
Date fields have magic grouping methods to specify how to group on
them like date:month, date:weeks, date:days for example. It needs
to be handled properly since date:month is not a valid field name
but date is.

Steps to reproduce the issue:
- Go to Sales/Dashboard
- Click on My Pipeline
- Group by "Creation Month"

Basically, this can be triggred from any view which has a search
view which defines a group using the magic date grouping methods.
2017-08-10 08:48:30 +02:00
Christophe Simonis c3d710d2f6 [MERGE] forward port branch saas-14 up to 80ac087d6e 2017-08-09 17:11:10 +02:00
Christophe Simonis 80ac087d6e [MERGE] forward port branch 10.0 up to f69655829a 2017-08-09 15:53:37 +02:00
Jerther 64190abec5 [FIX] web: display full error message
Add missing parenthesis, fixes ebc23b5
2017-08-09 09:53:26 +02:00
David Monjoie ed286c4562 [FIX] web: disable buttons in list view on virtual records
Such buttons are not going to work on records that actually do not
exist yet. The behavior is now the same as in saas-15.

Steps to reproduce the bug:
Steps to reproduce the bug:
- Enable lots in Iventory
- Choose a product which is a component of another (through mrp bom)
- Set this product as tracked by lot
- Set this product inventory quantity to 0
- Create a new manufacturing order for the product for which it is a
  component
- Click on "Check Availability"
- Click on Produce
- Click on the little square with a + in the m2m list view, the
  server will crash in the ensure_one of the function called by
  the button since there is no record to run it on.
2017-08-08 11:18:11 +02:00
David Monjoie e2252c35c1 [FIX] web: handle create in many2many default_get
Previously, we did not handle the case where the result of the m2m
default get was a new record. In this case, we can't just send a
replace all command giving the ids since the new record has no id.

We decided to keep the replace all command even when it is empty
to stay consistent with the o2m implementation, even though saas-15
did not behave like that.

Steps to reproduce the bug:
- Enable lots in Iventory
- Choose a product which is a component of another (through mrp bom)
- Set this product as tracked by lot
- Set this product inventory quantity to 0
- Create a new manufacturing order for the product for which it is a
  component
- Click on "Check Availability"
- Click on Produce
- You'll get an error as the id given to the onchange is a virtual one,
  rather than a create which would not include an id.
2017-08-08 11:18:10 +02:00
David Monjoie 587751aa0d [FIX] web: prevent virtual datapoint creation when no default value
Previously, it used to create a virtual datapoint even though there was
no change on this field. If the field was a many2one, this datapoint
triggered a name_get call afterwards, but giving the virtual id of
the datapoint since there is no real record. The solution is to avoid
creating a virtual datapoint when it is not needed at all, thus fixing
the wrong name_get call.

Steps to reproduce the bug:
- Enable lots in Iventory
- Choose a product which is a component of another (through mrp bom)
- Set this product as tracked by lot
- Set this product inventory quantity to 0
- Create a new manufacturing order for the product for which it is a
  component
- Click on "Check Availability"
- Click on Produce
- You'll get an error as the web client tries to fetch the name_get of
  this datapoint even though the record does not exist.
2017-08-08 10:38:16 +02:00
Aaron Bohy 8a386b9a08 [FIX] web: BasicModel: domain 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.

Commit 8473bde8 added the support of the 'domain' key, but stored
it directly in the fieldsInfo (an object gathering information of
the fields in the view, and which is shared between all records).

This was wrong as the domain isn't necessarily the same for all
records. To reproduce, with the UOMs activated, go to Sales >
Quotation, in the form view, add an order line, set a product
(e.g. Graphic Card), the onchange sets the domain for the uom
field (matching uoms like 'unit', 'dozens'). Add a second line
with a service product, the onchange returns another domain for
the uom field (matching uoms like 'hours', days'). Click again on
the uom field of the first line, the domain is the one of the
second record, which is wrong.

This rev. directly stores the domains returned by the onchange on
the object representing the record, so that this information isn't
shared between records anymore.
2017-08-07 11:24:15 +02:00
Odoo Translation Bot 47d84fca1c [I18N] Update translation terms from Transifex 2017-08-06 07:14:52 +02:00
Odoo Translation Bot b5ce70e70e [I18N] Update translation terms from Transifex 2017-08-06 04:40:09 +02:00
fwi-odoo 144d8e42fc [FIX] web: load subviews in the correct function
Before this commit, it was impossible to load the x2many fields subviews when
they were not defined inline.
Now it is possible to call the method "_loadSubviews" to do so.
Used mainly in studio, to be able to display the x2many fields without inline
views.
2017-08-04 14:53:06 +02:00
Khoi Nguyen c300e5ede7 [FIX] web: reload right record when editing a many2one inside an x2many
Before this revision, editing a many2one inside an x2many field did not
cause an update of the x2many field upon saving. This is due to the fact
that a field on a screen was deemed affected by a record change only if
its value or a directly related record has been updated.

This present revision looks for changes recursively, thereby including
the case where an x2many field contains a many2one.

The bug appeared for example in Manufacturing, when editing the product
name of a BOM line.
2017-08-04 11:31:58 +02:00
Nicolas Martinelli 7cd2f63705 [FIX] *: cancel settings
To reproduce:
- Go Website Admin > Configuration > Settings
- Change the Website Name
- Click on 'Cancel'

The name is saved.

When the "Cancel" button is clicked, we automatically save the record
(which is a transient model). Since the field is a related to the
company, the name is changed even if we canceled.

opw-760749
2017-08-04 08:25:33 +02:00
Martin Geubelle d19671f0d0 [FIX] web: return a deferred in m2o quick create
The rev. https://github.com/odoo/odoo/commit/99ae418bf24171fbc6bb27584059c27efb857e77
accidentally modified the `quickCreate` return value type, which was previously a deferred.

This function is overriden in Studio to catch the deferred so the previous type has
been restored.
2017-08-03 11:11:45 +02:00
Khoi Nguyen 2258c031ad [FIX] web: fix traceback when creating an event starting at 12am or 11.30pm
Since the switch to the new views, clicking on a 12am cell in a week
view of calendar triggers a traceback. A similar issue happens when
creating an event at 11.30pm. This is due to the fact that events
starting or ending at 12am are suspected to be incorrect and are thus
checked against the database.

This commit fixes both issues, by requiring that database checks be
carried out only if the records actually exist in the database.
2017-08-02 14:54:45 +02:00
Christophe Simonis a445548f07 [MERGE] forward port branch saas-16 up to 211961c374 2017-08-02 12:18:41 +02:00
Martin Geubelle 211961c374 [FIX] web: handle mutexify in standalone widgets
The rev. https://github.com/odoo/odoo/commit/99ae418bf24171fbc6bb27584059c27efb857e77
introduced a trigger_up `mutexify` when quick creating a record in a many2one ;
this broke the behaviour when the many2one was standalone (because it has no
BasicController and mutexify is handled in the latter).

An attempt to fix this issue has been made in the rev. https://github.com/odoo/odoo/commit/e83c3e2678500c9bf2c17b4d23ae9a294ebafaa7
by adding an option `standalone` in the field widget options. In this case,
the action was directly executed instead of the trigger_up. While this correctly
works, this implies that the option needs to be added in every standalone
many2one (and only many2one as the others won't use the option), which is not
very convenient.

An other attempt is made in this rev. by moving the mutexify handler from the
BasicController to the FieldManagerMixin ; as a widget that instantiates a field
widget needs to extend this mixin, both cases will work and we won't need to
specify the option anymore.

This commit thus partially reverts the rev. https://github.com/odoo/odoo/commit/e83c3e2678500c9bf2c17b4d23ae9a294ebafaa7
2017-08-02 08:49:12 +02:00
Christophe Simonis 072411b336 [MERGE] forward port branch saas-16 up to 8d89148d13 2017-08-02 01:08:42 +02:00
Khoi Nguyen 597d172ff0 [FIX] web: always call 'search_read' when loading calendar
This commit reverts
https://github.com/odoo/odoo/commit/2e2ab4e954cd5da8c0c06d393b334cefc7627315
(which ensures that if all filters are 'inactive' then nothing is shown)
for the following reasons:

- It is not necessary since _getFilterDomain was rewritten (see
  https://github.com/odoo/odoo/commit/4e12edc023dd20d435f5575b5517a3c11deb8421).
  If all filters are inactive, _getFilterDomain does now return an
  "in []" domain.
- It shows an empty calendar when filters yield an empty domain.
2017-08-01 18:03:15 +02:00
Christophe Simonis 391a29dc42 [MERGE] forward port branch saas-16 up to 3becbd764d 2017-07-31 19:07:04 +02:00
David Monjoie 28bf5f007f [FIX] web: fix action context with no explicit context
When I did efd15852, I accidentally undid d20074c5. That commit
wanted to filter out unwanted values from the action context, but
it was too violent, as it was discarding the action context. (See
bug described in efd15852)

My original commit aimed at avoiding the filtering of the action
context by having it devoid of unwanted values altogether. The
idea was "if this is an action button, we don't want the element
context". However, the default behavior of the _getContext function
was to add the element context. There were options to force to add
the element context despite being in a case where it should not be
added, but we needed the opposite: do not add the element context.
We used "additionalContext" in this fashion, the idea was: "if I
give you specific context values, don't polute it with the element
context". This was efd15852.

However, not all actions have context defined explicitely in their
definition. In this case, since additionalContext was undefined,
the element context was added again, despite our will not to add
it for actions. We solved this by simply always giving an
additionalContext to getContext, providing an empty one if needed.

To reproduce this bug (which is the same as efd15852):
- Go to Manufacturing
- Click on menu Master Data then Products
- Open a product
- Click on the "Bills of Materials" stat button
- Click on create
- The create crashes because of the "default_type" context key
  that is erroneously passed from the "Products" action to the
  "Bills of Materials" stat button action.
2017-07-31 15:53:12 +02:00
Christophe Simonis f46a393602 [MERGE] forward port branch saas-16 up to 09d698d05f 2017-07-31 14:53:06 +02:00
Christophe Simonis 09d698d05f [MERGE] forward port branch saas-15 up to a6900c43b4 2017-07-31 14:09:34 +02:00
Khoi Nguyen a752e7d145 [FIX] web: make calendar adapt to screen size
This commit aims to reproduce saas-15 behaviour when rendering the
calendar. More explicitely, in favourable conditions, we would like the
calendar to be contained in a scroller adapted to the screen dimensions.

To do so, we require that the calendar only use the height given by its
parent container (in case of overflow, the calendar should have its own
scrollbars). We then trigger a 'resize' event to account for a bad
initial render of the calendar.
2017-07-31 13:52:53 +02:00
Adrien Dieudonne a1f7aa3362 [FIX] web: form_renderer: disable buttons on clicking status bar
This fix reproduces a behavior implemented in saas-15.
It avoids simultaneous actions when you quickly click
on status bar buttons.

For example, in a manufacturing order, the main_flow_tour clicks
on 'check availability' and 'produce'.
Clicking on 'check availability' triggers an act_window_close
action when it has done.
Clicking on produce opens a dialog. Both action are executed simultaneously.
It may happen that the act_window_close closes the dialog opened by action
'produce', which makes the test fail.

Now the following buttons are disabled if you click on a status bar button:
- action buttons in control panel
- action buttons in status bar
- stat buttons in button box
2017-07-31 13:49:42 +02:00
Christophe Simonis a6900c43b4 [MERGE] forward port branch saas-14 up to 9cae991345 2017-07-31 12:59:48 +02:00
Christophe Simonis 9cae991345 [MERGE] forward port branch 10.0 up to 1e64a88cd3 2017-07-31 11:45:29 +02:00
Odoo Translation Bot 90282fa2d5 [I18N] Update translation terms from Transifex 2017-07-30 07:14:49 +02:00
Odoo Translation Bot b1e79e85bd [I18N] Update translation terms from Transifex 2017-07-30 04:40:00 +02:00
Christophe Simonis 4d5ff6401c [MERGE] forward port branch saas-16 up to b76109173a 2017-07-28 18:37:10 +02:00
Jeremy Kersten f3f66d2b8e [FIX] web: avoid cast None in int
Some function send None instead of 0
2017-07-28 18:30:01 +02:00
Christophe Simonis b76109173a [MERGE] forward port branch saas-15 up to c0ec09e9d5 2017-07-28 18:11:07 +02:00
Christophe Simonis c0ec09e9d5 [MERGE] forward port branch saas-14 up to be77cf7f5f 2017-07-28 17:25:45 +02:00
Christophe Simonis be77cf7f5f [MERGE] forward port branch 10.0 up to e686385138 2017-07-28 16:56:14 +02:00
Yenthe V.G d82933d8e7 [FIX] web: change exception name from openerp to Odoo
The crash manager still used the old name for the exception. (PR #18522)
2017-07-28 15:44:18 +02:00
Aaron Bohy 2ba72fb224 [FIX] web: graph: reload with correct fields
A traceback occurred when trying to reload a graph view with no
groupBy in the searchview, because the array of fields to read
given to the read_group RPC didn't contain the default groupBy
field (Error "Fields in 'groupby' must appear in the list of
fields to read"), e.g. in Sales > My Pipeline.
2017-07-28 09:27:31 +02:00
David Monjoie 3b3f6f04af [FIX] web: save changes when readonly if force_save is set
In previous versions, readonly used to prevent sending the values
of the fields to the server. However, it was not working properly
for fields which have their own sub-arch in the view, as the value
used to be sent regardless of the readonly value.

In the new views, the readonly modifier is never overlooked, which
created a bug in the stock_picking_return wizard which was not
able to return products received from a po anymore. Basically the
value of the product_id field was not sent so the create crashed.

This commit introduces a new "force_save" modifier which is used
to express that we want to save the value of the field even though
it is readonly from a user interface point of view.
2017-07-28 08:29:12 +02:00
Khoi Nguyen 4e12edc023 [FIX] web: correct domain when using 'all' filters
Since the switch to the new views, 'all' filters such as "Everybody's
calendar" did not work as intended (activating the filter would
sometimes lead to fewer events being shown).
This commit corrects the way 'all' switches affect a domain.

More precisely, the conversion from filters to domain has been changed
in the following way.

- Ticking all visible checkboxes associated with a filter no longer
  means the same as ticking the 'all' checkbox. The former choice was
  particularly problematic when a filter only had one visible checkbox,
  in which case it was not possible to see the list of records
  only associated with that one filter.
- The conversion used to contain an impossible case in which we convert
  a filter into a 'not in' domain. All the related logic has now been
  deleted.
- Minor changes (renaming variables etc.) to make the code more
  readable.
2017-07-27 17:11:41 +02:00
Aaron Bohy c3691a79cb [FIX] web: grouped list: update row after edition
Grouped lists aren't editable. However, they may contain a widget
allowing the edition in readonly (e.g. priority, toggle_button...).
This is for example the case in Leaves > Reporting > Leave Details.

When the toggle button is clicked, the model is correctly notified
of the change, which is correctly sent to the server. However,
before this rev., the edited row wasn't redrawn in the grouped
list, so the former value of the boolean was still displayed.
2017-07-27 14:35:17 +02:00
Adrien Dieudonne a71f223702 [FIX] web: InputField: don't re-render if dirty
Let's assume that we have a form view with a one2many field
displayed as a list containing two fields A and B (an input field,
e.g. a char field). An onchange on the one2many is triggered as
soon as A changes. This triggers a reset of the one2many which
thus redraws the corresponding line by resetting its widgets.

A problem occured when the user updated A, and directly (before
the onchange returned) updated the input field B, as in this case
the new value in B was erased when the onchanged returned, as the
widget was reset with its former value (or with the value returned
by the onchange, if any). Note that the model was aware of the
change on B, so the model and the UI were actually desynchronized.

This was quite hard to reproduce in practice, by hand, but it
occured in the tour testing 'the flow', in the form view of
account.bank_statement, with fields partner_id and amount of the
line_ids one2many.

With this rev., we don't re-render the input fields if there are
pending changes that haven't been acknowledged by the model.
2017-07-27 13:58:43 +02:00
Géry Debongnie 72ed3a153a [FIX] web,pad: record is not considered dirty when pad is loaded
The pad widget does something unconventional: it creates the pad url
only when rendering in edit mode.  This was done to prevent creating pad
by default for record in readonly mode.

Because of that, if the user clicks on create, then discard, the record was
considered dirty, so a confirmation modal popped up.  In this commit, we
just make sure that the initial setValue from the rendering does not
'dirty' the record.
2017-07-27 11:34:04 +02:00