Commit Graph
5110 Commits
Author SHA1 Message Date
Raphael Collet db25704b75 [FIX] service: autocommit when creating database
Creating a database from the Odoo CLI miserably fails with the error
"psycopg2.ProgrammingError: set_session cannot be used inside a
transaction".

Setting con.autocommit = True fails if some transaction is already
started, which is the case when creating a database.  The fix consists
in rolling back the existing transaction (with only a SELECT) before
switching to autocommit.

closes odoo/odoo#68549

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-03-30 12:54:05 +00:00
nounoubensebia ad602bba0c [FIX] calendar_event, tools: appointment time mismatch
add mail_tz to calendar_attendee model in order to make it easier to change the
timezone displayed in the mail template so that we can use it to make the
appointment time shown on the email reminder sent to the attendees consistent
with the time shown on the website page.

Change the invitation mail template and use the mail_tz field to display time
field instead of using the partner's timezone in order to make the time shown
in the invitation consistent with the time shown on the website page.

Remove the get_interval method in the calendar_event model and use standard
formatting tools instead, as this is more conveniant than having a custom
method for formatting dates, For this reason the format_time function located
in tools/misc.py has been modified to be capable of handling timezones in
order to be able to display time in the correct timezone, furthermore, this
function has been added to the rendering context provided in the
mail_render_mixin file to be used in email templates.

see: https://github.com/odoo/enterprise/pull/16204

Task-2451154

closes odoo/odoo#65729

Related: odoo/enterprise#16204
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-03-30 13:17:07 +00:00
Raphael Collet 3816601819 [FIX] service: autocommit
Following 7a235c19ff, use an alternative
API to the method autocommit().  Several functions managing databases
use a connection in autocommit mode to execute some commands outside of
a transaction.

closes odoo/odoo#68491

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-03-30 09:36:50 +00:00
Yannick Tivisse e896f4a3cf Revert "[FIX]base: fix domain of "user_id" field in res.partner"
This reverts commit a6c26aedf4c8043ac79b241acf6d69d1498f0acd.

closes odoo/odoo#68466

X-original-commit: 18281db9c918ff7b2b0c2fba841ffd8a141f046f
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-03-29 11:42:19 +00:00
Christophe Monniez 0bf5047889 [IMP] base: improve qweb barcode widget
As this backport already exists in saas-14.2 and master, only the
`lxml.html.Element` part is kept in this commit which is a safer way to
build the widget.

closes odoo/odoo#68483

X-original-commit: c891d61802018a14944c22d01316872427a40284
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-03-29 20:23:41 +00:00
Julien Castiaux 7a235c19ff [IMP] core: Deprecate cr.autocommit(True)
Since Odoo 13.0 and the refactor of the internal synchronisation between
the cache and the database, it is unsafe to use the ORM with the cursor
in autocommit mode. The function is deprecated for removal in the
future.

closes odoo/odoo#68313

Task: 2442905
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-03-26 16:10:12 +00:00
Romain Derie 905c9b52a7 [IMP] base: add filter on ir.ui.view to filter modified views
Closes #63040
2021-03-26 13:52:02 +00:00
Olivier Dony 9427804ef4 [FIX] ir.cron: execute jobs in priority order (again)
The selection mechanism selects 1 job at a time from the jobs that are
ready to execute, but while doing this it should respect the `priority`
defined on the jobs. Otherwise the field is useless, and the user has no
way to ensure that a long-running job does not cause starvation.
(Assuming execution resources that are insufficient for 100% of the
processing to happen)

The `priority` ordering was apparently lost during the introduction of
the trigger mechanism in #62124 via
4b28f1162a.
It was previously taken into account in `_process_jobs()`.

The `ORDER BY` is not strictly necessary in `_get_all_ready_jobs()`, but
it seems more consistent for this method to return an ordered list as
well, given the semantics of the `priority` field. We don't know what
the caller will do with the result.

closes odoo/odoo#68411

X-original-commit: 9d570662b4016b5cd9ad3c85abbcb5428c169cc6
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2021-03-26 15:04:23 +00:00
Thibault Libioulle 8bbf0e9e64 [IMP] project*: improve sub tasks workflow
We want to ease user experience regarding sub task creation and
management. We thus enforce the values of subtask stage, project and
parent task. we want to remove the ability of a user to choose a
third-party subtask project different than the actual one. Also, we want
to remove the ability to make one sub task recurrent. In general, We
want to improve and strengthen the relation parent-childs for Tasks. A
sub task is dependant of its parent all along the workflow.

This commit address those needs and, especially, removes the subtask
project configuration discussed in :
- odoo/odoo@66a0e5a
- odoo/odoo@b709e22

1) With this commit we want to change the way to link a subtask with its
project	for UI reasons, we want to be able to easily distinguish
subtasks that are linked to the project of their parent from subtasks
that are linked to another project. To do so, the idea is to create a
field display_project_id not required. Only relevant tasks are linked
to their project through this display_project_id, the other are linked
to their project only via project_id. As a result, domains in the
application are only based on the fact that tasks have
display_project_id. The other are simply hidden.

2) The number of subtasks is shown on kanban and list views with a
   wigdet to easily render it and extend the UI.

3) The default sub-task assignee is the assignee of the parent task.

4) Task form is modified to integrate those changes.

5) Various searches on project task are restricted with a clause where
display_project_id must be not null. Except in portal, in which context
we always display all tasks and subtasks.

PR community: #62577
PR enterprise: odoo/enterprise#15043
PR upgrade: odoo/upgrade#1984

task-2388034

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-03-26 13:51:39 +00:00
Nicolas Lempereur 5ef48dbdff [FIX] translate.py: CSV export correct module name
Correct small typo that the module when exporting translations as CSV
file might have been the wrong module because we used variable from
previous loop.

This did not seem to cause any issue since in this given case in import
we got the module from the part before . in XML ID ({module}.{name})
that was right.

found when working on opw-2439029

closes odoo/odoo#68297

X-original-commit: 62e7b161d39e5f5f6751cf87826fa6f7b729f83d
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-03-24 11:54:02 +00:00
Thibault Delavallée df52fedee6 [IMP] base: add missing views for ir.cron.trigger model
Purpose of this commit is to help debugging processes involving cron triggers
by adding views and a menu in Odoo. It allows to see triggers having been
created. Menu has been added under Scheduled Actions (aka Crons), in Technical
menu.

Task ID-2414658
COM PR odoo/odoo#63093
2021-03-24 11:18:06 +00:00
Julien CastiauxandRaphaël Collet 9a8cf18ddb [IMP] core: New 'capture_trigger' test helper
When testing cron triggers, it is common to get the newly created
triggers in order to validate they exist and are scheduled are the right
moment.

This new helper is a context manager that capture all triggers or
triggers created for a specific cron. The created triggers are
accessible via the context's object `records` attribute.

The various tests have been updated so they use that new helper.

closes odoo/odoo#68163

Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
Co-authored-by: Raphaël Collet <rco@odoo.com>
2021-03-24 09:29:38 +00:00
Nicolas Lempereur 5be7af0494 [FIX] translate.py: import model from CSV correctly
When importing transtlation from CSV, we:

- cut at `:` character to get the model
- used a model for types other than model and model_terms

This caused error that do not happen in PO import because:

- the model is before the `,` character
- the imd_model column is constrained to 64 characters, and a name that
  is not a model could be over that size.

With this changeset, the CSV import match better current PO import.

opw-2439029

closes odoo/odoo#68266

X-original-commit: cff91c6acbb7ef6a884d4dc4170574b83ff6e4cb
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-03-23 18:18:21 +00:00
Christophe Simonis 995d5dfe82 [FIX] tools.file_path: correctly handle the addons/ prefix
The tests passed because the path with the prefix is valid at root_path.

closes odoo/odoo#68257

Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2021-03-23 16:32:10 +00:00
Fabien PinckaersandRaphael Collet 085e972e4a [IMP] core: clean up and speed up XML/HTML translation
The former algorithm was recreating a full etree from scratch, while
parsing the content to translate.  Instead, we parse the etree and
update only the content that to be translated.

Before:
| In [2]: %timeit views.invalidate_cache(); views.mapped('arch_db')
| 578 ms ± 7.83 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

After:
| In [2]: %timeit views.invalidate_cache(); views.mapped('arch_db')
| 208 ms ± 2.79 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

Reading a view is 2.63x faster: from 504 ms, to 191 ms (sum of all the
1345 views, when installing website_sale).  Large views, like web pages
goes up to 3x-4x faster; small views are ~2x faster.

As views are cached, it only impact the loading to put in cache, but all
XML/HTML fields get the same performance gain.

closes odoo/odoo#68182

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
2021-03-23 15:35:47 +00:00
Francois (fge) 9c804aace3 [FIX] base: js_transpiler import legacy module
In a @odoo-module js file, importing a legacy module that did not have
a name respecting the "addon.name" format was not supported.

This commit will support all keys that do not start with a "." or "@".
This commit will also improve some regexes allowing to extract path.

Legacy module name supported:
    import X from "some/path"
    import X from "addon.name"

Legacy module name not supported:
(relative path and @module/path are only used to import @odoo-module js
files)
    import X from "@some/path"
    import X from "./some/path"
    import X from "../../some/path"

closes odoo/odoo#68152

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-03-23 14:15:02 +00:00
Dharmraj Jhala 9e4c8d61ea [IMP] base, survey: add option to enable smart-shnking
This commit adds a boolean field `disable_shrinking` in model
`report.paperformat`, which, if set to True, will add one
argument `--disable-smart-shrinking` in commands that prevents
the pdf shrinking. See issue[1] for more information.

This options is utilized for printing survey certificaiton.

issue[1] - https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3226

taskID-2483393
2021-03-23 10:08:58 +00:00
Christophe Monniez 1ba22f8aee [IMP] tests: add a test to avoid translations of template strings
When a template string that contains an expression is translated, the
resulting msgid is wrong.

e.g.:

    _t(`blah blah ${expression}`)

will generate a wrong msgid like this:

    msgid "blah blah ${expression}"

With this commit, a new test is added to find and forbid translations of
JS template-strings.

closes odoo/odoo#68165

X-original-commit: 9184ae45e0df179fc093c1fc48a7fa56d8fe9594
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-03-19 18:27:00 +00:00
wan 2fcfa2cc18 [FIX] tools: support malformed more malformed pdf
We do not want to fail ever if loading the attachment fails.
We still log a warning in every case though.

Some malformed PDFs lead to seeking the wrong bytes while looking for
some parts, raising a ValueError

closes odoo/odoo#68171

X-original-commit: f4cc0579a3e0ee9c117c7dd0f6090edc6e94384d
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-03-19 19:41:02 +00:00
Julien Castiaux fb4cf35368 [FIX] base: View error reporting can lack a context
A context is attached to the ValidationError object when elements in the
view arch are broken. This context helps to locate the error in the
source file. When the view processing fails outside of the arch
evaluation, such context is missing.

closes odoo/odoo#68157

Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2021-03-19 16:13:17 +00:00
Stéphane Bidoul 13b40bff2c [FIX] base: allow using another postgres schema than public
Before 1721ec1363 and fdc4ef97c9, Odoo did work fine when the
user had another default schema than 'public'.
This commit restores this behaviour by searching
for existing objects in the user's current schema,
which is the first in the schema search path and
the one used when no schema is specified when
creating objects.

closes odoo/odoo#68144

X-original-commit: 223781b34afacd1c0c5674d395cece6d472b048c
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2021-03-19 12:42:16 +00:00
Olivier Dony 49429f986a [IMP] tools: simplify and modernize file_open()
- Remove legacy arguments (`subdir`, `pathinfo`) of `file_open()`,
  they were not used anymore and made the code more complicated

- Drop the long-deprecated support for files inside zip archives,
  considering that zipped modules were discontinued a long time ago:
  278ed718e9

- Remove the redundant `_file_open()` method, that should never have been
  called directly anyway

- Add the possibility to filter allowed file extensions, in order to
  avoid opening up access to arbitrary addons files, such as .py files,
  depending on the context of use

- Split up the verification of the file path, to make it accessible
  without actually opening the file, as a separate `file_path()` function.

closes odoo/odoo#68043

Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2021-03-19 11:40:52 +00:00
Benoit Socias d41083e2fb [FIX] base: make the tests of sorted ir.filters work
Before this commit ir_filter tests were calling model.search() with an
array as order. It was not a problem because none of the tested filters
was actually using the sort and the falsy empty array was therefore
ignored by model.search().

After this commit ir_filter test calls model.search() with a string as
order.

task-2453416
See https://github.com/odoo/odoo/pull/65554

closes odoo/odoo#68036

X-original-commit: f326ba2d14e4fdd811426c6381b7e5bc3c1d657b
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-03-17 16:08:52 +00:00
Mathias Markl 6ca12a2545 [IMP] base: performance improvement when installing a module
closes odoo/odoo#67316

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-03-16 11:50:29 +00:00
oco-odoo 56f8c1c048 [FIX] base: tools: float_split_str: avoid traceback when rounding to 0 places and add some test cases
closes odoo/odoo#67970

X-original-commit: 42d409f180381316c97abd0c0ef5a062656e6122
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-03-16 15:09:51 +00:00
Mathias Markl f6d8275533 [IMP] base: performance improvement when installing a module
closes odoo/odoo#67959

X-original-commit: c0afa00d7cdbe98e4c67d2987a2b808bedd474ac
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-03-16 14:00:32 +00:00
ioFilippo 0a3c05d18e [FIX] modules: apply override translation option
Translation overwriting was not working when forced by command line
arg --i18n-overwrite

This is due to the change of signature of the method, no longer
relying on the context

Fixes odoo/odoo#67419

closes odoo/odoo#67873

X-original-commit: 44624f5d51a266c4fc37644d3fc36b810e722ee4
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-03-15 15:06:10 +00:00
Adrian TorresandRaphael Collet 143cffe001 [FIX] base: reset _rec_name if x_name field is deleted
Commit 6a0028f91944b1d9e4eac026e86ca249ef5bc7ee introduced a change that
allowed field_triggers to be computed lazily per registry, this change
introduced a behavioral change that is not easy to notice, in order to
explain the behavioral change I will use the following example which was
the original bug reported:

    - Install studio
    - Create an app (create a new custom model M)
    - Uninstall studio
    -> Uninstall fails because field display_name of the custom model M
    depends on field M.x_name which has been removed due to the
    uninstall process.

To understand why it didn't happen before the aforementioned commit, we
must first understand what happens with said commit applied:

    - We trigger the uninstall of studio, this triggers the uninstall of
    any modules that depend on it, namely studio_customizations which is
    the module in which all customizations done with studio live in.

    - We gather all data belonging to the studio_customization and we
    start deleting in the following order: ...,
    ir.model.fields.selection, ir.model.fields, ..., ir.model

    - During the unlink process, we first remove the actual fields from
    the model instances before deleting their database reflections, this
    is done in the ir.model.fields._drop_column() method, it is this
    method that will delete the x_name field but **not** the
    display_name field, since it is a base field and not a custom one.

    - After the deletion of the fields in memory, we call modified() to
    mark fields that might've depended on the fields we just modified so
    that they can be recomputed later.

    - The call to modified will in turn access field_triggers, but since
    we're in a new registry and field_triggers is a lazy property, it
    will be computed right at this moment, this means that it will call
    resolve_depends on the display_name field which still exists, and
    this field has a dependency on the x_name field that we just
    deleted! This is what will trigger the crash.

With that context, we can now understand how it didn't crash before
commit 6a0028f91944b1d9e4eac026e86ca249ef5bc7ee:

    - Before the aforementioned commit, the field_triggers attribute was
    computed during the registry's setup_models(), in the case of an
    uninstall this call to setup_models was done way before the
    uninstall step of the registry (Step 3 is the last to call
    setup_models before Step 5).

    - This means that the old behavior was technically a bug, because
    right after removing x_name from the model, the field_triggers still
    contained a dependency from display_name to x_name, the former being
    no-longer present in memory.

With this commit, we simply reset the _rec_name and the dependencies of
the display_name if the x_name field is being removed, this ensures that
the computation of field_triggers won't crash and burn.

opw-2452498
opw-2478589

closes odoo/odoo#67823

X-original-commit: e6d22a43ff9f40e5fc7b8c84cd4dfe43f926d872
Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
2021-03-15 09:30:21 +00:00
Adrian Torres ab7b5af3e8 [FIX] base: properly execute Selection field ondelete actions
With this commit, 2 changes are made to the way that the
fields.Selection.ondelete cleanup action works:

1) We manually delete ir.model.fields.selection **before** the deletion
of ir.model.fields purposefully to **avoid** SQL CASCADE deletes, as we
do not know which selections are deleted in cascade and thus we cannot
perform the corresponding ondelete cleanup action (which is implemented
within the ORM).

2) In some actions, namely 'set default' and 'set null', we write a
"safe" value to the records containing the Selection being deleted,
before this commit this would go through the ORM (records.write()) but
this is problematic if there's a write override for the record's model
that raises an error for the field being written to. With this commit,
we first try to go through the ORM but if there's a failure (because of
the raise in a write override) then we will bypass the ORM and set it
with SQL.

opw-2451126

closes odoo/odoo#67616

X-original-commit: f5c7e861ee3ca0cdeb6c2f06d227ada07f923ed0
Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
2021-03-11 06:45:42 +00:00
Adrian Torres 75243d5a43 [FIX] base: do not assign default ondelete policy for base fields
Previously, an ondelete policy would be assigned to any required
Selection fields, the default policy being 'set null'.

Base fields do **not** require an ondelete value, since if they are
deleted there is no "data fix" to apply because the field's column is
dropped, and in fact it's error-prone to do so because during
`_process_ondelete`, the system would attempt to set to null fields that
were required (i.e. NOT NULL).

This issue is hidden by the fact that ir.model.fields are usually
deleted **before** ir.model.fields.selection and thus the ondelete
action won't be applied on the field with the original definition
(because it has probably been deleted by SQL CASCADE)

X-original-commit: 2e238f1e0202d65a98177939dac166dd659bb39c
2021-03-10 16:45:06 +00:00
Jorge Pinna Puissant 304eef3ced [FIX] base: traceback on testing outgoing mail server connection
- Settings > Technical > Email > Outgoing Mail Servers;
- Create a new serve with no security;
- Test connection.

Before this commit,  a traceback error is raised. This occurs because
SMTPException don't have 'smtp_error'.

Now, the UserError is shown correctly.

opw-2464796

closes odoo/odoo#67712

X-original-commit: f0e478a154b1f15146c7d95e0ffe146bb22b8cae
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2021-03-11 16:44:30 +00:00
Tymoteusz Motylewski df4015f5f5 [IMP] tools: remove unneded dot from CLI group header
Internationalisation options. :
is now
Internationalisation options:
2021-03-11 18:06:21 +00:00
Julien Castiaux dddf1bc34b [IMP] models: Better error than apple and orange
The "TypeError: Mixing apples and oranges" error message is raised when
users are using recordsets from different models together. The error
message was confusing some users thus have been reworded to be more
explicit.

The initial proposal was to replace "apples" and "oranges" by "torchons"
and "serviettes" but it was rejected because the French are not capable
not to mixup the two. They suggested to instead replace "apples" and
"oranges" by "pain au chocolat" and "chocolatine", this was rejected
because none of us understood the difference between the two, they both
are couques.

closes odoo/odoo#62266

Task: 2366612
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2020-12-11 14:15:29 +00:00
Djamel (otd) a8f8999409 [FIX]base: fix domain of "user_id" field in res.partner
Steps to follow to reproduce the bug:
-Go to the Contact app
-Choose any contact
-In the contact form> go to the "sales & purchase" tab and try to assign a user in the "salesperson" fields

Problem:
You can choose any user regardless of their type. While normally we can only choose internal users

Solution:
Add a domain to the "user_id" fields to only see users of the kind "internal type"

opw-2468819

closes odoo/odoo#67642

X-original-commit: 1361686fe502be137a4757c9092fab4223d484f8
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2021-03-11 09:29:51 +00:00
Nicolas Seinlet b404ae6a55 [FIX] registry: avoid dropping indexes
When an index has name 'tablename_fieldname_index', this index is
dropped if the field has index=False.  This lead to dropping a
user-created index or dropping/recreating the index when index=True is
set in a dependent module.  Some info is logged instead.

closes odoo/odoo#67602

X-original-commit: 6a87318df296a11e3300723ca0c8b49c0dcf5fa7
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-03-10 14:56:16 +00:00
Nicolas Seinlet 5fa1256bb6 [FIX] registry: no name in constraint check
When table name is long enough, the foreign key constraint name computed
by odoo and the one by PostgreSQL are different, for the same table,
column and definition, are different. As an example,
base_partner_merge_automatic_wizard_res_partner_rel(partner_id) foreign
key is named
base_partner_merge_automatic_wizard_res_partner_rel_res_partner_id_fkey
in Odoo while it's
base_partner_merge_automatic_wizard_res_par_res_partner_id_fkey in
PostgreSQL. This difference trigger a useless foreign key drop/create.

closes odoo/odoo#67601

X-original-commit: 353b415c74da057d5e81cce4d309bebb5f0f2927
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-03-10 14:55:59 +00:00
Jeremy Kersten 3b9cd53660 [IMP] base: check fallback on AccessDenied
Before this commit, we only check if another endpoint can be serve in case of
404 not found. Idea was that each url has only one endpoint.

Fun effect is that if record doesn't exist, route doesn't match, so in reality
we had one endpoint but we fallback too to check if another match.

But it doesn't match a recurring case, when you archive a record, and want to
create a redirect for your seo and customer to another record, it is just
ignored because the url math a controller (that return 403 since you don't have
anymore the access right)

Since ask to the customer to delete the record is not always possible
(e.g. a product already sold) now we check if a fallback match for 403.

closes odoo/odoo#66030

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-02-12 08:46:31 +00:00
Martin Trigaux 0fda70aa8e [FIX] tools: properly format error message
To reproduce:
1. take a translatable record with an external id
2. delete the record but keep the ir.model.data (sql)
3. export the translations of the module linked to the orphan
   ir.model.data
-> Error while formating the message

This commit fixes three issues:
- %d instead of %s to construct the string
- wrong order to identify the missing records
- display the external ids instead of the ids (which may not be very
  helpful to debug)

Courtesy of Yannick Brant

closes odoo/odoo#67530

X-original-commit: a2a45539ca4056eb3b3d5d6bafbfb63c10255843
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-03-09 12:11:11 +00:00
Christophe MonniezandRaphael Collet c23b13eafe [FIX] models: call inverse method right after cache invalidation
When a record is written on a computed field with an inverse method and
an x2many field wit a delete command, the computed field is not properly
handled by the inverse method, because of a whole cache invalidation
that happens during the unlink.

With this commit, we write in cache on the fields that have been
invalidated before invoking the inverse method.

opw #2439861

closes odoo/odoo#67525

X-original-commit: d39855bad5153654d443d1b7ede3907f8bae3e66
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
2021-03-09 11:24:09 +00:00
William Henrotin 5b1fac7a78 [IMP] base: use of float_compare in server actions
This commit gives access to float_compare function in server action python
code.

closes odoo/odoo#67500

X-original-commit: 3046b11f50aa1a0e02725492ba63b17c194db751
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-03-08 17:19:11 +00:00
Christophe Monniez 76aff7b774 [FIX] core: avoid astroid imp module deprecation warning
The astroid package where version is lower than  2.5.1 uses imports the `imp`
module that was deprecated in python 3.4 [0].

In Debian buster, astroid version is 2.1.0 and 2.3.3 in Ubuntu Focal.

With this commit, the deprecation warning is filtered out.

Note that pylint 2.5 avoid that deprecated import [1], that's the reason
why the warning was not showing on current runbot Docker image.

[0] https://docs.python.org/3/library/imp.html
[1] https://github.com/PyCQA/pylint/commit/51c646bf70a6e0a86492bfd2ddd1885671d64d67

closes odoo/odoo#67469

X-original-commit: 8127bea147c093aa64ac7d31ebc69e4dcbef6eef
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-03-08 12:39:31 +00:00
Djamel (otd) 313bd0a2be [FIX] base: fix the customer search by vat number
Steps to follow to reproduce the bug:
-Go to sales
-Add a vat number with a '-' like: "123456789-5" to any customer
-Create a new SO
-Search the customer by entering their VAT number

Problem :
When the VAT number contains the character '-' you cannot find the customer with his VAT number.
The problem is the same if the vat number contains a '.'
Because, the "_name_search" method before creating the query to search clients by VAT number, removes all the special characters from user input

Solution :
Do not remove the characters '-' and '.' from the user input for the customer search by vat number.

opw-2457692

closes odoo/odoo#67355

X-original-commit: 3f54c1c7556c5d06759bf5ec74dd83872f0d24d2
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
Signed-off-by: Djamel Touati <DjamelTouati@users.noreply.github.com>
2021-03-05 14:27:38 +00:00
Christophe Monniez 97579f9c13 [FIX] packaging: remove dead code that prevent rpm build
Since 9c2ce1f12c2, more files are included in packaging.  The rpm build
failed because shebang lines of packaged files must not use
`/usr/bin/env` [0] [1] [2].

As it seems that those old files are not of any use anymore, this commit
removes them.

[0] https://docs.fedoraproject.org/en-US/packaging-guidelines/#_shebang_lines
[1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#Multiple_Python_Runtimes
[2] https://pagure.io/packaging-committee/issue/738

closes odoo/odoo#67294

X-original-commit: 54b6a7a97e574249c22f16ea2756989e4bd4fac3
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-03-04 18:39:14 +00:00
Damien Abeloos 162f3059d5 [IMP] base: modify some displayed texts for res_partner
* Add a new error message upon deleting the partner linked
  to an active user.

* Improve the error message wording upon archiving the partner
  linked to an active user. Add the linked users names at the end of
  the message.

* If the user has 'write' access on res.users, raise a RedirectWarning
  instead of a ValidationError, to offer an easy access to the related users :
    - If there are multiple Users, redirect to a list view.
    - If there is only one User, redirect to the form view.

* Adapt the test_access_deleted_records from test_orm.py to use a more
  basic model : `res.partner.category` (with less business logic), because the
  new unlink error message is dependent on a condition that will throw an error
  in case of multiple unlinks of the same record (MissingError).

* Force close the frontend archive confirmation Dialog since _toggleArchiveState
  may be interrupted by another Warning/Error Dialog. If the new Dialog was the
  redirectWarning, and the user chose to be redirected, the first Dialog would
  stay open even thought the context already changed.

* Modify the placeholders for a partner Name/Company
  -> placeholders will change according to an Individual or a Company.

* Adapt the main_flow tour to correctly select the partner name field on
  mobile (tested in enterprise).

Task ID : 2410217
PR : https://github.com/odoo/odoo/pull/63370
2021-03-03 12:12:47 +00:00
fja-odoo 9ea276ae2f [IMP] website_form, *: allow form default input value
* = web_editor

Add support for default values on website form

Compatible fields are: textarea, text, number, date, datetime, unique
checkox, multiple checkboxes, radio buttons, select.

Part of: https://github.com/odoo/odoo/pull/47949
task-2011583
2021-02-26 14:40:49 +00:00
ijas ahammed eca92a97be [IMP] base: display db ID along with name in partner merge wizard
Before this commit:
When merging the contacts, chances are there that the name of records being
merged are exactly same, and so we might not be able to distinguish them
and so can not tell for sure that which records are being merged to which
destination record.

After this commit:
In the 'Destination Contact' field, now we also show ID of the partner
along with the name, so that end user can easily distinguish between
them. For this, we pass 'partner_show_db_id' on the context for that field from
view, allowing us to get expected result from the name_get by using this
context key.

Task ID-2323060

closes odoo/odoo#66026

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-03-02 14:12:50 +00:00
Raphael Collet 22b0142d4e [IMP] core: delegate fields should be auto_join=True
The field that supports inheritance should be auto_join=True.  This
guarantees that searching on an inherited field (X) or its explicit
related expression (foo_id.X) gives the same query.

Note that adding auto_join=True on that field does not weakens the
model's security, since searching on the model automatically injects the
parent model's security rules into the query (see _apply_ir_rules).

closes odoo/odoo#66925

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-03-01 08:28:48 +00:00
Alvaro Fuentes 8aa4f42442 [IMP] tests: add test_sequence order for tests
We have some tests in odoo/upgrade that are sensitive to the order on
which they are executed. Specifically: IntegrityCase tests need to be
run after all UpgradeCase tests across all Odoo modules.

To support this we implemented a sorting mechanism for tests based on
the test_sequence class attribute. This is intended to be used by meta
cases, not by individual tests.

closes odoo/odoo#66521

Related: odoo/upgrade#2184
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2021-02-19 12:51:00 +00:00
Raphael Collet b652d84cd1 [FIX] core: convert_to_write() of x2many field with new records
When comparing the values of a new record with its origin, x2many fields
are always different because we compare new records with real records.
For instance, converting the value of a one2many field where lines have
a many2many field always returns update commands for the many2many
field.

closes odoo/odoo#66950

X-original-commit: 03a4137cc3fa398dbd0cb214dc5472a083ae33b8
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-02-26 16:32:16 +00:00
Francois (fge) 7b53bb4b6f [FIX] base: @odoo-module alias ending with **/
When you define an @odoo-module with an alias without any space between
the alias and the **/, the alias contains the **/.
The purpose of this commit is to no longer add the **/ to the alias.

Example:
/** @odoo-module alias=web.base**/

Before:
  odoo.define(`web.base**/`, function(require) {
After:
  odoo.define(`web.base`, function(require) {

closes odoo/odoo#66929

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-02-26 16:06:43 +00:00