Commit Graph
537 Commits
Author SHA1 Message Date
Julien Alardot (jual) 11a0f8fab7 [FIX] hr_expense: Fix currency_rate handling
The desired flow of currency rate in expense is as followed:
- (default) Use Odoo currency rate
- Allow the user to set a custom rate (to include fees) when changing
  the total amount in company currency
- Revert to the default behaviour when the currency is changed
  or the amount in foreign currency is changed

This aims to fix how currency rate is computed and overridden
- Reorganize all currency rate computation, so it doesn't revert to Odoo rate
  at every compute call
- Deals with a bug where a "total_amount_currency", when changed
  just before calling "action_submit_expenses" would not trigger
  the computation of unit_amount
- Force save when changing currency on expense form view to prevent a bug
  where the first modification of "total_amount_company" would be canceled
  (due to the new behaviour of currency rate computation)
- Removes unit_amount_display from views as it should be removed
  in later versions and is deprecated since 16.0

task-3476569

closes odoo/odoo#137598

Signed-off-by: Laurent Smet (las) <las@odoo.com>
2023-10-05 15:36:24 +00:00
alsh-odoo 8b1c10ae5a [FIX] hr_expense: raise exception if multiple company records selected
This traceback arises when the user selects multi
company records and click on the 'create report' button.

To reproduce this issue:

1) Install 'hr_expense'
2) Create a new company for example 'test'
3) Enable the 'test' company on the right corner
4) Now open 'employees' and change the company of the current user(Mitchel Admin)
   to the 'test'.
5) Open 'Expenses', create a new record, and change the company to 'test'.
6) Fill the required field values and save the record.
7) Now click 'My Expenses/My Expenses to report' and select all the records (Make sure
   'My Expenses' filter is applied)
8) Click on the 'Create Record' button

Error:- "ValueError: Expected singleton: res.company(2, 1)"

On the '_create_sheet_from_expenses' method, the value of 'company_id' is getting
through 'self.company_id.id'.
See:-
https://github.com/odoo/odoo/blob/f910987cb4af84c1e7afabf67f05d4eebc31e765/addons/hr_expense/models/hr_expense.py#L324-L335

But when user selects multi company recordsets
'self.company_id' has multi recordsets.

When 'company_id' is getting value through 'self.company_id.id', because of
'self.company_id' has multiple records, which leads
to the above traceback.

By applying this commit will resolve the issue by raising an exception,
when user selected multi company records to create report.

sentry-4465422743

closes odoo/odoo#136695

X-original-commit: 32cb39c9f533820b5558d739d993199a9541f779
Signed-off-by: de Wouters de Bouchout Jean-Benoît (jbw) <jbw@odoo.com>
Signed-off-by: Altaf Shaik (alsh) <alsh@odoo.com>
2023-09-28 01:51:37 +00:00
Andrea Grazioso (agr-odoo) 0ac4f54e4e [FIX] account,hr_expense: double base line amount
Create an expense sheet (report)
Add 2+ expenses with 10% included tax to the same employee
Approve expenses and post journal entries
Bill will be created
Go to the tax report
Group by "Tax > Account" or "Account > Tax"

Issue: Bill line will have the tax basis calculated incorrectly
This occurs because the bill will have 2 separate tax line and the query
 does not handle this case

opw-3510371

closes odoo/odoo#136694

X-original-commit: 2ed464bc6bf4fa35e1ad2704ed9db71789c39257
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Andrea Grazioso (agr) <agr@odoo.com>
2023-09-28 01:51:36 +00:00
Gorash ba1a5509fa [IMP] base: Remove context dependencies from get_views method
In this viewtiverse, the heroes remove the context dependencies for
`get_views`, from the views and python fields (such as domain). To reduce
inconsistencies and the number of rpc.

Current issues:
* There may be inconsistencies in views at the JavaScript level. Some
overrides modify the behavior of get_views or domains on fields via
context keys, therefore by changing the action, the rendering may be
different. However, these views are cached. However, the cache key
(Javascript) does not reflect the entire context, and requires additional
post-processing from the server.
* Multiple rpc for the same rendering. get_views being dependent on the
context, as soon as it changes, a new rpc is performed. In most cases,
when JavaScript needs the same view, there is no change depending on the
context, the rpc is useless.
* Inconsistency when rendering subviews, some views could be different
depending on the context, this context can be modified in the view itself
via the context attributes. However, the JavaScript client does not redo
an rpc for each change of these sub-contexts. Therefore the result may be
inconsistent.

Solution:
Limit as much as possible the number of context keys provided when calling
get_views, and use the context provided as a cache key. The authorized
keys are 'lang' and '*_view_ref'. For the cache key, options are added in
the get_views method.
Instead of using the context, it is inserted into python expressions.
This will be evaluated by JavaScript and thus avoids inconsistencies.

task-3414108
task-3414068

closes odoo/odoo#135145

Related: odoo/enterprise#47584
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-09-21 16:52:10 +00:00
Julien Alardot (jual) 87a0b760db [FIX] hr_expense: recompute expense currency
Fix a corner case when the expense currency doesn't update when a cost is added to the product

Steps to reproduce:
- Create an expense in a foreign currency
- Add a cost to the expense product

Before fix:
Unit amount currency stays in foreign currency

After fix:
Forces expense currency to
 company currency

task-3455446

closes odoo/odoo#135570

X-original-commit: 67901a4429c69fbba96c32af5d8f58aff54f0be5
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Julien Alardot (jual) <jual@odoo.com>
2023-09-15 08:08:35 +00:00
Ali Alfie (alal) 1d25e75241 [IMP] hr_expense: add attachments from expense to journal entries
This commit adds a copy of the attachments from the expense report to the created journal entry.

task-3443042

closes odoo/odoo#132955

Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2023-09-14 18:09:50 +00:00
Maximilien (malb) 49d6bdb675 [IMP] hr_expense: expense report
This pr aim to improve the pdf of the expense report. we have changed the design
 of the header of the report, the table and also added an annex with the
 different attachments.

 For the attachments, when it's a pdf it's simply merge to the actual pdf but
 when it's an image we use a new template to display the name of the expense
 link to that image.

closes odoo/odoo#133611

Task: 3443413
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
2023-09-14 15:50:16 +00:00
Raphael Collet 109935dbc1 [REM] *: discard old implementation of onchange
Part-of: odoo/odoo#133049
2023-08-31 05:11:44 +00:00
Hamza (hisl) d40d530a91 [FIX] hr_expense : remove the default_partner_bank_id
If we try to register payments for multiple expenses with multiple bank accounts from the expenses app, there is a traceback regarding the bank ids, as a singleton value was expected. We can do the same process from the vendor bills and the payment will be registered fine.

1. Create two expenses against two employees having different bank accounts.
2. Approve and post both of them.
3. In the 'To Pay' expense list, select the both expense reports and click on register payment.

Current Behaviour:
A traceback is thrown that a singleton value was expected. This is because there were multiple bank accounts against that payment.

Expected Behaviour:
The payment should be registered without any problem.

OPW-3272500

closes odoo/odoo#132774

X-original-commit: c7f62dca74e89659230ebc7a02d290cd62dd8323
Signed-off-by: Anh Thao Pham (pta) <pta@odoo.com>
Signed-off-by: Hamza Islam (hisl) <hisl@odoo.com>
2023-08-23 11:13:04 +02:00
Gorash 75a105f46a [REF] base/all: Update modifier syntax: remove 'states' from fields
These changes are made as a result of simplifying attrs and 'states' in
views. However, they should have remained in a separate commit. When
applying the script making the xml changes (used later for the migration
script), the script checked the definition of the python fields in order
to convert the information into a python expression. Therefore, this
commit is not applied when the script is applied to xml changes.

During this attribute deletion pre-existing errors were found. Part of
the code was using the boolean values of 'states' and another part of
the code was not. The behavior could therefore be different (in cases
where readonly on the field had the same value as the ballan in
'states').

Following the deletion of 'states' and without the application of the
view migration, the js tests (tower) were no longer functional. Tests
using the Form view suffered the same effect. There are few tests that
had to be adapted, including two tests in business accounting (updated
by the accounting team). A test for column_invisible did not work. Test
checking if the test system triggers an error if we try to write on an
invisible field. It turns out that Form was testing on the value of
invisible but not taking into account if the column was invisible. The
test system fix is applied separately because there were a lot of tests
that were incorrect.

Part-of: odoo/odoo#104741
2023-08-18 09:49:11 +02:00
SaddemAmine 5bd4120928 [IMP] hr_expense,project_sale_expense: Clarifying user error when partner is missing
When the partner is missing, the error message is not clear enough.
This commit adds a new error message to clarify the issue.

Task ID: 3438559

closes odoo/odoo#132029

X-original-commit: 5be853ebb6da19a4f0a147944995583e234bf1b9
Related: odoo/enterprise#45779
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Naceur Amine Saddem (sana) <sana@odoo.com>
2023-08-16 17:47:45 +02:00
Julien Alardot (jual) 7e1855f5b1 [FIX] hr_expense: Fix expense unit_amount computation
This fixes a bug when you change currency on an already saved expense
due to the fact that the unit_amount is never recomputed but used to
generate the move line balance

Step to reproduce:
- Duplicate an existing expense paid by an employee
- Change currency + save
- create -> post expense report
- The total amount and remaining amount do not match

closes odoo/odoo#131709

closes odoo/odoo#131818

X-original-commit: e0bceb37ee7656c37ab99a4a4bb3b71d85199e1b
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Julien Alardot (jual) <jual@odoo.com>
2023-08-16 16:05:51 +02:00
niyasraphy 933856d669 [FIX] hr_expense: warning in log on posting expense je
before this commit, on posting journal entry from
the expense it shows a warning in the log.

*warning in the log*

Action {6: account.move(49,), 'type': 'ir.actions.act_window_close'} contains custom properties 6. Passing them via the params or context properties is recommended instead

after this commit, on posting journal entry
warning wont be displayed in the log

closes odoo/odoo#131444

X-original-commit: 00b09c548b0a01191bea20584193da6a02681a36
Signed-off-by: Laurent Smet (las) <las@odoo.com>
2023-08-16 16:05:26 +02:00
Andrius Laukavičius 61bf9ae3bf [FIX] hr_expense: improve computed field performance
If you have large amount of product.template records (e.g. over 40k),
`hr_expense` module can't be installed as you would get MemoryError. It
would consume all memory while computing `can_be_expensed` field.

For that, using `_auto_init` to make it less of a memory hog.

closes odoo/odoo#131954

X-original-commit: 1138a24760ad57cb9e9895926012d269b4e2bfb0
Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
2023-08-14 20:24:47 +02:00
Thibault Delavallée 638e0f658d [REF] mail, various: cleanup alias usage
Cleanup alias usage and definition. Prepare code to ease future changes and
improvements. Notably

  * add a 'alias_email' computed field on the mixin allowing to have the
    complete alias email when set, and False in case it is inactive or linked
    to an inactive alias domain;
  * remove unnecessary alias_id field definition when just the help differs
    from the standard definition coming from the 'mail.alias.mixin';
  * use fields coming from 'inherits' instead of using alias_id and its sub-
    fields; notably use 'alias_display_name' and 'alias_email' fields;
  * remove useless custom code and management;
  * improve alias parameters support code in configuration parameters;

Task-3453343 (Mail: Cleanup Alias Usage)
Prepares Task-36879 (Mail: Support MultiCompany Aliases)

Part-of: odoo/odoo#130632
2023-08-09 17:04:26 +02:00
Julien Alardot (jual) 029a1ab2cc [FIX] hr_expense: Fix rounding mismatch
When paid by the company in another currency
with at least one tax, there may be
a rounding difference between the move and the expense

task-3390444

closes odoo/odoo#130397

X-original-commit: c889dcc83daeaccb09b7692e430e232778fc031d
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Julien Alardot (jual) <jual@odoo.com>
2023-08-02 06:18:39 +02:00
Julien Alardot (jual) a1d92ddd4a [FIX] hr_expense: Fix reports and moves accounting date
The accounting date on the report sheet and the linked
moves are always set at the current date

We want the accounting date to be the expense date,
or the most recent expense date when possible

task-3390444

X-original-commit: f1d03364230058f77f23bf0083e2757c8cd98e9a
Part-of: odoo/odoo#130397
2023-08-02 06:18:39 +02:00
william-andre 0479b2b594 [IMP] account,*: manage subsidiary companies
Allow sharing records between company
* accounts
* taxes
* fiscal positions
* products
* ...and some related models

These records can be read and used in children companies.

This can be used to
* have different branding for different businesses
* allow more complex security rules
* consolidate branches differently
* manage different tax reports with different tax ids in the same
  country

task-3371677

closes odoo/odoo#125642

Related: odoo/enterprise#43215
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2023-07-20 11:49:06 +02:00
Julien Alardot (jual) 495546de79 [IMP] hr_expense: Allow user to fix currency rate
This allows the user to set the total_amount_company

Currently, when an employee set the amount
in a foreign currency, Odoo doesn't let the employee
register how much they have been charged after
conversion in their own currency
(assuming that it's the company one)

After this if the user changes the total_amount_company,
the new rate is computed and used

Task-3255758

closes odoo/odoo#127246

Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2023-07-15 04:01:01 +02:00
Yosua Nicolaus 41d56e2e98 [IMP] expense: default expense category on scan
Description of the issue/feature this PR addresses:
- Expenses are automatically created when uploading or scanning receipts. This is a feature often used by employees who have a lot of tickets and upload them in batch. The expenses created have a random category (product_id) specified. Companies may however want to specify the default category for accounting or management purposes. They are currently unable to do so.

Current behavior before PR:
- Companies can't specify default category for scanned/uploaded expenses

Desired behavior after PR is merged:
- In the Expenses setting, combine the "Default Journals" and "Payment" block into one and name the new block "Accounting"
- Add new setting in Expenses for specifying default category for scanned/uploaded expenses
- If that setting is set, use the value inside it for the category field of new scanned/uploaded expenses

closes odoo/odoo#124205

Task-id: 3354763
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2023-07-13 16:52:52 +02:00
Julien Alardot (jual) 81fe11fabb [IMP] hr_expense: Split company payments per expense
When an expense sheet move is created, there is only one
outstanding line, but it is usual to pay separately.
That makes the reconciliation step harder.

This makes sure one move is created per expense

Task-3328877

closes odoo/odoo#126805

Related: odoo/upgrade#4873
Signed-off-by: Laurent Smet (las) <las@odoo.com>
2023-07-13 14:47:30 +02:00
Yolann Sabaux b970caef22 [FIX] hr_expense: set correct account_id on upload
Steps to reproduce:
- On the expense product by default, set an account_id
- Upload an expense

Issue:
The account_id that we set is not the one on the newly created expense

Cause:
We don't give any account_id during creation. Therefore, the account_id by default is set:
https://github.com/odoo/odoo/blob/7bcd64c51b2e87ece462c75a528c9ad6e1601633/addons/hr_expense/models/hr_expense.py#L31-L32

opw-3343007

closes odoo/odoo#127891

X-original-commit: c6b048196be92392ee34e50cc7ab13107632b87e
Signed-off-by: John Laterre (jol) <jol@odoo.com>
2023-07-10 16:59:33 +02:00
Yolann Sabaux acc638f80a [FIX] hr_expense: enable change account for no-access users
Commit #2:
Splite the method `_compute_from_product_id_company_id` so each stored field has its own compute method to avoid invalidation issues.

opw-3336796

closes odoo/odoo#126529

closes odoo/odoo#127794

X-original-commit: b64a378aab79ae4b6682ad66902c43a98a6f776d
Signed-off-by: William André (wan) <wan@odoo.com>
2023-07-07 20:24:50 +02:00
Yolann Sabaux 033c446084 [FIX] hr_expense: enable change account for no-access users
Steps to reproduce:
- install Expense and Accounting
- create 3 separate Expense categories ( this will create a related product of 'service' type) with a different Expense account and Vendor tax on it.
- Configuring different Taxes are important to replicate the issue
- Create a 'test' user who has no access to apps
- login a 'test' user and create an expense for one of the categories and save it.
- Update the expense to a different category and click 'submit to Manager'

Issue:
The account_id of the expense is not updated

Reason:
Multiple fields are computed using the same method `_compute_from_product_id_company_id`. The field being read-only=False
https://github.com/odoo/odoo/blob/c38cf4c2038d15890d5d50ec05fd5cb4f9f379b1/addons/hr_expense/views/hr_expense_views.xml#L199
It is protected during the write; that is, considered as user input

Solution:
Duplicate the field is it will not be read-only and put it as invisible
Split the compute method

opw-3336796

X-original-commit: 6664ccba5230d7890964cfe372ca863314f2fad4
Part-of: odoo/odoo#127794
2023-07-07 20:24:50 +02:00
Yannick Tivisse e8c48f824e [IMP] hr: Remove address_home_id field
Improve usability of employee form. It is confusing for end users
to create another record to encode the employee address.

Move all the private information on the hr.employee record itself.

Remove the M2O address_home_id.

TaskID: 3101400
2023-07-05 14:21:28 +02:00
flvr-odoo 729ec65d36 [FIX] account, hr_expense: removing forgotten 'TODO'
This commit remove the forgotten '#TODO: remove in master' that
were forgotten during the FW-port

closes odoo/odoo#125887

Signed-off-by: John Laterre (jol) <jol@odoo.com>
2023-07-04 17:59:42 +02:00
Julien Alardot (jual) 649b6d055d [FIX] hr_expense: fix currencies handling
Allow expenses reports to generate foreign currency
payments and use foreign currency accounts when all
expense lines are of the same currency.
If the report is multi-currency the company currency
is used instead (previous behaviour)

Task-3346458

closes odoo/odoo#126836

X-original-commit: 3d6d36ac5bab95af76776f07e55f286850f22ff9
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Julien Alardot (jual) <jual@odoo.com>
2023-06-30 01:32:58 +02:00
Ryan Cen 2bd6553ea4 [FIX] hr_expense: Add inverse on total_amount to update unit_amount
The customer was having an issue where they would create an expense from an email with the wrong cost on the expense.
Then when they would try to change the price on the expense record it would seem find all the way up until the journal was posted.

Issue:
When creating an expense from an email the unit_amount is updated instead of the total_amount.
This would cause issues if you had an attachment because when you would attempt to change the amount through the front-end this unit_amount would never get updated because it was set and there was an attachment (line 265).
However, when you would create a journal entry from this expense, because it has the unit_amount != 0 it would provide the unit_amount instead of the total_amount.
Thus propogating the original number from the email even if it was updated between the time of posting and the creation of the expense from the email.

Solution:
Implement an inverse function on total_amount that will update the unit_amount to total_amount_company.
This will cause the unit_amount to stay up to date with the total_amount while also taking into account currency.

opw-3286372

closes odoo/odoo#126388

X-original-commit: c2588824edc732bea40b1a8f6e5248b3d318b361
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2023-06-26 22:15:20 +02:00
Andrea Grazioso (agr-odoo) 4caddf1787 [FIX] hr_expense: due date conflict with payment terms
Have an employee with payment terms set in the contact form
Create an expense for $100 for the employee
Create the expense report > Submit to manager > Approve > Post journal
entries

Issue: The bill due date is manually set to the Accounting Date.
This is not consistent with the Payment terms applied on the
bill

opw-3298981

closes odoo/odoo#124542

X-original-commit: d363aa12429768e63d0f9def7006101983fd0adc
Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
Signed-off-by: Laurent Smet <las@odoo.com>
2023-06-12 12:41:19 +02:00
Ali Alfie (alal) 10d0805c94 [IMP] hr_expense: include paid by company expenses in status bar
Before: in the "My Expenses" statusbar, only expenses paid by the employee were shown.

Now: for the "to submit" and the "under validation" states, we show expenses paid by the employee AND the company. For the "to be reimbursed" state, we ONLY show expenses paid by the company.

task-3319115

closes odoo/odoo#121627

Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2023-06-09 12:21:47 +02:00
Guillaume (guva) e2500e26df [FIX] hr_expense: expense name on pdf upload
When uploading a PDF, the expense name is showing
the 1st category of expense instead of the name
of the PDF.

opw-3339756

closes odoo/odoo#123608

X-original-commit: 7ec2bb68067e49ea5ab2bbd6598264ccb78cfd70
Signed-off-by: William André (wan) <wan@odoo.com>
2023-06-02 23:39:32 +02:00
Julien Alardot (jual) 8f9ca3e29e [IMP] hr_expense: Split outstanding lines per expense
When an expense sheet move is created, there is only one
outstanding line, but it is usual to pay separately.
That makes the reconciliation step harder.

This makes sure one outstanding line is created per
 invoice_line and then if only one payment is made
 it can go through the same process as a batch payment

Task-3292188

closes odoo/odoo#120450

Related: odoo/upgrade#4625
Signed-off-by: Laurent Smet <las@odoo.com>
2023-05-08 22:39:52 +02:00
flvr-odoo 30b283fe7d [FIX] hr_expense: prevent linking of expense with no perm
Previously, a user could link his own expenses to a expense sheet
of someone else.

This would not be allowed upon creation but was allowed when updating
the values of the expense.

This commit add a simple check at the beginning of the write()

closes odoo/odoo#120661

X-original-commit: 884510b1496e0a0eba7171f4ef4bb749856cb1bf
Signed-off-by: Vranckx Florian (flvr) <flvr@odoo.com>
2023-05-05 14:55:10 +02:00
det 3cdec23ab3 [FIX] hr_expense: foreign currency rework
Bugprovemnts when multi-currency is enabled, alows to
enter expenses in activated currencies. The expense is
directly converted to the company currency using same day'
rate:

- do not reset amount on currency change

- rework of the views, to show currency and related amount only
when relevant.

- remove dead code: amount_residual on expense

closes odoo/odoo#114528

Task-id: 3191597
Related: odoo/upgrade#4443
Signed-off-by: Laurent Smet <las@odoo.com>
2023-04-28 16:04:08 +02:00
Andrea Grazioso (agr-odoo) ff35bf57a7 [FIX] hr_expense: force company currency on company payment
Activate Multicurrency (USD company curr, EUR foreign currency, 1 EUR = 2 USD)
Have a Bank account in both currencies.
Create an expense of 100€, paid by company
Create report, set EUR journal as Bank Journal
Send To manager > Approve > Post Journal Entries
Open created payment

Issue:
- Payment amount is 200€
- In journal items, amount_currency and balance is 200$

Do the same with "Paid by employee".
Open the vendor bill

Issue:
- Invoice lines are expressed in the wrong currency

opw-3269009

closes odoo/odoo#119490

X-original-commit: 5eab4469d87a4d1ca80916ca5790691ffed68e38
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
2023-04-24 23:49:12 +02:00
Rémy Voet (ryv) 234db70d86 [IMP] *: Use the new API of _read_group for backend use
Part-of: odoo/odoo#110737
2023-04-19 21:58:27 +02:00
Martin Trigaux 69f911d994 [IMP] *: enforce usage of Markup in mail
When using message_post, the body format must be explicitly specified.
If html is expected, a Markup object should be used.
If text is given, the content will be escaped.

Before this PR:
message_post was unaware if the content of a message was HTML or
text. This lead to multiple situation where the content was
incorrectly considered as HTML and led to display errors.
In
  self.message_post(body="Hello %s!" % self.name)
if the name contained HTML, it would be evaluated.

In
  self.message_post(body="Contact Raoul <raoul@caramail.be>")
the email would not be displayed as considered as unknown HTML and
discarded by the sanitizer

Now each call must explict the type of content.
Use the escape() helper to properly combine Markup and translations.
It would also be acceptable to use Markup() to wrap a static
translation but escape is better as one can not guarantee the content
of a translation.

closes odoo/odoo#111850

Related: odoo/documentation#3612
Related: odoo/enterprise#36728
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-13 16:39:48 +02:00
det f3569d1c9c [FIX] hr_expense: amount in needed terms
Steps to reproduce:

- set early_pay_discount_computation on company to mixed.
- create an expense with taxes
- try to post entries from the expense
> traceback

This commit adds the missing key in the needed_terms computed
on in hr_expense. We could have bypassed the computation in the
case of expenses but simply adding the key sounds like a more
future-proof solution.

opw-3244294

closes odoo/odoo#118250

X-original-commit: 7922a7db0d840a33a3db54da1a359ac95e61cb7b
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Detry Thomas (det) <det@odoo.com>
2023-04-12 08:05:47 +02:00
Maximilien (malb) 41b39f2a57 [IMP] hr_expense: adding tooltip
Before this PR, the field tax_ids had no tooltip.
Since v16 we now allow the use of all taxes in the expenses module now. But, there is not much mention that price-excluded taxes will be used as price-included taxes.
In the release notes it just mentions that all taxes are usable, but there is no mention of anything else. This seems a bit confusing. Adding the tooltip will help users.

Also adding fresh exported .pot

closes odoo/odoo#117351

Task-id: 3252757
X-original-commit: df28d24699a6bfb4ea142fc07b10c1835d9d4323
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
Signed-off-by: Maximilien La Barre (malb) <malb@odoo.com>
2023-04-05 15:11:17 +02:00
Nicolas (vin) 783733cf33 [IMP] hr_expense: avoid adding wrong expense_line_ids
You cannot validate and expense report having expense_line_ids of
different payment mode.
But so far, it was possible to select these lines, and it would
be blocked upon saving.

We will improve this behavior by extending the domain on the
expense_line_ids field and disallowing to add lines that would lead to
an error later in the process.

It will also correctly handle the creation of new line via the expense
report form view, and add the paid by field as optional hidden in the
view in order to allow to find more easily the expense line that are
causing issues.

task id # 3221780

closes odoo/odoo#116077

X-original-commit: ec18bd414c831a9af67802dcd5d7181ef8d43049
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
2023-03-23 08:01:08 +01:00
det 043dadaa91 [FIX] hr_expense: currency and payable line discrepancy
Explanation:

A rework of hr_expense has been introduced in master and landed in 16.2.
https://github.com/odoo/odoo/commit/f79ff3fb374650670e89f231aaf17bb8d6596c25

There was a need to backport it to 16.0 then 16.1.
https://github.com/odoo/odoo/commit/90affb562962d0dc233526e3f15f5b60f383331d

During the backport;
- a computed fields 'journal_displayed_id' has been introduced and will need to be removed again in master.
- 2 bugs have been discovered:
-- the analytic.account were not created anymore (function not called)
-- the payment terms for expense paid by company could not be modified as a filter was missing

closes odoo/odoo#115650

X-original-commit: 672f4efd2c990ab6eef8f934c41625860b8ded46
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Detry Thomas (det) <det@odoo.com>
2023-03-17 15:02:46 +01:00
Thomas Lefebvre (thle) 3a982de28e [FIX] hr_expense: compute total amount if there is a unit price
Steps to reproduce:
Create an expense by sending an email.
Make sure the product has a zero cost.

Issue:
The expense has no total amount even if
a unit price is detected in the subject of the mail.

Solution:
Compute a total amount if we have a unit price.

opw-3128566

closes odoo/odoo#115620

X-original-commit: eb629fa82cbf592184ed60d0bf309a26a4465b70
Signed-off-by: William André (wan) <wan@odoo.com>
2023-03-16 22:53:59 +01:00
Jeremy Kersten 3eaca8ba16 [FIX] hr_rexpense: expense_sheet_id is not readable for portal user
Missing sudo for portal user on Invoice list.

When portal user go to his portal, to display the list of the invoices
we compute the url via get_portal_url that will call this method
`is_purchase_document` and got a traceback due to missing permission.

Now we call it with sudo to bypass the Access Right error without leaking
any extra information since it is casted as boolean later.

`get_portal_url` -> `record.access_url `-> `_compute_access_url`

account:account.move `def _compute_access_url` -> `filter(is_invoice)`

account:account.move `def is_invoice` -> `is_sale_document or is_purchase_document`

hr_expense:account.move `def is_purchase_document` -> `return bool(self.expense_sheet_id) or super()`

closes odoo/odoo#114424

X-original-commit: 01a91419f906bd8d9248e6376a0246b667218ca2
Signed-off-by: Jérémy Kersten <jke@odoo.com>
2023-03-07 02:00:17 +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
Pierre-Yves Dufays 4cec1e12d8 [REF] various: apply main attachment mixin on models that use the feature
Add mail.thread.main.attachment in the inheritance chain of all models that
use the main attachment feature.

Note that we remove the main attachment from crm_case_15 of the demo data as
crm_lead doesn't use that feature.

Task-2648976

Part-of: odoo/odoo#110734
2023-03-02 12:32:11 +01:00
det f79ff3fb37 [IMP] hr_expense: do not create purchase.receipt
Rework of the hr.expense workflow so that:
- expenses paid by employee generate purchase.order
- expenses paid by company generate entry that look like payments

Main reason being that purchase.receipt are not active by default.
That makes the entry hard to find, holes in sequences, inconsitency
with payment states.

It also remove the refusal of expenses as this was dead / inaccessible code, only reports can be refused.

task-id: 3126550
[community](https://github.com/odoo/odoo/pull/110518)
[enterprise](https://github.com/odoo/enterprise/pull/36090)

closes odoo/odoo#110518

Related: odoo/upgrade#4266
Related: odoo/enterprise#36090
Signed-off-by: Laurent Smet <las@odoo.com>
2023-02-24 10:06:06 +01:00
Victor Feyens be42e8178d [IMP] product,*: privatize price_compute method
This method is not used by rpc calls and wrongly allowed users to read the standard_price
field by calling the method through rpc.

Make it private to reduce its uses and avoid this potential leak of information.

closes odoo/odoo#113234

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-02-21 21:07:34 +01:00
Miquel Raïch 317463fb21 [IMP] *: Remove unnecessary view_type
closes odoo/odoo#110817

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-01-30 19:45:59 +01:00
det 42c1d2a6d3 [IMP] hr_expense: button to register payment on expense view
Before this commit, the user had to go over each expenses to
register a payment.
He now  has the possibility to do so from the expense report
tree view via the "register payment" button.

task-id: 3116195
[community](https://github.com/odoo/odoo/pull/109671)

closes odoo/odoo#109671

Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
2023-01-25 10:18:29 +01:00
Thibault Delavallée 4775bd93a2 [REF] mail: cleanup post with {view, template} wrappers
RATIONALE

Purpose of this commit is to cleanup main post helpers and have a more easy
and understandable way of calling them.

SUMMARY

We now have two main API methods, based on business flow: either posting
on documents, either sending a mass mailing. Indeed those two flows are
different

  * post: create message, then launch notification process by taking into
    account subtype, followers, ...
  * mail: create mails in batch with recipients being based on template or
    given partners. No notifications is involved, only maybe traces if a
    mass mailing is linked

Delegate QWeb rendering to the render mixin (i.e. _render_template_qweb_view)
in order to have a single point to forge evaluation context and re-use
existing rendering code.

SPECIFICATIONS

Main API helpers are now

  * ``message_post_with_source``: (batch) post on records, using an ir.ui.view
    (given a record or its xml id) or a mail.template record (given a record or
    its xml id). When using a template, a composer is called to post on each
    record (as batch post is not yet supported). When using a view, a direct
    call to message_post using the rendered bodies is done, one record at a
    time.
  * ``message_mail_with_source``: send a mass mailing on records, acting like
    invoking the mail composer in mass mode. Same arguments are valid, either
    a reference to a view, either a reference to a mail template.

Other helpers are

  * ``_message_log_with_view``: (batch) log on records, using an ir.ui.view
    to render the body using QWeb (no notification process);
  * ``_message_log(_batch)``: (batch) log on records (no notification process);
  * ``message_notify``: notify partners on records (creating notifications
    specifically for some people while message itself is not displayed in
    chatter);

Code migration

  * ``message_post_with_template`` in "mass mode": use ``message_mail_with_source``
    and set the template record as source;
  * ``message_post_with_template`` in "comment" mode: use ``message_post_with_source``
    and set the template record as source;
  * ``message_post_with_view``: its main usage was to post on a document, in which
    case it generally can be replaced by ``message_mail_with_source`` using
    the view reference as source;

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:34 +01:00