Commit Graph
6600 Commits
Author SHA1 Message Date
Yannick Tivisse e79b1a79bc [IMP] base: Garbage collect ir.cron.triggers
Part-of: odoo/odoo#114656
2023-03-13 13:13:49 +01:00
Yannick Tivisse 9aa04f18d9 [FIX] base: Make user apikeys ondelete cascade on user_id
This could prevent the user deletion if linked to a record of this
type, like a auth_totp.device which inherits from this model.

Part-of: odoo/odoo#114656
2023-03-13 13:13:48 +01:00
Yannick Tivisse d8c9c8d10b [FIX] base: Handle portal user deletion separately
Purpose
=======

Improve the portal user deletion by preventing timeouts and
avoiding several rollbacks causes.

Specifications
==============

- Move the portal users deletions from autovacuum to its own cron.
  On big databases such as odoo.com, deleting a res.users takes
  more than 1 minute. Move the whole process into its own scheduled
  tasks.
- Commit the deletion at each user. As said previously the deletion
  can be expensive, so commit what has been done to avoid having to
  delete the same user again in case of rollbacks or timeout.
- Delete the user and the partner separately. If the partner is used
  in a sales order for instance, the unlink is possible for the user
  and not the parner. It allows to unlink the user and keep the
  partner in case it cannot be deleted.
- Re-call the cron into another transaction in case there are too many
  users to delete, instead of waiting next call, that is supposed
  to occur the day after.

Taskid: 3222941
Part-of: odoo/odoo#114656
2023-03-13 13:13:47 +01:00
Petar Najman fd5a082984 [FIX] base: Invalid flag image url computed for Serbian lang sr@latin
When computing flag_image_url field on res.lang model an invalid url is generated due to the peculiar format for serbian lang code sr@latin which has "@" sign instead of expected "_" sign and thus the unexisting url is computed, so we are forced to populate binary field flag_image instead.

X-original-commit: 85db3773ba475a143a99126c6c24b404bdd39d0b
Part-of: odoo/odoo#114565
2023-03-13 10:53:00 +01:00
bve-odoo 708f5997c5 [FIX] core: recycle more connections in multi-tenant servers
During revision 415525cecc
the code comparing the connections without password has been
dropped, for an unknown reason.

Because of the above, and the fact psycopg2 alter the password
with 'xxx' for security reasons, the connections recycling was
no longer working as expected, and was recycling less connections.

closes odoo/odoo#37005

Signed-off-by: Rémy Voet <ryv@odoo.com>
2023-02-20 12:19:19 +01:00
Gorash 113d3d5b19 [FIX] base: display white-space before the t-if when display a content
Issue: when use t-if to display text and use mutli line, the white-space
are removed.
```
<div>
    <t t-out="nb"/>
    <t t-if="nb == 0 or nb == 1">product</t>
    <t t-else="">products</t>
</div>
```
is rendered:
```
<div>
    3products
</div>
```

closes odoo/odoo#114986

X-original-commit: 3150a3769ff4d762c0e52dab31a70b59292c1bcc
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-03-10 18:55:17 +01:00
flvr-odoo 9fe7c94c06 [FIX] mail: check translation
This commit adds a check to prevent saving a translation in a language that was not installed.

Upon adding a translation, the field "language" in the request was not checker,
allowing to add translation for language (or any strings as key) for a given field

This is not ideal and we want to prevent that, it can bloat the database for no reason.

opw-3208305

closes odoo/odoo#114793

X-original-commit: 89cd5ce88a0c666e811410e264e3cb474f9851c0
Signed-off-by: Vranckx Florian (flvr) <flvr@odoo.com>
2023-03-09 15:55:10 +01:00
Rémy Voet (ryv) 9b7c372602 [IMP] core: avoid queries when creating records with one2many values
When we create a new record X and its values contains an one2many field
with either a recordset Y or a Command.set(ids), the ORM generates extra
SQL queries to search and remove the existing lines of the new record.
The call chain is as follows:

    Model._create
        -> _RelationalMulti.create
            -> _RelationalMulti.write_batch
                -> One2many.write_real

But because record X is brand new, it has no lines to begin with.  The
fix consists in skipping the search and removal in that case.

Also remove any nondeterministic behavior of method write_real() using
an OrderedSet instead of a builtin set.

closes odoo/odoo#114726

X-original-commit: 428827e5213ee002a5b50d864f8ce1f24d1842b3
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-03-09 15:54:53 +01:00
thsh-odoo e651c2b3aa [IMP] base: added mobile field as optional field in tree view
Before commit:

There was no mobile field in the optional fields of tree view in res.partner.

After commit:

Added the mobile field as optional field.

Task-3184771

closes odoo/odoo#113243

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-03-09 10:51:40 +01:00
Rémy Voet (ryv) 45115cb9c2 [IMP] core: add a representation of a TriggerTree
The TriggerTree class does not have a specific __repr__().  It thus
falls back on dict's __repr__(), which does not show the root of the
tree.  This makes debugging hard and confusing.

closes odoo/odoo#113521

Signed-off-by: Raphael Collet <rco@odoo.com>
2023-03-08 22:29:51 +01:00
Rémy Voet (ryv) f5503bf295 [REM] core: remove useless/inefficient flush_all in unlink
Doing a `flush_all` at the end of `unlink` is useless and can generate
extra queries for no reason. Remove it.

Part-of: odoo/odoo#113521
2023-03-08 22:29:51 +01:00
Victor Feyens 24ccf7d9b0 [CLN] *: useless type info for actions
The type fields of actions already defaults to
the model name in the base model definition.

Therefore, specifying `ir.actions.server`, `ir.actions.act_window`
& so on as type is useless (and adds noise since it's the same as
the action model).

closes odoo/odoo#114539

Related: odoo/enterprise#37855
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-03-08 17:33:37 +01:00
Xavier Morel eb5515bee9 [ADD] core: support for binding IPv6 in worker mode
Because Werkzeug supports ipv6 natively (and has since ~2010
pallets/werkzeug@13a76262a4), running
Odoo in threaded mode allows binding to an ipv6 address.

However the prefork server is part of Odoo, and only creates
AF_INET (ipv4) sockets. Thus switching from threaded to worker mode
breaks the bind.

Add a family switch on the `http-interface`, so binding to ipv6
addresses also works in ipv6. Gevent already does that switching
internally, so the evented worker works out of the box, it was only
the prefork / workers which did not.

Looking at both the Werkzeug and Gevent implementations:

- https://github.com/pallets/werkzeug/blob/f9906fa6d83dd668f9214acef458419756bbc062/src/werkzeug/serving.py#L607-L614
- https://github.com/gevent/gevent/blob/1e412d35526183b26c1abf2eb658cbef661f5f70/src/gevent/baseserver.py#L415-L433

Both primarily check whether the host contains `:`. Werkzeug also
checks if `socket.AF_INET6` exists, however gevent doesn't bother with
that. Looking at the
source (https://github.com/python/cpython/blob/7d801f245e2021d19daff105ce722f22aa844391/Modules/socketmodule.c#L7419-L7421),
it is indeed possible for `AF_INET6` to be missing, however that
requires specifically compiling Python in an environment which doesn't
support IPv6.

Meanwhile it's also possible to disable ipv6 at runtime, in which case
I'd assume the `socket.AF_INET6` constant is present, and creating the
socket fails, which nobody guards against. Therefore just ignore the
entire thing, it doesn't seem worth the hassle (or the questioning) to
check whether the constant is present, especially since this is only a
concern when the user specifically requires an IPv6 address.

Fixes #35782

closes odoo/odoo#114666

Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-03-08 13:49:05 +01:00
Raphael Collet be278780f7 [FIX] core: first onchange when adding a line in a one2many field
Consider a form view with a one2many field, which has no form subview.
Also the form view of the comodel (the one2many field's lines) contains
the inverse many2one field of the one2many field.  When adding a new
line on some existing record, the form view shows the many2one field as
empty, instead of being the main record.

Explanation: the form view of the line invokes onchange() with the main
record's values (dict) as the value of the many2one field.  Inside
onchange(), the field is actually set to a new record corresponding to
the main record.  Alas, when that value is sent back to the form, the
new record is serialized as False.

Solution: let onchange() serialize the new record as its origin record
instead.

closes odoo/odoo#114648

X-original-commit: d137ea4915da8d46909fcb082b5a88fd347874a4
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-03-08 11:37:10 +01:00
Nicolas (vin) 9461d2d52b [FIX] base: disable same vat warning when using single-char vat
In order to ease the process of setting vats for some users, it was
decided to allow to use a vat number of a single character ('/' for
example) without checking it. This allows to differentiate between
partners for which we did not set VAT yet, and partners exempted from
VAT/without a number.

The VAT check was recently adapted to handle this use case, but the
"same vat" warning was forgotten in the process.

This additional change will disable the "same vat" warning that appears
when two partners share the same VAT number if that vat number is
only a single character, aligning the behavior of the warning to the
changes done in the vat check itself.

closes odoo/odoo#114640

X-original-commit: 4d80d30d0db6993a2fbbab59b935abe07080074b
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
2023-03-08 10:31:18 +01:00
Xavier-Do 8049b78a03 [IMP] tests: detect if any patcher was forgotten
closes odoo/odoo#109886

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2023-03-08 10:31:04 +01:00
Laurent Desausoi d38268040f [FIX] base: decode wkhtmltopdf errors
In some cases, wkhtmltopdf might exit with an error (e.g.: a memory
limit). In such cases, we want to show to the user the error returned by
wkhtmltopdf. Previously, this message was only displayed in binary
format (displayed as "Message: b'My error\n'") which is not user-friendly.
We want this message to be decoded so that it is a bare string
(displayed as "Message: My error").

closes odoo/odoo#114609

X-original-commit: 5fc49f8bb24a328e7b735847795bd8e78229cbfb
Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
Signed-off-by: Desausoi Laurent (lade) <lade@odoo.com>
2023-03-07 19:04:27 +01:00
Raphael Collet 501b7e37d5 [IMP] core: doc of search_count() and fetch()
closes odoo/odoo#114551

Related: odoo/documentation#3749
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-03-07 18:03:16 +01:00
niyasraphy e83ad17d51 [IMP] core: remove non existing modules from test
document_ftp, website_instantclick, pad, pad_project, note_pad, pos_cache is not currently existing in the addons, removing the non existing modules from the BLACKLIST dictionary.

closes odoo/odoo#107213

Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-03-07 18:02:28 +01:00
Yolann Sabaux afe6f967cd [FIX] base: make country code required
Steps to reproduce:
- Go to Contact-Configuration-Countries
- Remove the code of a country
- Create a new contact
- Select the country from which you deleted the code
- Put any vat number starting with country code you deleted

Issue:
Traceback

Cause:
in `_run_vat_test` we want to `country.code.lower()` -> country code does not exist

Solution:
Prevent the user to delete a country code by making the field required.

sentry-3923412146

closes odoo/odoo#113207

Signed-off-by: William André (wan) <wan@odoo.com>
2023-03-07 11:11:42 +01:00
Walid HANNICHE (waha) 7b71480c19 [FIX] base: wkhtml2pdf large documents load
Step to reproduce:

    Edit documents layout in general setting to add logo and background
    select multiple documents (more than 5) e.g. Inventory> delivery slips
    print all documents.

Bug:
background and logo missing on the last documents because the pages
were printed before the browser had time to render them

Fix:
wkhtml2pdf has a default delay of 200 ms (--javascript-delay)
increasing the value will allow large document to load

opw-2951594

closes odoo/odoo#114512

X-original-commit: ac2df93eb3f08696189d010bdfa4187e02a94576
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
2023-03-07 03:53:49 +01:00
Nasreddin Boulif (bon) 8e299fb2ee [FIX] base: fix partner merge wizard
Steps to reproduce:

  - Install `Contacts` module
  - Create 3 contacts with the same name
  - Archive one of the contacts
  - Go to list view
  - Edit search filter to display archived and non archived contacts
  - Select the 3 created contacts
  - Open `Action` menu and click on `Merge`

Issues:

  - Archived partner is set by default as destination partner.
  - Archived partner is not displayed in the list of partners to merge.

Cause:

  - The default destination partner set is the last record of the record
    set returned by `_get_ordered_partner` (where `Archived` partners
    are the last ones in the record set).
  - The field `partner_ids` does not allow archived records.

Solution:

  - Sort the partners to have the archived ones on top (since we took
    the last one).
  - Set `active_test` to False in the context of the partner_ids field.

opw-3205577

closes odoo/odoo#114508

X-original-commit: 8d0cec6844b248d3787bd7d6b8868d930d25e38c
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
2023-03-07 02:57:02 +01:00
Nicolas (vin) c25341ed0c [IMP] account: payment scamming protection
Odoo does not have much in terms of payment protection; you can create
payments to any account you want without many checks.

This changes it by requiring users with the right groups to trust an
account before allowing it to be used for payment methods requiring.
Also adds some warnings on the bank account view, and checks at the time
of creating a payment.

Task id # 3210415

closes odoo/odoo#114278

Related: odoo/enterprise#37789
Related: odoo/documentation#3737
Related: odoo/upgrade#4397
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
2023-03-07 01:59:51 +01:00
Denis Ledoux 2541cf636b [REM] core: remove search_view from ir.actions
This field has been introduced in
https://github.com/odoo/odoo/commit/c68600cc5397700df4f40095c27723a2b1f90a22

The reason why is not really clear, given the commit message.

But, it looks completely unused nowadays.
We can therefore safely remove it.

In addition, this will save a lot of transferred data to the web client,
as currently all the fields of an action are read when the web client
loads an action,
including this one, which contains a long xml content.

For instance, with just base and the contacts modules installed,
to load the action of the Contacts menu,
it goes from 5.51kB to 1.05kB.

closes odoo/odoo#114041

Related: odoo/upgrade#4390
Signed-off-by: Rémy Voet <ryv@odoo.com>
2023-03-07 01:59:38 +01:00
std-odoo 1c2f29fc56 [IMP] base: allow to order record by properties fields values
Purpose
=======
Allow to sort records by properties fields values.

Task-2980121

Part-of: odoo/odoo#101901
2023-03-07 01:59:05 +01:00
std-odooandPolymorphe57 defa390621 [IMP] web: allow to search properties fields using the top search bar
Purpose
=======
Add the properties fields in the search bar and allow to search
properties fields values.

Technical
=========
If the "active_id" is in the context, show only the properties
of the given definition record. Otherwise, show all properties
of all definition records.

Because fetching the properties definitions cost a SQL query and a RPC
call, the properties definition are fetched only if we unfold the
properties field (so it has no performance impact until we ask
explicitly to search a property).

Task-2980121

Part-of: odoo/odoo#101901
Co-authored-by: Polymorphe57 <dam@odoo.com>
2023-03-07 01:59:05 +01:00
std-odoo 0583a5ddd0 [IMP] base: search on properties fields
Purpose
=======
Allow to search properties fields.

For now, the properties fields are meant to be used with the frontend
top bar filter on views in a later commit, and so everything as been
kept as simple as possible for that particular use case.

Technical
=========
Relational properties
---------------------
We can not search on relational properties using the rec name, or
using one of their fields.

The following domains do not work
```
[('properties.partner_id', 'ilike', 'alice')]
[('properties.partner_ids', 'ilike', 'alice')]
[('properties.user_id.name', 'ilike', 'bob')]
[('properties.user_ids.name', 'ilike', 'bob')]
```

Instead, we should give the ids
```
[('properties.partner_id', '=', 55)]
[('properties.partner_ids', 'in', 55)]
```

IN operator
-----------
The "in" operator is used to either search specific tags / many2many
values, either doing a "OR like" condition on "non-array" value.

It can be used if the left or the right side is not an array
```
[('properties.my_char', 'in', ['a', 'b'])]
[('properties.my_tags', 'in', 'a')]
```

But it can't be used if both side of the condition are array, because
it will require to check type in SQL (which is technically possible,
but add extra complexity, so for now we keep the feature as simple as
possible).

So the following domain is not supported.
```
[('properties.my_tags', 'in', ['a', 'b'])]
```

Instead we should use the "OR" operator
```
['|', ('properties.my_tags', 'in', 'a'), ('properties.my_tags', 'in', 'b')]
```

Tags / many2many - "=" operator
-------------------------------
Tags and many2many have to be searched using the "in" operator.

So the following domain will return unexpected results and raise a warning.
```
[('attributes.mytags', '=', ['a', 'b'])]
```

The reason is that we don't want to dynamically check the type in SQL,
and so we need the "in" domain operator to know what to do in SQL.

Task-2980121

Part-of: odoo/odoo#101901
2023-03-07 01:59:04 +01:00
std-odoo da48700b59 [IMP] base: do not modify the cache when reading properties fields in batch
Purpose
=======
Do not modify the cache in order to improve the performance when we
read in batch. Instead we create a new batched method "convert_to_read"
that check existence in batch, and generate a dict with the result.

Now, all the properties field checks (many2one existence, selection option
still exists, tag value stiff exist, etc) and done in "convert_to_read".

It means that doing `record.properties` won't do all those checks.

Having the batched field fetch at the convert_to_record required too
many changes for the scope of this task, so "record.properties" having
the cache values unchecked is an acceptable tradeoff currently, hence
we batch convert_to_read.

Task-2980121

Part-of: odoo/odoo#101901
2023-03-07 01:59:04 +01:00
Raphael Collet 8c81074e60 [IMP] base: optimize code with search_fetch() and fetch()
Part-of: odoo/odoo#112126
2023-03-05 15:12:56 +01:00
Raphael Collet ae31aebf09 [FIX] base: fix and optimize ir.attachment._search()
Make ir.attachment._search() consistent with method check() for access
checks.  Also make it generate less queries by combining the extra query
with the main query of _search().

Part-of: odoo/odoo#112126
2023-03-05 15:12:56 +01:00
Raphael Collet dc15044cc0 [FIX] base: visible menus is a search() feature, not a _search() feature
Part-of: odoo/odoo#112126
2023-03-05 15:12:55 +01:00
Raphael Collet 4e6f1d7805 [FIX] core: invalidate the cache of forbidden records when raising AccessError
Issue: checking access rules fetches some data in cache.  Sometimes,
accessing a forbidden record does not crash because of the data left in
cache.  This is the case when accessing a field on a record, like in the
field accessor method:

    try:
        records._fetch_field(f)     # (1)
    except AccessError:
        record._fetch_field(f)      # (2)

The field f is included in the data fetched to check access rules in the
prefetch set of record (1).  Therefore, when trying to fetch the same
field in (2), there is nothing to fetch and no access error occurs.

Part-of: odoo/odoo#112126
2023-03-05 15:12:55 +01:00
Raphael Collet e962860c6f [IMP] core: introduce search_fetch() and fetch()
This fulfills the goal of searching and fetching fields in a single SQL
query.  We introduce the new method search_fetch() for that purpose.
Also introduce method fetch() to fetch some fields for a recordset if
they are not in cache yet.

The call graph is as follows:

    search()        calls   search_fetch()
    search_read()   calls   search_fetch() and _read_format()
    read()          calls   fetch() and _read_format()

    search_count()  calls   _search()
    search_fetch()  calls   _search() and _fetch_query()
    fetch()         calls   _search() and _fetch_query()

The methods _search() and _fetch_query() are usually the ones to
override to implement business-specific logic.  The method _search()
returns a Query object to retrieve the records that satisfy the given
domain and are accessible for reading.  The method _fetch_query() uses a
Query object to retrieve fields from the database and store them in
cache.

Also use search_fetch() to save one query in search_read() and the
reading of one2many fields.

Part-of: odoo/odoo#112126
2023-03-05 15:12:55 +01:00
Raphael Collet 46c23fd64d [IMP] *: _search() always returns a Query
Goal: make _search() always return a Query object, in order to make
search_read() in a single query when possible

Adapt the overrides of _search() towards the given goal.

Part-of: odoo/odoo#112126
2023-03-05 15:12:55 +01:00
Raphael Collet c161177cb7 [IMP] core: _name_search() now takes explicit order and limit parameters
This API is much more sensible for making subqueries.  Specifically, one
can generate a subquery without the clauses LIMIT and ORDER BY.

Part-of: odoo/odoo#112126
2023-03-05 15:12:54 +01:00
Raphael Collet 136eb34f07 [IMP] core: _search() no longer uses a default order
This simplifies the use of subqueries by avoiding some costly default
order on the model or the idiotic order='id'.  Method _flush_search()
has been adapted accordingly.

Part-of: odoo/odoo#112126
2023-03-05 15:12:54 +01:00
Raphael Collet 7e6cff5479 [IMP] core: search() and _search() no longer have parameter count
The parameter in search() is redundant with method search_count(), and
was making the calls less readable.

The method _search() is aimed at always returning a Query object.  The
method can therefore never return an integer, hence the removal of the
parameter.  This does not actually remove any functionality from the
method; counting result is simply given by using it differently.

Part-of: odoo/odoo#112126
2023-03-05 15:12:54 +01:00
Raphael Collet 789c643925 [IMP] core: improve Query for subqueries
The goal is to be able to use Query objects for both subqueries and
known ids tuples.  This provides a single API for injecting either a
subquery or its resulting ids into another query.

Part-of: odoo/odoo#112126
2023-03-05 15:12:53 +01:00
Raphael Collet 537a60ffd1 [IMP] core: quote field "id" in SQL queries
Part-of: odoo/odoo#112126
2023-03-05 15:12:53 +01:00
Raphael Collet 637cdc8ffa [IMP] test_performance: more tests and adapt query counts
Part-of: odoo/odoo#112126
2023-03-05 15:12:53 +01:00
momegahed 1d54dfad33 [FIX] base: Cannot print multiple checks
Steps to reproduce:

1. Settings > Accounting > Vendor Payments > Checks > Enabled with
Print Check (Top) - US
2. Accounting / Vendors / Payments
3. Create at least 2 vendor payments using "Checks" as the payment method
4. In the list view select both payments and click action/print checks
5. Error

Bug:

in `_render_qweb_pdf_prepare_streams`, in the case of multiple
documents on multiple pages, we can only split them if the pdf has an
outline, and it will have an outline only with templates that have a
header tag. For the ones that don't have them like
`l10n_us_check_printing.print_check_top`, it is not possible with the
current logic to unambiguously split them. (maybe we can add a
heuristic like if number of pages = number of documents we can assume
1 document/page)

thus the streams returned by `_render_qweb_pdf_prepare_streams` don't
contain the record ids and
`safe_eval(report_sudo.attachment, {'object': record, 'time': time})`
might fail based on the expression to evaluate.

Fix:
It doesn't make sense to save the attachment if we can't split the
attachments clearly anyway, so we can just continue and skip the saving
 if record is null

OPW-3124089

closes odoo/odoo#113863

X-original-commit: 1fac708bd335dce27eeb77e0a11e12883a83dac6
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Mohamed Megahed Abbas Megahed SALLAM (mome) <mome@odoo.com>
2023-03-05 14:16:51 +01:00
Laurent Smet 955091e707 [IMP] account*: send&print with documents
Refactoring send&print wizard.
==============================

Main reason for this commit is that we want to let the user
decide when to generate the relevant documents / approvals
for its invoices. The natural choice is when the information
leaves Odoo. So now, each time the users decide to
download/send its invoices, he will be able to select the
relevant documents to be generated and the approvals to be
requested from the send&print wizard.

This used to happen automatically during the posting with lots
of undesirable behaviors (difficulty to update/revert, hard to
know exactly what will happen,...)

Main changes:

1/ Send&print wizard

- The model 'account.invoice.send' has been replaced by
'account.move.send' and became models.Model to handle
asynchrounous generation of documents (webservice,..) in
case of more than one invoice.

- The wizard is meant to be overriden in order to add
checkbox and document to be generated. A comprehensive exemple
can be found in account_edi_ubl_cii.

2/ Import invoice from attachments

- The decoding logic has moved from account_edi to account
on the attachemnts.

- The function _extend_with_attachments() serve as a common
entry point for import (from chatter, dashboard).

3/ Export invoice pdf / document

- All the specific actions to export attachments should be
implemented on the account.move and called from the wizard in
 _generate_documents()

- The official pdf for the invoice is now only generated once
 the user request it. In order to regenerate the pdf and
documents, it needs to be deleted.

task-id: 3117238
[enterprise](https://github.com/odoo/enterprise/pull/36757)
[community](https://github.com/odoo/odoo/pull/111857
)

[IMP] web: enable close on ir.actions.act_url in wizard

Before this commit, calling ir.actions.act_url on a modal
leaves the modal open. Which feels ackward in the send&print
wizard.

We now enable 'close' parameter on ir.actions.act_url. If set,
the wizard will close after act_url.

closes odoo/odoo#111857

Related: odoo/enterprise#36757
Related: odoo/upgrade#4387
Signed-off-by: Laurent Smet <las@odoo.com>
2023-03-03 19:10:10 +01:00
Antoine (ande) 961faf9d31 [FIX] base: wrong CH state name
To reproduce the issue:
1. Go to 'res.country.state.csv' in base
2. state_ch_sh is "Shaffhausen"

Error: should be "Schaffhausen"

State code is still SH because
ISO 3166 code for this state is CH-SH

OPW-3199628

closes odoo/odoo#114202

X-original-commit: 245804aabb5cd8b3a84b2a4836b188ec9fb144e1
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2023-03-02 18:18:50 +01:00
Ivan Yelizariev a1187c5140 [FIX] base: update currency symbol for EGP
LE is most commonly used today.

opw-3188129

closes odoo/odoo#114094

X-original-commit: e901ee541407b70fee8bad0d6adc80e0726079d2
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
2023-03-02 16:01:11 +01:00
Bruno BoiandMathieu Duckerts-Antoine d19037e141 [IMP] web,*: better classes handling in view archs
**Before this commit**
- The optional "class" attribute set on the root node of a view arch
  is ignored, except for the kanban view which has a custom
  way of using it.
- The optional "js_class" attribute set on the root node of a view arch
  does not have any impact on the class names passed to its controller.

**After this commit**
The content of the optional attribute "class" set on the root node of an
arch like in

<list class="o_custom_class">
    ...
</list>

as well as an additionnal class derived [1] from the value of the
"js_class" attribute set on the root node of an arch like in

<list js_class="extended_list">
    ...
</list>

will both be found in the prop "className" of any view controller.

[1] a js_class value of "xyz" yields to the class "o_xyz_view"

**Note on this commit**
The kanban view was already appending the root node class attribute
to its renderer element. This is no longer the case and some styling
rules has been adapted.

closes odoo/odoo#113014

Related: odoo/enterprise#37265
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
2023-03-01 17:01:03 +01:00
MerlinGuillaume 25d7d3327d [FIX] base: change default Norwegian date format
The date format set on the Norwegian language is not kept when we click
on date fields

Steps to reproduce:
1. Install Sales
2. Install and switch to Norwegian language
3. Open Sales and create a new quotation
4. Click on the 'Quotation Date' field
5. The date format is changed from '%d. %b %Y' to '%Y/%m/%d'

Solution:
Change the default Norwegian date format to a valid static format
The format used comes from babbel[^babbel], double checked with the
Norwegian locale[^nb.js]
[^nb.js]: https://github.com/odoo/odoo/blob/16.0/addons/web/static/lib/moment/locale/nb.js#L25
[^babbel]: https://www.babbel.com/en/magazine/how-to-write-the-date-in-norwegian

Problem:
The old date format didn't pass the `isValidStaticFormat` test of the
date picker, so the default format 'yyyy/MM/dd' was used instead

opw-3191605

closes odoo/odoo#113926

X-original-commit: c27226e13392207811b61aceb3c77d1e9fcc180d
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
2023-03-01 08:51:20 +01:00
Xavier-Do 7431dac2fc [IMP] tests: add file selection for tags
The test-file is used by some dev to run all test classes from a file.
But test-file is always post install and doesn't always have the same
behaviour of a normal test execution.

This commits modifies the module test tags behaviour to be able to
give a file.

closes odoo/odoo#113850

X-original-commit: 5aff8cf22ab0cbac7a9a3cebf39860f55617f79e
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2023-02-28 23:49:33 +01:00
Xavier-Do e9b170da38 [IMP] tests: refactor unittest classes
Odoo Test environments requires to modify many parts of the unittest
TestCase, Suite and Result.

The main initial reason is to **avoid to postpone result at the end of
the test suite**, because even if it is convenient to have all errors
visible after the tests in some case, odoo logs adds information during
the execution that can be useful to debug when a test fail, to have
context for an error. (see **OdooTestResult**)

We are also fixing the stack trace comming from a unittest and since
there is no proper way to hook inside the TestPartExecutor, a dirty hack
injects anoter result on the outcome to manage the error and complete
the stack trace. This was also a way to avoid to postpone subtest logs
at the end of the test case (see _ErrorCatcher)

`_feedErrorsToResult` was used to test the test suite behavior since
there are many customization and this is quite fragile, especially if
unittest changes behavior in other python version.

**Python 3.11** introduced python/cpython#664448d8 That, in a way, goes
in the same direction of the changed introduced with _ErrorCatcher:
immediately feed errors to resut instead of postponing it. But this also
removes `_feedErrorsToResult` that was used to test this behaviors, as
well as other ones.

Since odoo should remain multi-version, this amount of changes on the
initial behavior become to complicate to keep cross-version and the
(already in our mind for a while) solution to **vendor unittest** will
help to simplify most of our test code base.

This commit modified the vendored unittest files to simplify them as
much as possible to suite our needs.

Since the runner is still the unittest one, we need to inherit from
unittest.Testcase in order to have the right type.

This also means that we still have access to all TestCase methods
without overriding them all. This is convenient for assertion methods as
an example but the initial idea is to vendor our own version of TestCase
to avoid having trouble to adapte our miscommunications to future python
versions. A trade-off must be done to chose what should remain in our
code base. The idea is to keep logic closely linked to our changes in
our code base, mainly around the run method, but also addClassCleanup
wich need to be vendored for python 3.7, but assertions methods are
independent. Any logic can be moved fom unittest to our
vendored version in the future if needed.

X-original-commit: 9a5d1ea54be49e4cc8208c33e76a6bbd2414d5d0
Part-of: odoo/odoo#113850
2023-02-28 23:49:33 +01:00
Xavier-Do 630b6484a2 [FIX] tests: vendor some unitest files
Vendor some unitest file before modifying them in next commit

Chosen files are suite, case, and result since they are working together
and are the most modified classes in odoo.

mock, signals, runner and utils will still be imported from unittest.

X-original-commit: 742d165b9a1bff23deb736dee6b266c76f3ce727
Part-of: odoo/odoo#113850
2023-02-28 23:49:32 +01:00
Julien Castiaux eaff61793b [FIX] website: public user should see published pp
As the public user, browse the website where you usually should see some
profile pictures (e.g. inside the forum). All the images are wrongly
replaced by the grey avatar placeholder.

When using `ir.binary._find_record` it was checking the access rights
and raising `AccessError` early even if the record was
`website_published`.

closes odoo/odoo#113526

X-original-commit: 0611fb437b699588317919e72ccfa1c41f1245bc
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-02-28 23:49:22 +01:00