Commit Graph
159150 Commits
Author SHA1 Message Date
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
Patrick Hoste 8bcdc5f82f [FIX] auth_password_policy: add PasswordField template to manifest
This commit adds the PasswordField template to the manifest
which was missing after being extracted from the JS Component.
Introduced by https://github.com/odoo/odoo/commit/688986f888f2fe2371d58b74ded81315ba6bb353

Task-3222527

closes odoo/odoo#114645

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-08 11:37:07 +01:00
william-andre f075cba176 [FIX] account: module installation in post init
There is only one module that can be installed, key change was forgotten
during refactoring during initial dev.

closes odoo/odoo#114544

Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
2023-03-08 11:37:04 +01:00
aliya e84d479ee3 [FIX] l10n_co: fix accounts on tax repartition
The most recent update in l10n_co broke tax repartition: incorrect accounts are assigned to withholding taxes.

This commit fixes the accounts on taxes and adds missing accounts to Colombian CoA.

task-3212928

closes odoo/odoo#114471

Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Aliya Tastemirova (alta) <alta@odoo.com>
2023-03-08 11:37:02 +01:00
FrancoisGe a8ad4b5b57 [FIX] web: Save & New with a context dependent parent record
Before this commit, in x2m fields with a parent record dependent context,
the context used to generate default values for a new record by clicking
on "Save & New" could be wrong. It was not based on the edited values of
the parent record.

How to reproduce:
- Go to a form view with a text field (field_a) and an x2m field with the
  context { default_field_b: 'field_a' }.
- Edit the 'field_a'
- Click on "Add a line"
A dialog opens with the edited value of 'field_a' as the value for 'field_b'
- Click on "Save & New"

Before this commit:
    A dialog opens with the unedited value of 'field_a' as the value
    for 'field_b'

After this commit:
    A dialog opens with the edited value of 'field_a' as the value
    for 'field_b'

closes odoo/odoo#114460

X-original-commit: b22ef9d2cc4119c8cd6e9c72103279e37f043440
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-08 11:36:59 +01:00
Walid HANNICHE (waha) 615aa00daa [FIX] stock: unit price rounding
Steps to reproduce the issue:
. Change the decimal accuracy of the product price to 0
. Create a storable product and set the Vendor Tax
. Create a purchase order with that item.
. Set the unit price to have 0 decimal places. E.g: 20
. Change the demand quantities to 10
. Confirm the purchase order -> Traceback

Bug:
wrong key word arg used for _float_compare for this PR [1]

Also this PR, remove the rounding on `total_void` in `_compute_all()` to
ensure the price unit have the maximum precision. Usually, the price
unit is rounded following the 'Product Price' accuracy rather than the
currency one.

opw-3136160
[1]:https://github.com/odoo/odoo/pull/105080

closes odoo/odoo#114356

X-original-commit: 6906c32626cb222246a895ba2ba5d15b3263935d
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-03-08 11:36:56 +01:00
Horacio Tellez ddda5d4a26 [IMP] payment: allow the public user to pay with tokens
Before this commit the public user did not have access to tokens or the
possibility of saving payment methods.

When receiving a link to pay the customer (even if not logged in) should
be able to use tokens saved by the parter of the document and also save
new payment methods. This is intuitively correct: as the possesor of the
link, the customer have rights to pay with tokens linked to the partner.

After this commit tokens linked to the partner of the document will be
visible to the public user and also the possibily to save payment
methods.

Task - 2799296

closes odoo/odoo#104472

Related: odoo/enterprise#34792
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-03-08 11:36:53 +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
Jorge Pinna Puissant bd2bf1a30f [FIX] account: remove isVirtual
Since [1] we removed the isVirtual function from the record, to use the
equivalent isNew, this was made to avoid having two functions with
equivalent behavior. This one was forgotten.

[1] : a73390a42a

closes odoo/odoo#114639

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-08 10:31:15 +01:00
Adrien Dieudonné 0d2a80a071 [FIX] partner_autocomplete: field as title is too short
Before this commit when the partner autocomplete field was used
the form title css rules defined in o_field_char were missing.

So now the width: 100% is also applied when the partner autocomplete
is a title and takes the whole available space.

closes odoo/odoo#114610

X-original-commit: b9788544b7101e5a202cf87989bc3f5fc0495249
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2023-03-08 10:31:12 +01:00
Andrea Grazioso (agr-odoo) f5cdc4f14c [FIX] l10n_id_efaktur: use shipping address for Column "ALAMAT LENGKAP"
To generate an e-faktur

1. Settings > Users & Companies/Compagnies:
- Create a new company ‘ID Indonesia’:
- Set the state (e.g Yogyakarta (ID))
- Set the country ‘Indonesia’

2. Accounting > Customers > e-Faktur
- Set a range of numbers (which are supposed to be assigned by the
Indonesian government)

3. Accounting > Configuration > Settings
- Fiscal Localization: select the Indonesian package

4. Accounting > Customers > Customers
- Create a new res.partner:
- Set the country ‘Indonesia’
- Check ‘ID PKP’ field
- Fill Tax Address field
- Fill NIK field
- Under ‘Accounting tab’: set both accounting entries (Receivable +
  Payable)
- Create a delivery address

5. Accounting > Customers > Invoices
- Create a random invoice with the res.partner set in point 5. as the
Customer
- Confirm the invoice
- Action > Download e-Faktur

Under column ALAMAT LENGKAP the tax Address will be used, but the
delivery address should be used
Follows the official documentation with translation
https://www.pajakku.com/tax-guide/12490/PER_DIRJEN_PJK/PER - 03/PJ/2022
(Article 6, paragraph 6)

Translation:
Paragraph 2 : The identity of the Buyer of Taxable Goods and Services or
the Recipient of Taxable Goods and Services which includes name,
address, NPWP, NIK, and passport number as referred to in Article 5
letter b must be filled in accordance with the actual or actual name,
address, NPWP, NIK, and passport number.

Paragraph 6 : In the event that the delivery of Taxable Goods and/or
Taxable Service is made to the Buyer of Taxable Goods and/or Receiver of
Taxable Service which is the place where the VAT or VAT and STLG payable
is concentrated, but the Taxable Goods and/or Taxable Service is sent or
delivered to the place where the VAT or VAT and STLG payable is
centralized, the following provisions shall apply:
a. the name and NPWP as referred to in paragraph (2) shall be the name
and NPWP of PKP where the VAT or VAT and STLG payable is centralized;
and

b. the address as referred to in paragraph (2) shall be the address of
the place where the VAT or VAT and STLG payable that is centralized
receives the Taxable Goods and/or Services.

opw-2878096

closes odoo/odoo#114087

X-original-commit: 15dc3de31ef07a73078bbe3656f3518a1e9679fd
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
2023-03-08 10:31:07 +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
Pieter Claeys (clpi) 1109443069 [FIX] stock: scrap quantity editable in done state
Since https://github.com/odoo/odoo/pull/104062, the quantity field on a scrap order is still editable when it is in the done state. This behaviour is now fixed.

Community PR: https://github.com/odoo/odoo/pull/114320

closes odoo/odoo#114337

X-original-commit: a226a0ae51b4ece6a7e68ea56cf23396e2cda65e
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-03-08 09:26:50 +01:00
David Monnom (moda) 7b14d73a5a [REF] point_of_sale,pos_*: remove legacy posbus
closes odoo/odoo#113782

Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-03-08 09:26:47 +01:00
FrancoisGe d060853b7a [REF] web: remove dirtyTranslatableFields from model
The logic of dirtyTranslatableFields is only needed in one place in
the form view. We will therefore remove this function from the model.
We'll take the opportunity to replace dirtyFields with isFieldDirty
because all uses of dirtyFields want to check with the name of a field
if it is dirty or not.

Part of Task: 3179751

closes odoo/odoo#114560

Related: odoo/enterprise#37866
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-08 08:24:21 +01:00
Merel Geens (mege) 283c1f102d [FIX] website_sale: store empty fields as False
If you specify an empty VAT number in the Contacts app, it will store it
as `False` in the ORM. If a new partner is created through the shop, the
VAT number is set through HTML form submission. It will use `''` for an
empty VAT number. When evaluating the VAT number in Python code, it will
usually be converted to a boolean, so it doesn't matter if it's `False`
or `''`. But in ORM queries those are two different values and code that
checks on `False` to check for the presence of a VAT number can
misinterpret `''` as being one.

This fix replaces `''` values submitted through the address form in the
shop with `False`.

opw-3114246

closes odoo/odoo#114617

X-original-commit: 84106a1d43fa768429f555cd49a72e0fd2adee4b
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Signed-off-by: Merel Geens <mege@odoo.com>
2023-03-08 07:04:14 +01:00
det 3dfe9d372f [FIX] account: add attachments to send&print
Before this commit, it was not possible to add attachments to the
send&print wizard (account.move.send) due to:
https://github.com/odoo/odoo/commit/688986f888f2fe2371d58b74ded81315ba6bb353

closes odoo/odoo#114627

Signed-off-by: Laurent Smet <las@odoo.com>
2023-03-07 23:10:01 +01:00
Xavier BOL (xbo)andYannick Tivisse e2cec54fad [FIX] project: improve performance for burndown chart report
Before this commit when the user wants to see the burndown chart of a
old large project then the report could take more than 20 sec to be
loaded.

This commit adds 2 indexes one on `mail_tracking_value` table
(`mail.tracking.value` model) and the other one on `mail_message` table
(`mail.message` model) to reduce the load of that report to less than
10 sec.

task-3177072

closes odoo/odoo#114114

X-original-commit: c6b355d471889634ae26a020e14c81e9a315b3de
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
2023-03-07 23:09:58 +01:00
Abderraouf Ghrissi (abgh) c28063baee [IMP] project: add task quick create shortcuts
In this commit,
-We Ease the quick creation of tasks by providing shortcuts allowing the user
to set different fields (planned_hours, tags, priority, and assign to users)
without opening the form view.

task-3145203

closes odoo/odoo#112821

Related: odoo/enterprise#37166
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-03-07 20:31:53 +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
Romain Derie f5225d5bc6 [FIX] website: prevent social media tour to fail sometimes
There is a weird deeper low level misbehavior which makes concurent
click to not acts as they should.
Depending on the runbot/tour speed, the misbehavior might kick in and
makes the tour fail.

When you click on multiple options very quick back to back, their click
will be registered and processed one by one, waiting for the previous
one before considering the next one.
You can see that by simply printing a console log in both
`renderListItems` and `_computeWidgetState` method from `s_social_media`
`options.js` file. Then click quickly on the options related to this
snippet like the active toggle and/or remove custom media.

Despite respecting the click order and not overlapping, some click
results (like hidding or removing) will be rollbacked visually and only
the latest click result (starting from the DOM state before the first
click) will be applied.

Long story short: spam click on every toggle option of all the social
media, you will see that all your click will be processed one by one:
- The first media you toggled off will be toggled off
- Then the second media you toggled off will be toggled off but the
  first one will be back to toggle on.

It seems to be correctly applying the click result one after the other,
but always starting from the initial DOM state/option widget state
(before the clicks), and not as it should: process the second click
based on the state of things altered by the previous click.

This will need a deeper and longer investigation to fix the root cause.
In the meantime, as this tour is failing multiple times a day, this
commit introduce a workaround to avoid this error in the tour.

task-3212519 (later fix)
runbot-16628

closes odoo/odoo#114600

X-original-commit: e9bd67672ea0517771998ec56f155709cd7c310e
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-03-07 19:04:21 +01:00
Louis (loco) 051b98d5f0 [FIX] web_editor: remove the possibility to edit readonly image field
Steps to reproduce the bug:
- Add multiple images on a product page
- Go to the shop and edit an image of this product by double clicking
on a small image on the carousel thumbnail
- Save
-> Nothing happens and the image is not updated

The goal of this commit is to ensure that a field of type image is not
`readonly` before adding the `contenteditable` attribute to its image.

task-3122670

closes odoo/odoo#114598

X-original-commit: 36fb7654b785888f100d5163e6cebd788c3c042a
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-03-07 19:04:18 +01:00
Kevin Baptiste 5ee8d8fe8e [FIX] hr_holidays: validation of multi-employee leaves for officer
An employee with time officer access right would receive the error "You
must be False's manager to approve this leave" even if they were manager
of all the employees.

Now the error message will list all the employee's the user is not
manager of, and it will properly check that the user is manager of all
of them.

task-3220920

closes odoo/odoo#114591

X-original-commit: 76f762008b34ed1322ab318ec3829d038ac8bbe4
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-03-07 19:04:15 +01:00
Benjamin Vray acedfc6882 [FIX] website: fix scroll table of content
This commit fixes two bugs with the table of content snippet:

- Before this commit, the scrollspy position for the table of content
navbar was incorrect in fullscreen or edit mode due to the calculation
being based on the presence of the main navbar, which is not present in
those modes.

- Before this commit, when the table of content navbar contained enough
elements to exceed the height of the page, the bottom elements were not
accessible without first scrolling through the entire table of content.
This commit addresses this issue by adding a scrollbar to the navbar,
allowing for easier access to these links.

opw-3115597

closes odoo/odoo#114569

X-original-commit: e5d826e03be1fe8c617ef9a8bb8169ad196657fd
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-03-07 19:04:10 +01:00
Aaron Bohy 14d74a1d65 [REF] web: tests: remove legacy action manager tests
Those tests check that we do not leak legacy Widget instances.
However, as the form/list/kanban views and fields have been
converted to owl, no Widget instance is created anymore by those
tests.

closes odoo/odoo#114577

Signed-off-by: Georis François (fge) <fge@odoo.com>
2023-03-07 18:03:27 +01:00
sofiagvaladze 2a4795d3e2 [FIX] hr_contract: proceed cron action even when ValidationError occurs
The method update_state is called from cron. When the contracts are
updated couple things are checked. There are constraints set that can
throw ValidationError. As a result, none of the contract states are updated.

In this PR we do the following:
In case the ValidationError occurs when we run the cron, we update
contracts that can be updated, and silently pass the invalid contracts.

task - 3069480

bloupbloup

closes odoo/odoo#114566

X-original-commit: bce0d7d0f11d46c671bc2b902d17d80febeefa5f
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2023-03-07 18:03:19 +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
Benjamin Vray 45118a3fcf [FIX] web_editor: fix customize panel backdrop position
Before this commit, the customize panel backdrop did not fully cover the
customize panel when the vertical scrollbar was scrolled to the bottom.

Steps to reproduce the bug:

- In website edit mode, add a table of content snippet to the page.
- Add a three columns snippet within the table of content.
- Click on an image in the three columns snippet.
- Scroll the customize panel to the bottom and open the filter selector
of the image.
- Bug: the backdrop does not fully cover the customization panel.

task-3090626

closes odoo/odoo#114517

X-original-commit: 672a8cb1632b2e61b87834b47e16e3b2f1c57ad9
Signed-off-by: Outagant Mehdi (mou) <mou@odoo.com>
2023-03-07 18:03:10 +01:00
Odoo's Mergebot a53e2d871d [FW][MERGE] mail: add tests and improve attachment management in MC / readonly modes
PURPOSE

Fix and add tests for posting messages in multi company environment as well
as posting on readonly documents when greated by '_mail_post_access'
class parameter.

SPECIFICATIONS

Fix multicompany issues which are generally trying to answer a ping on a record
users cannot reach due to MC ACLs.

Effectively support '_mail_post_access' parameter at chatter level. On readonly
documents it is currently always deactivated while it should respect that
parameter. Some record models allow to post without write access.

Add tests to justify the various access rights avoided using sudo, notably

  * check attachments: attachments check is stricter than message check
     as it always require at least read and often write access on docuemnt.
    This does not work when posting on unreachable documents due to
    answering a notification;
  * check document access: sudo some document value fetch (like display
    name) as access is granted at message creation level and should not
    crash due to a missing read access on document;

See sub commits for more details.

Task-3213982 (Mail: fix 'multi-company' post support)
Task-3178885 (Mail: fix 'readonly' post support)

closes odoo/odoo#114511

Forward-port-of: odoo/odoo#114464
Forward-port-of: odoo/odoo#114175
Related: odoo/enterprise#37863
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-07 18:03:04 +01:00
Thibault Delavallée acfb07e79c [FIX] mail: effectively allow to post when notified on unreachable documents
When being notified on a document they cannot read users should be able to
post, as indicated in message ACLs. However some data preparation prevents
from doing it as ACLs are raised on document level.

In this commit we sudo the call to display_name to populate record_name when
not given. Indeed access is checked at message level so no need to crash in
this specific use case.

Task-3213982 (Mail: fix 'multi-company' post support)

X-original-commit: odoo/odoo@2d73c61136
Part-of: odoo/odoo#114511
2023-03-07 18:03:04 +01:00
Thibault Delavallée 452ca009e3 [FIX] mail: allow to update main attachment
When replying on a document they cannot read (notably when being notified)
ACLs raise when trying to check if 'main_attachment_id' is already set before
updating it. This is fixed in this commit. This fixes the recently introduced
'test_post_wo_access' test that does not pass without this fix.

Note that the update of 'main_attachment_id' was already done in sudo. As all
read or update access is now done in sudo, better call the whole method as
sudo in 'message_post' and let '_message_set_main_attachment_id' works on
the given record set environment.

Task-3213982 (Mail: fix 'multi-company' post support)

X-original-commit: odoo/odoo@0375bb227a
Part-of: odoo/odoo#114511
2023-03-07 18:03:03 +01:00
Thibault Delavallée 37c100a87d [FIX] mail: delegate document attachment check to message when posting
When creating a <mail.message> with attachments a manual check is done on
given attachemnts to ensure user have rights to read them. Indeed otherwise
user could simply give attachments from a protected document when posting
on a document he can read and try to gain information about those.

However sometimes user can post and create messages without having read
access on the document, e.g. when being notified and answering in a multi
company environment.

In this commit we consider that creating a message with attachments linked
to the same document does not require an additional check for attachments.
The check is performed at message level (see its custom 'check_access_rule')
and is considered sufficient. However attachments linked to other documents
using model and res_id are still checked.

This fix helps greening the 'test_post_wo_access' test recently introduced.

Task-3213982 (Mail: fix 'multi-company' post support)

X-original-commit: odoo/odoo@bab0549904
Part-of: odoo/odoo#114511
2023-03-07 18:03:03 +01:00
Pierre-Yves Dufays 5c5282ba15 [FIX] {test_}mail: fix send message button activation (_mail_post_access)
The attribute _mail_post_access='read' on a model allows user with read only
access on the model to post a message. It was not taken into account on the
client side, making the send message button disabled for user with readonly
access on such model. This commit fixes this issue and now correctly takes
into account that class parameter.

Task-3178885 (Mail: fix 'readonly' post support)

X-original-commit: odoo/odoo@d2b8612cf7
Part-of: odoo/odoo#114511
2023-03-07 18:03:03 +01:00
Pierre-Yves Dufays e725ba761f [FIX] mail: allow post on model with readonly access when authorized
The attribute _mail_post_access='read' on a model class allows to post on that
model with readonly access. But when providing an attachment such action was
throwing a security error due to the check done on the attachment. Indeed
adding an attachment to a model is modifying that model so the write access
is needed. To solve this problem, we add the attachment in sudo in the
'_message_post_process_attachments' method.

Justification

This is an internal method and we have stated in its documentation that it is
the caller responsibility to check the rights. Actually, the checks are done at
mail.message creation (to which the attachment are linked) by the override
of 'check_access_rule' which calls '_get_mail_message_access' which takes into
account that attribute (_mail_post_access). Moreover sudo is already used
in '_message_post_process_attachments' to link existing attachments. Here we
add a sudo for the new attachments as well.

Note

This fix allows the test 'test_post_with_read_access' to pass (located in
test_mail/tests/test_mail_multi_company.py). But it is currently hard to
reproduce functionally as

  - answering an email works as it is executed by the cron;
  - replying in discuss trigger a multi company error no matter there is an
    attachment or not (so it is another problem);
  - sending a message (with readonly access) on a thread from the interface
    works without this fix because the attachment are created beforehand and
    the part that handle already existing attachment is already in sudo;

Multicompany issues will be solved in the next commits.

Task-3178885 (Mail: fix 'readonly' post support)

X-original-commit: odoo/odoo@f9a6f7f7ce
Part-of: odoo/odoo#114511
2023-03-07 18:03:03 +01:00
Thibault Delavallée ae791c7a7a [FIX] mail: correctly check 'is_thread_notification' when notifying
Due to misplaced / missing parenthesis some corner cases were not correctly
computed, notably when having Falsy values and using the fallback. Also
it was returning the thread ID instead of a boolean. This was not harmful
but better return a boolean "is a thread notification".

Task-3046371 (Mail: Better Language Support in Composer)

Part-of: odoo/odoo#114511
2023-03-07 18:03:02 +01:00
Pierre-Yves Dufays 0a527ace82 [IMP] test_mail: add tests to justify sudo when writing attachment
Add message post with attachment test on record of another company than the
user company but for which the user has readonly access on. The goal is to
justify the sudo added in mail_thread:

  - in '_message_post_process_attachments' method to create attachment linked
    to the record (the creation of attachment linked to a record verify the
    right to write to the record, so in readonly we need a sudo);
  - in '_message_set_main_attachment_id' method to link the main attachment to
    the record. Here we write directly on the record for which we only have
    readonly access, so a sudo is needed. Here the attachment is already linked
    to the model and we only "tag" it has main attachment (see odoo/odoo#30659)

Task-3178885 (Mail: fix 'readonly' post support)

X-original-commit: odoo/odoo@8486c7ee05
Part-of: odoo/odoo#114511
2023-03-07 18:03:02 +01:00
Thibault Delavallée 5edb04d491 [IMP] test_mail: add posting tests in multi-company environment with attachments
Purpose of this commit is to add tests to post in record user cannot access
especially in multi company environment.

Main observations

  * ACLs are checked when fetching record_name, then when fetching reply_to
    information, adding a bit of ACLs noise in the process;
  * check_access_rule of mail.message is called when creating the message
    (which is the real protection);
  * posting on a document user cannot see is possible when they have been
    notified of a parent message. Use case is: answer a ping, even on a
    document non readable, should always be doable. However it currently
    crashes notably due to attachments check, who always require the read
    access on the related document even if the message is authorized;

In this commit we also move other tests about multi_company in the right
file (and add a test flag) in order to have all of them in the same place
easing debug and testing.

Task-3213982 (Mail: fix 'multi-company' post support)

X-original-commit: odoo/odoo@5656f4d20d
Part-of: odoo/odoo#114511
2023-03-07 18:03:02 +01:00
Thibault Delavallée 248e0e495b [IMP] test_mail: add composer tests for email layout support and translation
Purpose is to add some tests about email layout support in both comment and
email mode, as well as language support in those two modes. They are added
in a test targeting a complete template usage, testing globally the results
(outgoing notifications or emails, buttons, language, recipients, ...).
Posting in multi-languages environment with notification layout is also
tested. Finally a test about reply-to is moved into its own subtest to
avoid polluting core template tests. Other low level details should already
sufficiently tested. Normally.

Main observations

  * translations are quite broken in mass mode (either batch comment either
    mass mailing). Indeed translations are fetched based on <mail.compose.
    message> body and subject fields, which are probably not translated
    as they are linked to a transient model. Real translations are stored
    at <mail.template> level when users translate their templates;
  * layout translation is partly supported in comment mode, due to a small
    context-based hack. However access buttons are not translated and some
    use case (like using a 'res_domain') are not supported;
  * mass_mail mode does not support layouting at all;
  * when posting manually ('message_post') current users' language determines
    the language of notification email layout e.g. a user using Odoo in French
    will send a french layout to all followers, whatever their language and
    whatever the language of the post (which is not known as user input);

Most of those use cases will be fixed soon.

Also update some query counters while passing by.

Task-3046371 (Mail: Better Language Support in Composer)

Part-of: odoo/odoo#114511
2023-03-07 18:03:01 +01:00
Thibault Delavallée 3147d09b90 [IMP] (test_)mail: improve test tooling
Allow to return <mail.mail> records and found outgoing emails when using
asserts. It eases doing checks in some specific tests e.g. checking
notification layout usage in emails. Indeed this is quite low level and
does not really deserves its own assert tooling methods.

Update tool method generating attachment data to ease name tweak when required
in tests.

Also update query counters, and fix a test not running locally.

Task-3046371 (Mail: Better Language Support in Composer)

X-original-commit: odoo/odoo@b32d937b37
Part-of: odoo/odoo#114511
2023-03-07 18:03:01 +01:00
Hubert Van de Walle (huvw) 9b136383c2 [FIX] web,mrp,stock: don't call action buttons for virtual records in x2manys
Steps to reproduce
==================

- Make sure the "Work Orders" setting is enabled
- Manufacturing > Products > Bills of Materials > New
- Select a random product
- In the Operations tab, add a line
- Type something in the Operation field
- Set the workcenter to Assembly line 1
- Save and close
- Click on the "Show Instructions" action button

```
Traceback (most recent call last):
  File "/home/hubert/src/16.0/odoo/odoo/models.py", line 5108, in ensure_one
    _id, = self._ids
    ^^^^
ValueError: not enough values to unpack (expected 1, got 0)
```

Cause of the issue
==================

The action is called without in id because the record is not yet created

Solution
========

The button should display a warning in x2manys when the record is virtual.
This was actually the case before Odoo 16 but there was an option on the
button `options='{"warn": true}'`. With this commit, it will be the
default behavior.
We also remove this option from the xml since it isn't used.

sentry-3950549982

closes odoo/odoo#114505

X-original-commit: 9fc0424a4450923aa8582bdb6766e1b19cb68546
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
2023-03-07 18:02:53 +01:00
Maximilien (malb) aa14ae958b [IMP] hr_expense: remove depends
Before this PR when uninstalling hr_contract, expense was uninstall automatically because of the depends, the purpose of this task is to remove the depends.

closes odoo/odoo#114120

Task-id: 3203717
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
2023-03-07 18:02:47 +01:00
rhe-odoo f100e021ce [FIX] pos_Loyalty: fix product loading
Before this commit, when loading the pos with pos_loyalty, even if limited product was activated, all the products were loaded to make sure that we could apply rewards.
Now, we don't load all the products but we only load the rewards by default.

closes odoo/odoo#114021

X-original-commit: 60e7cdee62cf6b19ce0b26f2c7cbe708f74a806e
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2023-03-07 18:02:45 +01:00
FrancoisGe 838f568e87 [REF] web: Trigger events on the model itself
In the model, we trigger events RELATIONAL_MODEL:NEED_LOCAL_CHANGES,
RELATIONAL_MODEL:WILL_SAVE_URGENTLY and RELATIONAL_MODEL:FIELD_IS_DIRTY
on env.bus. That means that if we have two instances of the model in //
(e.g. two views, or two Record components, or a mix...), their fields would listen and react to events
triggered for another model. Trigger those events on the model instead,
as it is an EventBus.

Because the events are directly triggered on the model, we can remove
"RELATIONAL_MODEL:".

Part of task: 3179751

closes odoo/odoo#113880

Related: odoo/enterprise#37727
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-07 18:02:42 +01:00
dasz 8451eabb67 [IMP] hr: focus employee smart button on main flow
The current smartbutton is Employee(s) and it redirects to kanban view by default, no matter how many
employees a user / partner has. 9 out of 10 times a user / partner only has one linked employee, this
change renames the label to 'Employee' and redirects to the form view if there is only one employee
if there are more, the previous action is called

linked upgrade: odoo/upgrade#4363
this closes odoo/odoo#111439

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-03-07 18:02:37 +01:00
Rohitkumar (roku) 99b09bcd42 [IMP] hr_fleet: improve the employer On/Offboarding plan activities
PURPOSE:
Companies want to have a better integration, we need to focus on the On/Offboarding process,
 to find automation and something to show to our customers.

In this commit, we add the "Fleet Manager" in the responsible list of the activities
generated from a plan.

Case 1:
 If employee is not linked with fleet, `Employee XXX is not linked to a vehicle`
 this  warning will be appeared.

Case 2:
 If employee linked with  fleet  but doesn't  fleet manager set  on fleet,
`Employee's vehicle XXX is not linked to a fleet manager.` this warning will be appeared.

task-3081261

closes odoo/odoo#108892

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-03-07 18:02:31 +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
william e7df30a565 [IMP] account{,_sequence}: merge
This module was added in stable but was never intended as a separate
module.

closes odoo/odoo#106413

Related: odoo/upgrade#4073
Related: odoo/enterprise#37844
Signed-off-by: Josse Colpaert <jco@odoo.com>
2023-03-07 18:02:19 +01:00
Zelong Lin 0cc3b3e6d3 [FIX] mail: portal user access error on init
closes odoo/odoo#114568

X-original-commit: bccdf65192140308d4661482a9dcb431cba8126a
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-03-07 16:56:48 +01:00
Yolann Sabaux f091c5d701 [FIX] account: prevent wrong floating representation of currency
Steps to reproduce:
- In Journals/Bills/Advanced activate "Lock post entries with hash"
- Create a purchase tax of 17%
- Create a bill with a product of a cost of 30 and apply the "17%" tax
- Post it
- Export the data inalterability check report

Issue:
"Corrupted data"

Cause:
In python we have a reprentation issue
```
>>> 30*0.17
5.1000000000000005
```
We define the hash string during the `_compute_string_to_hash` at the
move creation. The issue is, at that time, the move_line tax debit
is not rounded.

Therefore, when we print the report, we take the `move.line_id.
debit` from the db which is rounded and equal to '5.10' and compare
it to '5.1000000000000005' which gives a different hash

Solution:
Implementing a V3 version that uses `repr` for monetary fields.

opw-3072693

closes odoo/odoo#114567

X-original-commit: cfd71892aabf1510273b28032ff8f2d4cfd4d1f7
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Yolann Sabaux (yosa) <yosa@odoo.com>
2023-03-07 16:56:45 +01:00
Adrien Widart (awt) 3e0e643212 [FIX] sale_{stock,mrp}: repost inv with cogs
To reproduce the issue:
(Also need: account_accountant,purchase)
1. Setup a product P
   - Storable
   - Category:
     - FIFO + Auto
2. Process a PO with 1 x P at $10
3. Process a PO with 1 x P at $50
4. Create and confirm a SO with 1 x P
    - Because of FIFO, the value of the delivered product is $10
5. Process the delivery
6. Post the invoice
7. Add credit note
   - Credit Method: Full refund and new draft invoice
8. Post the second invoice

Error: The cogs are based on the second received product ($50), they
should rather be based on the delivered one

When computing the anglo-saxon unit price of the product, we consume
the outgoing SVLs, and we consider the already-invoiced quantity.
Here is the issue: we pretend that this quantity is 1, because of
the first invoice, but this should be balanced with the quantity of
the credit note

OPW-3109789

closes odoo/odoo#114564

X-original-commit: e46d68562c1ec55b7838f6854c1d26f56bec9bc6
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2023-03-07 16:56:43 +01:00