Commit Graph
5848 Commits
Author SHA1 Message Date
William Braeckman d90153180d [FIX] base: fix file extension when using default name
The file extension detection previously used to determine whether a
filename required an extension was not very smart and in fact only
checked for a dot in the filename.
`mimetypes.guess_type` is now used on the filename to better determine
whether the filename still needs a file extension or not.

This commit is a follow-up to: https://github.com/odoo/odoo/pull/90614
Which aimed to fix the same issue.

TaskId-2826061

closes odoo/odoo#91254

X-original-commit: bf904a7f98ba5bcc0a8909cca3241e2965c4464c
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2022-05-12 21:13:34 +02:00
Victor Feyens a945d9043c [IMP] core: simplify & improve docstrings
closes odoo/odoo#90915

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-05-12 17:34:38 +02:00
Florian Charlier b0f233ba86 [FIX] link_tracker,mass_mailing_sms: fix shorten links
Purpose
Fix bugs in link replacement (html and text version)

1/ The replacement of urls in text (not html) was buggy when
* a string includes multiple urls, and
* `base_url` is one of them and not the first
* Also in SMS marketing when adding the sms `id`

When it came to base_url's turn, the replace function for the content would
replace the `base_url` part of a previously shortened url instead of the
distinct `base_url` link.

2/ Ampersand character
A) The ampersand character prevented replacement of an url inside a `Markup`.
Previous tests passed as the tracker was created but the url was not replaced.

B) The ampersand character was not recognized as part of an url for simple
strings.

3/ Replacement of already short links
A faulty logic made it possible to replace "/r/" urls when no "blacklist" was
passed.

Commit
* Ensures that only the base_url link would be replaced instead in this case.
* Adds support for urls with "&"
* Does prevent shortening short urls
* Improves link conversion performance (regex + avoid duplication when there
  are several occurrences of the same url)
* Adds multiple unit tests

Task-2783844

closes odoo/odoo#91164

X-original-commit: 61026806d831b49a7cf5c44ffef3d762986781ce
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-05-12 13:43:17 +02:00
Stanislas Gueniffey ac175c98e1 [IMP] define xml_utils.cleanup_xml_node
Intended to cleanup qweb xmls:
- remove blank (empty) nodes and/or nodes with whitespace text
- fix indentation
- remove indentation (needed for some xml signatures)

closes odoo/odoo#91006

X-original-commit: b7d7adb4f5a9873350511c227d5fbf54c8f38ce8
Signed-off-by: William André (wan) <wan@odoo.com>
2022-05-11 09:21:59 +02:00
Ivan Yelizariev 5bf898d58a [FIX] core: use non-breaking space for currency symbol
In some languages and layout the currency symbol might be wrapped in a separate
line, which is not acceptable from accounting point of view. Fix it by replacing
space with a special symbol.

STEPS for v15:
* install MX localization;
* create a Spanish speaking customer
* generate a pdf:
1) Create quotation with products
2) Add IVA 16%tax
3) print a report

BEFORE: the currency symbol is incorrectly displayed on a separate line
AFTER:  currency symbol is always with the amount

---

https://github.com/odoo/odoo/pull/89722
opw-2829138

closes odoo/odoo#90961

X-original-commit: 684687226b87022bc9f9ba7667b295e545100645
Related: odoo/enterprise#27138
Signed-off-by: William André (wan) <wan@odoo.com>
2022-05-10 13:22:42 +02:00
Moens Alexandre 06964fee08 [FIX] cloc: empty string in demo(_xml) or cloc_exclude
Before this commit:
calling `odoo-bin cloc -P <path_to_a_module>` when the manifest of a
module includes an empty string in the demo, demo_xml or cloc_exclude
entries, would result in a crash because an empty string is not an
acceptable pattern for Path.glob

to note: an empty string in those entries is technically wrong and will
cause issue during module install, but that shouldn't prevent the cloc
from giving correct results.

closes odoo/odoo#90650

X-original-commit: 93318b22fc8b7cf6344f789d2c45fc3f5b3269eb
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Thibault Francois <tfr@odoo.com>
2022-05-09 11:25:24 +02:00
Denis Ledoux ede6e47ebd [FIX] models.py: fields_view_get compatibility layer
On a `sale.order`, when hitting the `View Forecast` button,
a traceback occurred:

```
Traceback (most recent call last):
  File "/home/odoo/src/odoo/master/odoo/http.py", line 1381, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/home/odoo/src/odoo/master/odoo/service/model.py", line 136, in retrying
    result = func()
  File "/home/odoo/src/odoo/master/odoo/http.py", line 1410, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/home/odoo/src/odoo/master/odoo/http.py", line 1607, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/home/odoo/src/odoo/master/addons/website/models/ir_http.py", line 220, in _dispatch
    response = super()._dispatch(endpoint)
  File "/home/odoo/src/odoo/master/addons/utm/models/ir_http.py", line 27, in _dispatch
    return super()._dispatch(endpoint)
  File "/home/odoo/src/odoo/master/odoo/addons/base/models/ir_http.py", line 137, in _dispatch
    result = endpoint(**request.params)
  File "/home/odoo/src/odoo/master/odoo/http.py", line 541, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/home/odoo/src/odoo/master/addons/web/controllers/dataset.py", line 42, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/home/odoo/src/odoo/master/addons/web/controllers/dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/home/odoo/src/odoo/master/odoo/api.py", line 457, in call_kw
    result = _call_kw_model(method, model, args, kwargs)
  File "/home/odoo/src/odoo/master/odoo/api.py", line 430, in _call_kw_model
    result = method(recs, *args, **kwargs)
  File "/home/odoo/src/odoo/master/odoo/models.py", line 1808, in fields_view_get
    view = self.env['ir.ui.view'].sudo(result.pop('id'))
  File "/home/odoo/src/odoo/master/odoo/models.py", line 5381, in sudo
    assert isinstance(flag, bool)
AssertionError
```

This follows the `load_views` refactor odoo/odoo#87522.

`fields_view_get` has been deprecated. All calls to it must be replaced
by calls to `get_views`.
Leaving it there is an oversight:
https://github.com/odoo/odoo/blob/fc26cc1789b1309e54473cccbc545145ccbaee31/addons/stock/static/src/js/report_stock_forecasted.js#L116

However, this demonstrated an issue in the compatibility layer added
server-side to keep `fields_view_get`.

This revisions solves the compatibility layer bug.
In the next commit, the call to `fields_view_get` is replaced to
a call to `get_views`

Part-of: odoo/odoo#90750
2022-05-06 17:06:59 +02:00
Olivia Fantinel 6203e91e8b [IMP] base: see server action id in test_expr
When we had a traceback because of a server action, we used to have no
information in the traceback about which server action it was.

With this commit, we will be able to see the server action id in the
traceback. This will help the investigation as we will be able to check
the server action that causes the issue.

Example:

Previous traceback for a server action that executes bad python code:

```
Traceback (most recent call last):
  File "/home/odoo/src/version/15.0/odoo/odoo/tools/safe_eval.py", line 330, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
  File "", line 1, in <module>
NameError: name 'i' is not defined
```

Now:

```
Traceback (most recent call last):
  File "/home/odoo/src/version/15.0/odoo/odoo/tools/safe_eval.py", line 330, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
  File "ir.actions.server(152,)", line 1, in <module>
NameError: name 'i' is not defined
```

closes odoo/odoo#87086

Signed-off-by: Olivia Fantinel (ofa) <ofa@odoo.com>
2022-05-06 15:31:50 +02:00
Victor Feyens 1acd299934 [IMP] core: mark fields_view_get deprecated in its docstring
Now that the method is deprecated, we think it's better to
keep showing it in the doc, but with a clear deprecation notice
in the docstring (instead of hiding it).

closes odoo/odoo#90634

Related: odoo/documentation#1908
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-05-05 18:47:55 +02:00
MAHAMADASIF ANSARI e246bf1448 [IMP] base: allow to specify decimal points with format_decimalized_number
Currently, we can format the number into decimal points with help of
the `format_decimalized_number` option of `ir.qweb.field.integer`
class. However, sometimes we need to decide how many decimal points
we need to display, which is not possible with current implementation.

This commit improves the above option and now allows to pass the number
of decimal points, with a new option `precision_digits`, which defaults
to one decimal point.

task-2792149

Part-of: odoo/odoo#87996
2022-05-04 17:46:12 +02:00
Julien Castiaux d9608b1932 [FIX] core: skip debugger for JSON-RPC in --dev=werkzeug
When started with the CLI option --dev=werkzeug, errors in controllers
are caught by a friendly web debugger. This debugger should not be
started in case of error in a JSON-RPC controller.

closes odoo/odoo#90420

Task: 2837457
X-original-commit: 711a29e76f55e87d73dad89ddbef889dd5c7af10
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-05-04 10:55:55 +02:00
Raphael Collet 68aa10fc24 [FIX] base: do not load translations twice
This fixes former pull request odoo/odoo#78287.

The language installation wizard was invoking toggle_active() on the
target languages, which loads translations for those languages (with
overwrite=False), and then loading translations again (with expected
parameter overwrite).

Simply don't use toggle_active(), and directly set the active field
instead, in order to load translations once with the expected parameter
overwrite.

closes odoo/odoo#90421

X-original-commit: 3e4733859fbe2465c386ec65b7be995b152c8c48
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-05-03 17:53:58 +02:00
Dossogne Bertrand 605a3c1e44 [IMP] hr_*: uniformize group category
*:
approvals
hr_apprasaisal
hr_payroll
hr_referral
fleet
hr
hr_attendance
hr_holidays
hr_recruitment
lunch

Change various access rights names to improve understandability for users.
Addition of an officer role in fleet with intermediate accesses

TaskID 2742855

closes odoo/odoo#87545

Related: odoo/enterprise#25741
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-05-03 14:38:19 +02:00
Victor Feyens e151251009 [FIX] core: docstring of new get_view method
Fixing docstring of new get_view method (odoo/odoo#87522),
to include it in the doc (and replace reference to the deprecated
method fields_view_get).

models.py:docstring of odoo.models.BaseModel.get_view:8: WARNING: Unexpected indentation.
models.py:docstring of odoo.models.BaseModel.get_view:9: WARNING: Block quote ends without a blank line; unexpected unindent.

+ some little improvements to the docstring

closes odoo/odoo#90372

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-05-03 13:31:31 +02:00
Victor Feyens 42bad1a6d2 [IMP] *: remove useless keys from manifests
Remove most values uselessly specified because giving the same value as 
the default one (see _DEFAULT_MANIFEST in odoo/modules/module.py)

* auto_install is Falsy by default
* author is Odoo SA by default
* summary & description are empty strings by default
* application is False by default
* test, demo, depends and data are empty lists by default

This will reduce noise/inconsistencies between manifests specifications, 
simplify analysis of manifests content, ...

closes odoo/odoo#90209

Related: odoo/enterprise#26807
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-05-03 13:31:16 +02:00
Gorash fd1c982a40 [IMP] core: handle recordset comparison with lazy() recordset
The base model is modified in order to be able to make comparisons between
recordsets contained in lazy values. The isinstance method will always
return an error, so we consider that we receive a recordset and try to
access the `_name` and `_ids`. If an error is triggered, it was not a
recordset.
This way of doing it involves little change in performance (improvement
when it is good and decrease when there is an error) because we do not
test if it is a recordset before comparing it.

closes odoo/odoo#89141

Signed-off-by: Rémy Voet <ryv@odoo.com>
2022-05-03 13:30:49 +02:00
Samuel Degueldre 8603d13d19 [FIX] web, test_assetsbundle: make useAssets work in owl 2
Previously, the useAssets hook would load the templates from the given
bundles into the qweb instance that was in the environment. In owl 2,
qweb is no longer in the environment, and templates need to be loaded in
the app.

This commit fixes that by exporting a function to load templates in the
main app from assets.js, when the main app is created, it should be
written on the function in a similar vein to renderToString, so that all
further calls to the function will load the templates in that app.

This commit also adds an actual lazy-loading test in the
test_assetsbundle module, as we don't want to pollute the manifest of
web with bundles that only exist for one specific test.

closes odoo/odoo#90122

Related: odoo/enterprise#26776
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-05-03 11:20:52 +02:00
Denis Ledoux 6c3ae09d7f [FIX] base: res.users, include self readable/writable fields in fields_get
The user profile view is loaded using sudo
https://github.com/odoo/odoo/blob/183b021b2f01595caee7fa672cc5f212a9e63075/addons/hr/models/res_users.py#L172-L185
Therefore, there are in the view field nodes which are restricted to some groups,
the user might not belong to.
These fields need to be in the result of the `fields_get` in order for
the web client to be aware of them.

```
/web/static/src/legacy/legacy_load_views.js:75
Uncaught Promise > models[resModel][fieldName] is undefined
```

This issue happens since odoo/odoo#87522
with which the fields are no longer returned in `fields_view_get`,
renamed `get_view`.

The behavior before this revision was weird:
When calling `load_views` on `res.users` to get the profile form view,
you had fields added in the `fields` key of the `form` view
which were not present in the `fields` list key of the main result dict,
which is supposed to have all the fields of the model.
e.g.:
```
{
    'fields': {
    	...
        # address_home_id not there
    },
    'views_fields': {
        'form': {
            'arch': ...,
            'fields': {
		...
                'address_home_id': ....
                ...
            }
        }
    },
}
```

closes odoo/odoo#90331

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-05-03 03:57:21 +02:00
Denis Ledoux 7c9a28d9c4 [IMP] base: specify fields to fields_get in view postprocessing
Thanks to
- odoo/odoo#87522
- odoo/odoo#87273

It's possible to speed-up the postprocessing of views
by only requesting a few attributes to `fields_get`,
therefore avoiding to load other costly attributes
(e.g. string, help, selection translations)

Before:
```
In [1]: %time for i in range(10000): env["res.partner"].get_views([(False, 'kanban'), (False, 'tree'), (False, 'form')]);env["base"].invalidate_cache()
r"CPU times: user 9min 19s, sys: 10.9 s, total: 9min 30s
Wall time: 10min 53s
```

After:
```
%time for i in range(10000): env["res.partner"].get_views([(False, 'kanban'), (False, 'tree'), (False, 'form')]);env["base"].invalidate_cache()
CPU times: user 6min 39s, sys: 11.5 s, total: 6min 50s
Wall time: 8min 14s
```

closes odoo/odoo#90168

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-04-30 10:47:53 +02:00
Martin Trigaux 2617b3f072 [FIX] base: include model_terms in check
Translations of type model_terms are similar to model and the access
rights can be checked on the referenced record instead of
ir.translation

closes odoo/odoo#90101

X-original-commit: 992a919d09c3ba224a64241f4a6c16c1a086eb4b
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-04-29 13:13:00 +02:00
Denis Ledoux b9feebc25c [REF] models, fields: refactor fields_get
- Filter in attributes rather than filter out.
  The goal is to not gather attributes which are
  costly in term of performance if they are not requested
  in the first place.
  e.g., with all modules installed:
  - Before rev:
    ```py
       In [1]: %time for _i in range(1000): self.env["res.partner"].fields_get(attributes=['readonly', 'required', 'states', 'invisible']);self.invalidate_cache()
        CPU times: user 1.99 s, sys: 9.83 ms, total: 2 s
        Wall time: 2.03 s
    ```
  - After rev:
    ```py
        In [2]: %time for _i in range(1000): self.env["res.partner"].fields_get(attributes=['readonly', 'required', 'states', 'invisible']);self.invalidate_cache()
        CPU times: user 345 ms, sys: 0 ns, total: 345 ms
        Wall time: 345 ms
    ```

- Use the `_description_` mechanism for the attributes `name` and `type`,
  so its no longer needed to treat them as exception in
  `field_get` and `get_description` respectively,
  and make the code shorter and cleaner.

- Move out from `fields_get` the block
  ```py
      has_access = functools.partial(self.check_access_rights, raise_exception=False)
      readonly = not (has_access('write') or has_access('create'))
      ...
      if readonly:
         description['readonly'] = True
         description['states'] = {}
  ```
  because:
  - It meant you had a different behavior using `fields_get` or `get_description`
    for the keys `readonly` and `states`, meaning a field could be marked as `readonly`
    by `fields_get` but not by `get_description`, which is confusing.
  - It is actually used in only one place, the post-process of back-end views,
    which mark the fields readonly for the web client if you do not have
    the create or write access to their model.

closes odoo/odoo#87273

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-04-29 13:12:49 +02:00
Ipsita Borisagar 1e4ddef514 [IMP] hr(_timesheet)_attendance: improvements for the ui
PURPOSE

Generic improvements for services.

SPECIFICATION

- For all reporting menus: removed the group by in the search view, and kept grouping
  the grid, pivot and graph views by the corresponding field.
- For timesheet/attendance, switched the pivot and graph views from their places.
- Renamed 'billable type' into 'billing type'.

task-2766164

closes odoo/odoo#85726

Related: odoo/enterprise#24940
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-04-29 11:01:07 +02:00
Laurent Smet bbc2128ba1 [FIX] base: Blacklist invoice specific reports in generic test
Some reports are specific to invoices and are raising an UserError if called without the correct business objects.
Since version 13.0, invoices have been merged into `account.move`.
The test is making a `search` on `account.move` to test the report generation but there is no guarantee there are invoices.
To prevent random failures in the futur, this commit allows custom domain to get the records in order to test these reports correctly.

closes odoo/odoo#85150

Task: 2726507
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2022-04-29 11:00:56 +02:00
Laurent Smet 7c4e591d58 [REF] base,account: Refactor PDF generation to allow CH QR-bills
For the Switzerland localization, we need to append some extra pages during the PDF generation such as QR barcodes or ISR payment slip.
There were multiple difficulties with the current codes:
- The ir.attachment was generated before the hook allowing to append the extra pages.
- There is no existing hook allowing to get the pages for each invoice when printing on multiple records at once.

This commit aims to dispatch the generation of PDFs from the creating of extra attachments:
- `_render_qweb_pdf_prepare_streams` is called first and creates a stream for each record containing the PDF pages.
- Then, the ir.attachment are generated if necessary.
- Finally, all streams are aggregated together to get the final PDF.

Task: 2726507
Part-of: odoo/odoo#85150
2022-04-29 11:00:56 +02:00
Aaron Bohy f573e93bb2 [REF] web,mail: adapt code to new load_views API
Part-of: odoo/odoo#87522
2022-04-29 09:57:44 +02:00
Denis Ledoux b03c227e88 [REF] models: refactor fields_view_get, load_views
Refactor the `load_views` API so it no longer sends multiple times the same
fields description.

e.g.
When `load_views` is called to get the kanban, tree and form views,
the list of fields of the model was sent 4 times:
- Once for each view, with only the fields used in the view,
  in `['fields_views']['kanban']['fields']` for instance
- Once globally, with all the fields of the model, in `['fields']`

The goal of this revision is to change that so it sends the list of all fields
only once.

In addition, if a view contains x2many fields,
the fields description of the comodel is also sent.
It was sent in the `views` key of the view fields dict.
e.g.
When calling `load_views` of `res.partner` to get the kanban,
tree and form views,
the `res.partner` fields description was actually sent 6 times:
- Once for each view
- Once globally
- Once for each view of the many2many field `child_ids` of the form view, in
  - `['fields_views']['form']['fields']['child_ids']['views']['kanban']['fields']`
  - `['fields_views']['form']['fields']['child_ids']['views']['form']['fields']`

The change suggested in this revision is to:
- Remove the fields description for each view in `['fields_views']`.
  As it no longer contains the fields,
  the key becomes `['views']` instead of `['fields_views']`.
- Replace the dict key `['fields']` by `['models']`,
  which is a dict with as key the model name and as values
  the model fields description. It contains the fields description
  for all models implied in the view:
  the model of the main view and the model of all one2many and many2many fields.

With this change, the fields description will only be sent once by model
implied in the view.

In addition, the web client was getting the information about the fields
sometimes in the global fields description list (e.g. `['fields']`),
sometimes in the fields description list of the view type
(e.g. `['fields_views']['form']['fields']`),
making it a pain to try to make changes / performance gain
in these field description dictionaries, because you never knew in which dict
the web client was getting its info.
Now, as there is only one place to get the fields description from,
it's clearer and cleaner.

- one2many and many2many fields views are passed directly in the main view
  architecture rather than being put in the `views` key
  of the field description.
  This is actually easier to treat by the web client,
  and this will allow in a future work to cache an entire view in one block
  of text rather than having to combine multiple cached blocks of text
  to return one view.
- one2many and many2many fields which do not have directly embedded views
  have their views directly injected in the architecture,
  so the web client doesn't have to do RPC calls to `load_views`
  for each one2many and many2many fields not having embedded views.
  For instance, this allow to reduce the number of RPC calls to `load_views`
  from 8 to 1 when loading the form of `product.product`.
  Currently, this behavior is limited to 1 level deep but we consider making it
  go all the way down in future works. We did not do it for the moment because
  in certain cases it rises the processing time and the size (bytes) too much.
  e.g. the sale.order view can be 5 levels deep,
  meaning you can reach 4 dialogs on top the main view.
  ```
  sale.order form > order_line > sale.order.line form > invoice_lines >
  account.move.line form > asset_ids > account.asset form >
  depreciation_move_ids > account.move form.
  ```
  This will also benefit in future works to cache an entire view in one block
  of text rather to having to combine multiple cached block of text
  to get one view.
- `fields_view_get` becomes `get_view`.
  As it no longer returns the fields description,
  keeping the `fields` in the name `fields_view_get` no longer makes sense.
  Hence removing `fields` from the method name, it becomes `view_get`.
  As it gets renamed anyway, we take the opportunity to rename it `get_view`,
  which is more in line with the general getter/setter guidelines
  in the model object world.
- `_fields_view_get` becomes `_get_view`. For the same reasons than above.
- `load_views` becomes `get_views`.
  This is not mandatory, there is no technical reason to rename `load_views` as
  it practically sends the same info as before,
  the view architectures and their fields description. Just in another way.
  We just take the opportunity of this pull request to suggest a cleaner API:
  `_get_view`, `get_view` and `get_views`.
- Arguments `toolbar=False, submenu=False` fo the methods
  `_fields_view_get` and `fields_view_get` are converted to a kwargs `**options`
  in `_get_view` and `get_view`.
  The rationale is that submenu was already no longer used (deprecated)
  and the mobile options is introduced.
  The mobile options is necessary to tell the server to send the mobile views
  for x2many fields (kanban instead of tree).
  Instead of adding a new argument each time we add a new option to
  `fields_view_get`, it seems wiser to have a kwargs `**options` to avoid
  to re-write all overrides each time a new option is introduced.
- `_fields_view_get` returned a dict containing the arch in text and some of the
  view information. Now, `get_view` returns a tuple with the view architecture
  as an `etree` node, and the view as a browse record. The rationale is that all
  overrides of `_fields_view_get` were about modifying the arch only
  (e.g. changing the address format/re-organizing the address related field
  nodes of the partner according to the company country).
  To do so, all these overrides were doing `etree.fromstring` to parse the arch
  which was sent in text to convert it to an `etree`,
  then operations were done on the `etree`,
  and then `etree.tostring` was called to convert back the arch to string.
  With this change of signature to send the arch as an `etree`,
  all these back and forth `etree.fromstring` -> `etree.tostring` are avoided,
  allowing some performance gain and less code in the end.
- A cleanup of the keys returned in the dict of `fields_view_get`
  has been performed in `get_view`:
  - `fields` is removed, as explained above,
  - `view_id` is renamed `id`,
  - `name` is removed, it was unused by the web client,
  - `type` is removed, it was unused by the web client,
  - `field_parent` is removed, it was unused by the web client,
  - `base_model` is removed, it was unused by the web client.
- `filters` is moved from the global dict returned by `load_views`
  (now `get_views`) to the dict returned by `fields_view_get` (now `get_view`)
  as it applies only to the `search` view type.
- Retro-compatible methods for the 3 methods
  `fields_view_get`, `_fields_view_get` and `load_views` are provided,
  with deprecation warnings in them.

- The web client could cache the model fields description
  (as it already caches the views),
  so it doesn't need to fetch them again if it asks for another view of a model
  for which he already has the fields description.
  If we do so, `get_views` could return only the list of models used by
  the views, without the fields description as of now,
  and the web client would then call `fields_get` independently only for
  the models for which it doesn't have yet the fields description.
  This would avoid the server to return the fields description
  and to call `fields_get`, which is costly, for each `get_views`,
  therefore gaining performances.
- Inject the views of the one2many and many2many fields all the way down,
  unlimited depth level, as explained above.
- Cache with `ormcache` the architecture of back-end views.
  This is already done for qweb views, it's not done for back-end views.
  Therefore the postprocessing of the views is performed for each `get_views`,
  which is costly, while the view architecture doesn't change for users
  belonging to the same groups, according to the groups implied by the view.

This pull request is co-authored by
Aaron Bohy (aab) for the web client part and
Denis Ledoux (dle) for the server part.

Part-of: odoo/odoo#87522
2022-04-29 09:57:44 +02:00
Denis Vermylen ea913dd39d [FIX] server: close psql connections on shutdown
Stopping a threaded odoo server would spam the postgresql logs with
multiple:

<...> LOG:  could not receive data from client: Connection reset by peer

Let's avoid being rude and not hang up on postgresql connections
unexpectedly.

closes odoo/odoo#89955

X-original-commit: d0da17b167edee82381b6add573742e1cf663a9c
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-04-28 09:59:56 +02:00
Julien Castiaux 034d01b2f3 [IMP] core: send json to http controllers
With this work we relax the http controller so that it accepts all
requests, including `Content-Type: application/json`. We also enrich
the framework with two new helper methods dedicated to serialaze json
requests and responses:

- `request.get_json_body()`, loads the json content from the request's
  body and returns the corresponding python object (usually a dict).
- `request.make_json_response(data)`, dumps `data` to json and makes an
  http response out of it.

closes odoo/odoo#86300

Task: 2779837
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-04-27 20:35:55 +02:00
Abdelouahab (abla) 873b7b8a82 [FIX] l10n_ch : fix body style in swissqr_report
To reproduce
============

- Create a company with a complete Swiss address (street, city, zip and country).
- Install the l10n_ch modules and install the Swiss plan comptable in the Settings of the Accounting app.
- Go to Accounting > Configuration > Settings > Activate the "QR codes" > Save
- Go to Accounting > Configuration > Journals > Choose the journal for the invoices > In "Advanced settings" verify that the communication type is "Based on invoice" and the communication standard is "Switzerland"
- Go to Accounting > Configuration > Journals > Select your bank journal(s) > Verify that you have set up your bank account number and the name of the bank
- Go to the Contact app > Configuration > Bank Accounts > Choose the one you use for the QR-bills > Edit > In "ISR Client Identification Number" refer a client number and make sure account type is 'IBAN' > Save.
- Verify that you have a complete address on the contact form of the customer (street, city, zip and country).
- create multiple invoices for this client
- try to print QR-bill for these invoices at once -> and assert error is raised

Purpose
=======

the `assert len(outlines_pages) == len(res_ids)` fails because the generated pdf
contains only a single invoice.

this issue is caused by the line `<script>document.body.className += " l10n_ch_qr";</script>` in `swissqr_report.xml`,
when `wkhtmltopdf` generates the pdf from html, it doesn't wait for all javascript to finish before rendering the page,
which lead to not execute the script `<script>document.body.className += " l10n_ch_qr";</script>` for some pages then the final pdf
is missing some pages.

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

To solve the issue we removed the javascript block `<script>document.body.className += " l10n_ch_qr";</script>` from the template
and move it to python, by setting the body style when generating the html.

opw-2772396

closes odoo/odoo#89835

X-original-commit: a669b4c5f78aa18b87f5adcfc5acca3ce0a76040
Signed-off-by: abla001 <abla@odoo.com>
2022-04-27 18:38:10 +02:00
William Braeckman 7e945db634 [FIX] website,website_sale: fix user sign up config
This commit aims to fix multiple issues with the "Customer Account"
parameter in the backend config.

 - Hide the parameter from general and sales settings if website is
   installed.
 - Properly compute the right value once website is installed, as it was
   not using the website's value.
 - Fix a traceback when clicking on "Default Access Rights".

TaskId-2825096

closes odoo/odoo#89806

X-original-commit: 8b162f507f881619061d61530cc03b4b4654c1fe
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2022-04-27 12:16:28 +02:00
William Braeckman 8ea9ce1ed8 [FIX] base: allow proper override of config_parameter
Prior to this commit there was no way for a `res.config.settings` field
using a `config_parameter` and remove the `config_parameter` aspect.
After this commit, the parameter is ignored if it is falsy.

TaskId-2825096

X-original-commit: b0b62ee3e302b1a1d08d1c8a32bf297380a4f27b
Part-of: odoo/odoo#89806
2022-04-27 12:16:28 +02:00
MAHAMADASIF ANSARI f00c443350 [IMP] base: update industry list
In the current version, some industries are named things like `Administrative`,
`Food`, and `Transportation`, and do not have the proper space and dash after
the first alphabet in full name.

This commit renames the above industries to `Administrative/Utilities`,
`Food/Hospitality`, and `Transportation/Logistics` respectively, and also adds
 space after comma and semicolon according to 'NACE' rules, and also adds a dash
 after the first alphabet in the full name.

task-2674365

closes odoo/odoo#88555

Related: odoo/upgrade#3442
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-04-27 10:03:57 +02:00
Habib (ayh) 948ce9a1f5 [FIX] core, base_address_extended: manage special characters in street_split
A traceback is caused when migrating/upgrading certain databases. It seems to be caused by special characters in the `street` field.
When there are `newline` characters the regex match function returns None.
This fix improves the REGEX with DOTALL mode (view newline characters with `.` expression) and also checks if the Regular Expression match function succeeds OR provides a fallback otherwise.

Add tests to base_address_extended - tests for `street_split` are enhanced to include problem case

closes odoo/odoo#89727

X-original-commit: 6f72b8f8c2a0080a67c62b40aa4f6d8f3427b16c
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Ayob Habib (ayh) <ayh@odoo.com>
2022-04-27 07:52:06 +02:00
Victor Feyens 7828fab39c [REM] core: unused import
Part-of: odoo/odoo#86332
2022-04-27 07:51:24 +02:00
Victor Feyens 862ad88bc4 [FIX] test_inherit: Bad first argument given to super() (E1003)
Part-of: odoo/odoo#86332
2022-04-27 07:51:23 +02:00
Victor Feyens 24f9af3fd0 [IMP] *: remove Trailing newlines (C0305)
Part-of: odoo/odoo#86332
2022-04-27 07:51:23 +02:00
Victor Feyens 3a43ba3ee0 [FIX] core: Method should have "self" as first argument (E0213)
Part-of: odoo/odoo#86332
2022-04-27 07:51:23 +02:00
Victor Feyens dcc71b984e [FIX] test_converter: unused format argument (W1304)
Part-of: odoo/odoo#86332
2022-04-27 07:51:22 +02:00
Victor Feyens 43ddbec741 [FIX] core: Too many arguments for logging format string (E1205)
Part-of: odoo/odoo#86332
2022-04-27 07:51:22 +02:00
Martin Trigaux 158b537c28 [I18N] *: export saas-15.2 source terms
closes odoo/odoo#89225

X-original-commit: 5925a83d87fa4702f4c0f22346304dc2da47c728
Related: odoo/enterprise#26435
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-04-23 08:33:43 +02:00
Dejanae Benton c336dddab8 [IMP] release: correct typo in code comment
Fixes odoo/odoo#88866

closes odoo/odoo#89454

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-04-22 18:08:59 +02:00
Yolann Sabaux 7c0e93c7c1 [FIX] ir_actions: home action restriction
Steps to reproduce:
- define a home action for the user
- delete the action in configuration > Window Action
- refresh to the home page
-> id not found

Solution:
- prevent the deletion of a window action if used as a home action

OPW-2728824

closes odoo/odoo#89420

X-original-commit: b868583690d8560d3cc300b9448f0af32f41d81a
Signed-off-by: yosa-odoo <yosa@odoo.com>
2022-04-22 14:14:04 +02:00
nda-odoo c7d54d9ef1 [FIX] base: performance of has_group()
Avoid calling with_user() inside method has_group() when possible, as it
represents a major overhead inside this method which is commonly called. This
sole optimization speeds up the accounting general ledger by about 6%.

closes odoo/odoo#89206

X-original-commit: e858507aaf01c3701bf5642978490d7947acf35d
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-04-22 12:04:27 +02:00
Tom De Caluwé 7b1ffd6315 [FIX] website, base: allow modify_image calls on svg for designers
SVG images are considered an xml like format, as a consequence restrictions
apply for manipulating svg type attachments. This poses a problem when a
website designer tries to save a page containing images with svg shapes. This
commit allows writing attachments with an xml like mimetype to anyone with
write access rights on views.

opw-2806930

closes odoo/odoo#89185

X-original-commit: d5aa54ca108eb99c7eb855a7d456bfe2f208a8eb
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-04-21 11:33:56 +02:00
Aurélien (avd) d10e32e141 [REV] expression: revert performance search one2many commit
Revert commit 54cd73a4f4 as it prevents customers from closing
their pos sessions without timeouting.

closes odoo/odoo#88941

X-original-commit: 43165dc3f7a8cc199219b8a32b65eb0ee7b5c2dd
Signed-off-by: Julien Castiaux <juc@odoo.com>
Signed-off-by: Olivier Dony <odo@odoo.com>
2022-04-15 19:08:42 +02:00
Artem e6ec113896 [FIX] base: use current company when rendering report
Fixes odoo/odoo#86216
When printing qweb report use the current company.
For example, the company logo printed was always from user company
default instead of the current company.

closes odoo/odoo#86356

X-original-commit: becdd7d54a5dd7dc50ca1458951f98f95b011d56
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-04-12 16:49:57 +02:00
Raphael Collet 857ef8f5fd [FIX] core: field display_name should be "" instead of False
This is a followup of #86567, where we change the computation of
display_name to match the values of name_get().  Forcing its value to
False instead of the empty string causes many regressions in frontend
applications like website_blog.

closes odoo/odoo#88438

X-original-commit: d467881f66b11021005005584854f30059971b6c
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-04-11 16:02:17 +02:00
Christophe Monniez 082aa4d352 [IMP] core: bump master release to 15.4 alpha
closes odoo/odoo#88424

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-04-11 12:32:21 +02:00
Odoo's Mergebot b11b05b714 [MERGE] sale_subscription: Merge sale.subscription into sale.order
Purpose
=======

Migrate subscription to sales order to simplify the code, the UX & make it more flexible for the future and easier to maintain.
Subscription still appears as a separate module.

This PR aims to move the sale.subscription models to sale.order. The implementation is quite similar to the sale_renting module.

Before this PR, sale.subscription records are similar to sale.order ones. A lot of logic is duplicated to handle the subscription line computations, tax handling, etc.
The current implementation of subscription has several drawbacks:
* the sale.subscription records depends on required sale order template.
* it is not possible to mix different periodicity in a subscription. Each partner has as many contract as periodicity  needed (monthly, yearly etc)
* when the flow starts in sale_management, the first invoice must be created from the sale application.
* upsell prorata calculation to apply a discount is flawed when the salesman want to apply another discount.

This PR fixes these issues and make subscription more flexible. One record can have subscription lines with different periodicity. Each line have a next_invoice_date and invoices are generated when they are due with the matching lines.

Before this commit, the sale module could not be used to manage subscriptions in an override.
This commit adapts the sale module to odoo/enterprise#21825

closes odoo/odoo#82632

Taskid: 2568007
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-04-07 15:19:59 +02:00
Michael Tietz 6e96a41cc8 [FIX] core: make one2many empty search use EXIST
This speeds update the peformance of searching empty one2many fields

closes odoo/odoo#88176

X-original-commit: a7679d246ae43bf81fd8b279008b57dbdc1bba05
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-04-07 13:24:13 +02:00