Commit Graph
2988 Commits
Author SHA1 Message Date
Laurent Smet 5c1f28cce4 [FIX] account: Fix dashboard 'Oustanding' amounts with shared outstanding accounts
- Share outstanding accounts between multiple journals
- Create payment for each of them
- Go to dashboard
=> "Outstanding Payments/Receipts" amounts are wrong

closes odoo/odoo#70564

Ticket: 2517499
X-original-commit: 39fb6b2990e5d6fda0d5f12dbd64d26ef77b9d0c
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-05-07 17:06:02 +00:00
oco-odoo 995f6fbb86 [FIX] account: reconciliation models: fix priorities when matching amls from payments
Since the payment refactoring, the structured reference of a payment is stored in its ref field, not payment_reference like for invoices. This caused payments never to be matched with highest priorities, as payment_reference_flag was always false, and only communication_flag could match.

To reproduce:

- Have a reconcile model with match_total_amount=False.
- Create a statement line with communication a1b2c3 for 1000
- Create 3 payments:
> 500, with memo a1b2c3
> 500, with memo a1b2c3 (so, the same one)
> 500, with memo d1e2f3
- Open the reconciliation widget for your statement line

===> The 3 payments are matched, while only the two first ones should have been, as they were exact matches for the communication, and should hence have received higher priority.

closes odoo/odoo#70394

X-original-commit: b5800c9d2088df2bb9c4fbe0fed91c7ef24299c5
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-05-06 15:17:32 +00:00
oco-odoo 255c63ff26 [FIX] account: cash basis taxes: generate correct exchange difference when using the same cash basis taxes on multiple lines
To reproduce the bug:
1) Create a cash basis tax for 42%
2) Make an invoice with two lines at 100$, each using this tax
3) Post and register full payment of the invoice

==> An exchange difference has been generated, doing +100 -100. One of its two line has tax_ids set, while the other does not. This makes the base amount shown in the generic tax report wrong: 100 instead of 200.

Actually, this exchange difference entry shouldn't have existed in the first place, as there is no rounding issue to compensate for here. It happens because the grouping keys computed for the two base lines are the same, and the second line overwrites the totals of the first one instead of adding them to its own.

closes odoo/odoo#70283

X-original-commit: 60770f0b99bedd3dcb695e2191dc83c45ef0b594
Related: odoo/enterprise#18107
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-05-06 15:10:28 +00:00
Laurent Smet b80e214780 [FIX] account: Fix price_unit rounding issue with fpos/price included tax
- Create an invoice with an empty fiscal position
- Create a line with a product having 100.0 as sale price and 21.0% price-included tax
=> price_unit equals 99.99

This is because 100 / 1.21 ~= 82.64 but 82.64 * 1.21 ~= 99.99 != 100.0.
The bug only appears when managing a fiscal position because the code is trying to adapt the product price_unit to the newly computed taxes.

closes odoo/odoo#70276

X-original-commit: 3470a3c94e06d92afcd8a8129f80e4dfea14efe4
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-05-04 08:19:17 +00:00
wan efc407cacd [FIX] account: same sequence in different journal clash
When the same sequence is used in different journals (i.e. BNK1 in two
different companies), a clash might happen in the grouping optimization
of the `_compute_name`

closes odoo/odoo#70152

Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-05-04 07:45:03 +00:00
Raphael Collet 960cd72774 [REF] core: add method get_currency_field() on Monetary to retrieve it
This replaces the setup of the attribute 'currency_field', which depends
on the presence of other fields on the model, and may therefore vary
from one registry to another.  This is necessary to make monetary fields
shareable across registries.
2021-05-03 12:33:29 +00:00
Raphael Collet 34d6f87d54 [REF] core: put field.depends on registry and make field.recursive explicit
The attributes field.depends and field.depends_context are problematic
for sharing fields across registries, because they depend on the model's
registry class, which may vary from one registry to another.  In order
to make computed fields shareable, we have to move those values away
from fields.

For the same reason, field.recursive should not be inferred, because its
value may depend on the registry, although it is generally not the case.
Moreover, the flag recursive=True is set on a field when field triggers
are determined (on the registry).  A compute method may be called before
the flag is set (if no update has been done yet), and that can lead to
incorrect computations.

This happened in test TestUsers2.test_reified_groups in module 'base'.
The user groups view was apparently determined without the flag being
set, and the view depends on the recursive field 'trans_implied_ids',
which was not correctly computed.

We thus force developers to be explicit about recursive computed fields.
The code now logs a warning when the flag is not set up properly.
2021-05-03 12:33:29 +00:00
Nicolas (vin) 3973f766cc [IMP] account_reports: carryover improvements
Implements various small improvements in order to make the carryover
functionality a bit less hidden, with a cleaner UX.

Task id #2500684

closes odoo/odoo#69762

Related: odoo/enterprise#17908
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-04-30 15:37:35 +00:00
Goffin Simonandsmetl 45710b17da [FIX] account: Wrong amount of tax with different currency
Steps to reproduce the bug:

Create an accounting entry AE with $ as default currency
Add a line L1 with 10 € and a tax of 15%
Bug:

The added tax line was 0.75€ instead of 1.5€

opw:2510338

closes odoo/odoo#69995

X-original-commit: 28e85cdbbd499b3fa826c15d4058aa4b83b993c9
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Co-authored-by: smetl <las@odoo.com>
2021-04-28 11:38:09 +00:00
Andrea Grazioso (agr-odoo) cbdb4cb8aa [FIX] account: fix fiscal position mapping in pos
Have a Fiscal position FPOS which map tax A to tax B
Have products DEMO with tax A and DEMO2
Allow FPOS in POS, Open a session, activate FPOS, sell DEMO and DEMO2
Close POS
Go to Orders, select the last one, hit return, edit, delete DEMO2 line

Tax will be wrong.
This occcur because the fiscal position mapping fail an equivalence
check with a virtual record, so the tax is calculated as A and not B

opw-2485399

closes odoo/odoo#69952

X-original-commit: 983797e626f742e84710de7ec8487824d6eaa7f1
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2021-04-27 17:27:04 +00:00
Nicolas (vin) b9a17c2135 [FIX] account: fix a domain in the carryover lines model
The domain for the fiscal position in the carryover lines was incorrect,
missing the required quotes.

closes odoo/odoo#69921

X-original-commit: 85c07f0f93d664bf7f6028a1dfa0f663e2999c3d
Signed-off-by: William André (wan) <wan@odoo.com>
2021-04-27 12:26:13 +00:00
Goffin Simon d14299bc7b [FIX] account: Access error in multi companies
Steps to reproduce the bug:

- Let's consider two companies C1, C2 and a partner P in C2
- Let's consider an customner invoice I in C1 with P as customer
- Go to Accounting > Accounting > Partner Ledger and select I
- Click on Reconcie

Bug:

An access error was raised due to the ir.rule res.partner company

opw:2446242

closes odoo/odoo#69833

X-original-commit: 2279d84b4aefc8e488ccc33c30b816e988867589
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-04-26 10:42:22 +00:00
wan 002f89bd84 [FIX] account: never set default for invoice_date
For customer invoices:
* do not set default date because if you prepare an invoice (and it gets
  a default date), then validate it the next day, the date will be wrong
* set the date when posting if it wasn't set, because why not?

For vendor bills:
* do not set default date because you rarely encode a bill at the bill
  date. Forcing the user to enter it reduces risks of user error
  (duplicated vendor bill)
* do not set it when posting, same reason.

opw-2492862
Related #68368
Closes #68367

closes odoo/odoo#69639

X-original-commit: 41041d8016d11f017d92d28f32ab2cf42f1349a9
Related: odoo/enterprise#17866
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-04-22 08:16:08 +00:00
Goffin Simon 71301b8bbf [FIX] account_batch_payment: Payment method on payment not available
Steps to reproduce the bug:

    - Let's consider a journal J with inbound payment methods PM1 and PM2
    - Create an inbound batch payment with Bank = J
    - The default payment method will be PM2, change it to PM1
    - Create a payment P in the batch content (payment_ids)
    - Save

Bug:

    A UserError was raised: The batch must have the same type as the payments it contains.
    because when setting a partner on P the function _compute_payment_method_id defined in module account_check_printing
    was triggered and the first available payment method was set.

opw:2495487

closes odoo/odoo#69683

X-original-commit: 683c3fd267162c93cb278fd903152ac387e6aba6
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-04-22 12:16:29 +00:00
oco-odoo f8ca384ba7 [IMP] account: error message when no country can be inferred for taxes when installing the CoA
Generic chart of accounts such as Syscohada don't have any country_id set. When installing them on a company without any account_fiscal_country_id, no country could be assigned to the account.tax being created, hence crashing, as country_id is required on account.tax. We now prevent that by raising a more comprehensive error.

closes odoo/odoo#69593

X-original-commit: a253bf331b2448194106523b9c3d753fb6ddd04a
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-04-21 09:42:22 +00:00
jbw 79d7f1edab [FIX] account_payment: remove double country_code field in account_payment
There were 2 country_code fieldss in account_payment. Probably the result of
faulty rebase.

closes odoo/odoo#69530

X-original-commit: 0f4932c1b9b8c7201d175fff7e78bb1cecc98971
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: jbw-odoo <jbw-odoo@users.noreply.github.com>
2021-04-20 11:13:09 +00:00
Laurent Smet 53913adfc1 [FIX] account,point_of_sale: Allow mixing 'affect base' price-included/price-excluded taxes
Before this commit, such configuration wasn't allowed.
However, in some countries, this is mandatory, when dealing with eco-tax for example:

Suppose t1, t2 being taxes where:
- t1 is include_base_amount, price_excluded, fixed tax of 10 (eco-tax)
- t2 is include_base_amount, price_included, percent of 21%

The computation on 1210 should be:
price_excluded: 1210 / 1.21 = 1000
price_included: (1000 + 10) * 1.21 = 1222.1

closes odoo/odoo#69449

X-original-commit: 2bb9e68b546db191b2a88b787a865548d8107bcd
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-04-19 09:26:17 +00:00
Swapnesh ccba1ce694 [FIX]account: process one record to set debit/credit
Before this commit, There would be Expected singleton error
on changing Credit/Debit for multile account in single call.

Now, We are proocess one record to set `_set_opening_debit_credit`

closes odoo/odoo#69474

X-original-commit: 8fe9f552ed4591795b449f4d1e32e1563ce43ca2
Signed-off-by: William André (wan) <wan@odoo.com>
2021-04-19 12:22:14 +00:00
Raf Geens fc41a4a6c9 [FIX] account: Traceback on multiple auto-validation candidates
When an auto-validating reconciliation model is defined for matching
bank statement lines to invoices, it was possible to get a traceback
when the bank statement lines were in a certain order and matched in a
certain way.

In particular, if the first bank statement line is priority 3
(communication_flag True) and the amount is an exact match with the
invoice, it will be instantly reconciled. If there's a second line
that's a priority 5 match, it crashed because _filter_candidates didn't
take into account that candidates_by_priority could be empty if the
candidates were already reconciled.

Instead we just return an empty list of candidates and priorities when
this happens.

closes odoo/odoo#69331

Ticket: 2507189
X-original-commit: e9538d9cee092e034b85187a2eae857349f42ce7
Signed-off-by: William André (wan) <wan@odoo.com>
2021-04-15 15:07:21 +00:00
Julien CHEVREAU (JCU) d5270c1c8a [IMP] account: check non reconcilable accounts for configured journals
Beforehand, users could configure an account as non reconcilable
even when it was configured as a payment credit or debit account
in a journal. This prevented journal items to be reconciled

Now, when a user tries to set an account as non reconcilable,
we check if there is no journal with a payment credit or debit account
set to this particular account. If there is at least one journal,
then we display an error message stating the journals names and ids
that the user would have to modify before changing the account
configuration.

closes odoo/odoo#69317

X-original-commit: 87c207f3a408abb93d9b8378ef4aa1744935d86d
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Julien CHEVREAU <Julien-CHEVREAU@users.noreply.github.com>
2021-04-15 12:40:17 +00:00
Julien CHEVREAU (JCU) 0cf8df4f3f [FIX] account: Check Move Status Before Posting
Beforehand, if two users independently opened a draft
invoice on their respective sessions, then both of them
clicked on the "Post" button, then the invoice was
posted twice.
On a more general aspect, the view currently "prevents" users
from posting moves several times, but technically speaking,
nothing stops users from posting moves several times.

Now, after checking that the user indeed has the right to post
a move, the next check is about verifying that the move is
not already posted.

opw-2479201

closes odoo/odoo#69178

X-original-commit: b7db7db283d7b9d167201b791e6282b022d59c40
Related: odoo/enterprise#17658
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Julien CHEVREAU <Julien-CHEVREAU@users.noreply.github.com>
2021-04-14 08:37:32 +00:00
Andrea Grazioso (agr-odoo) 1cf1445d3b [FIX] account: count in dashboard statement lines marked 'to_check'
1. Reconcile of a bank statement, checking the "To
check" box on the manual operation before validation
2. Go to accounting dashboard

The statement line will not be counted in the "to check" action.
This occur because the action only filter on reconciled moves

This reverts commit 6b0017ffda.

opw-2475663

closes odoo/odoo#69135

X-original-commit: 4f2ba741af913c36dd944070b6cbe5aaf682ced6
Related: odoo/enterprise#17637
Signed-off-by: William André (wan) <wan@odoo.com>
2021-04-12 15:57:22 +00:00
emilkholod 207c4dda5c [FIX] account : Fix error on search_read for account.move.line
* If `where_clause` is empty, then there will be an error. This commit fixes that.

closes odoo/odoo#69100

X-original-commit: f0a1bb3692e17334850fed4f22444f47992adb78
Signed-off-by: William André (wan) <wan@odoo.com>
2021-04-11 11:56:15 +00:00
Nicolas (vin) a2d5c63bed [FIX] account: Fixes the losing of company_id in account move
Currently, the company_id of an account move is related to its journal.
This means that if you empty the journal field, the company_id is also
emptied.
This is then causing a traceback when adding a new line, for example.

This change will transform the related company_id in a computed field,
making sure to not lose the company_id if the journal_id is emptied.

task id #2392004

closes odoo/odoo#68886

X-original-commit: c3c6ec69a0c50daf0b33df62144b6cd2f254a4f5
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Nicolas Viseur <vin-odoo@users.noreply.github.com>
2021-04-07 12:34:08 +00:00
Swapnesh Shah 71452c3873 [IMP] account: remove orphan repartition lines
When a tax is deleted,
remove the `account.tax.repartition.line` linked to it as well.

closes odoo/odoo#68847

X-original-commit: 0731976cf0e3c6d47658ed1cbfbb8ace7428994e
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-04-06 17:20:36 +00:00
Julien CHEVREAU (JCU) e208da9372 [FIX] account: Cash Basis - recompute tax exigibility on move creation
Beforehand, tax exigibility was not systematically recomputed upon
move creation.

Now, as soon as an account move line is created on a move, tax exigibility
is recomputed.

closes odoo/odoo#68832

X-original-commit: df14e157fc7a80a1675b9581e0105891b4228f40
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-04-06 13:29:01 +00:00
Djamel (otd) 2e1689ef47 [FIX] account: added a regex verification when adding a partner mapping
Steps to reproduce the bug :

- Go to accounting > Configuration > Reconciliation Models
- Create a new reconciliation model
- Select the “Match existing invoices/bills” type
- In the field “Match Invoice/bill with” choose “Label”
- Add a new partner mapping > encode in "Find text in label" an erroneous regex like “*test” > choose any partner
- Go to accounting Dashboard > click on “Bank”
- Create a new Bank statement> add new transaction without selecting “Partner”
- Post the created bank statements > Reconcile it

Problem :
An error is triggered because the regex is wrong.

opw-2473973

closes odoo/odoo#68755

X-original-commit: cd9c071c9357cef14635ef094a9f14fc5431956c
Signed-off-by: William André (wan) <wan@odoo.com>
2021-04-06 09:17:03 +00:00
wan 00f1ad8d83 [FIX] account: set noupdate flag on accounting demo data
Demo data is not usually updated. It was also deleting the demo data
when doing a `-i account` when the module was already installed (or
actually the chart of accounts instantiated)

closes odoo/odoo#68802

X-original-commit: 8e4b7db8fe9f7c7cef1939938e9fa3df0dddc1f4
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-04-06 08:55:28 +00:00
Ivan Yelizariev 5901e7c553 [FIX] account: prevent excess calls of _get_lines_onchange_currency
That method iterates over move lines:

https://github.com/odoo/odoo/blob/7623a0c771495cd41bf40af37c0d2b6e4beb7cdc/addons/stock_account/models/account_move.py#L16-L18

So, we have O(n^2) complexity at least. It leads to timeout error on invoices
with few hundres products. After this commit it takes 70 seconds to confirm an
invoice with 450 lines:

23527 11.038 56.530
(Number of queries / Query time, sec / Remaining time, sec)

---

https://github.com/odoo/odoo/commit/9e1aec7873a935b287b4b3c5dbc2688acee5422a
opw-2488458

closes odoo/odoo#68797

X-original-commit: 176ecb1239f7e0a8e938de996d174b9c5bf930f4
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-04-06 07:57:30 +00:00
Jorge Pinna PuissantandLaurent Smet 76afde138f [FIX]account: error when rest bill to draft
- On accounting settings, activate 'Cash Basis';
- Select a 'Base Tax Received Account';
- Modify a purchase taxes, and set the 'Tax Due' to 'Based on Payment';
- Set a 'Cash Basis Transition Account';
- Be sure that the previously selected account allows reconciliation;
- Create a Vendors Bills, using the modified purchase tax;
- Register a payment;
- Reset to draft the vendors bill.

Before this commit, an error was raised : 'Record does not exist or has
been deleted.'

This occurs because when trying to unlink the partial reconcile, it will
first reverse and unlink the tax cash basis partial reconcile moves.
After when trying to access the partial reconcile to unlink the error is
raised because one is already unlink.

Now, the vendors bill is correctly reset to draft.

opw-2477526

closes odoo/odoo#68754

X-original-commit: 72c29b105bdb4da5b306cd3b48a1683c1bf3e620
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
Co-authored-by: Laurent Smet <las@odoo.com>
2021-04-06 08:36:08 +00:00
jbw 980e8ce14d [IMP] account: move views improvement
Account move view improvement and creation of amount_total_in_currency_signed
to allow display of amounts in company currency and in move currency.

closes odoo/odoo#66069

Task: 2403336
Related: odoo/upgrade#2331
Related: odoo/enterprise#16308
Signed-off-by: William André (wan) <wan@odoo.com>
2021-04-02 06:11:11 +00:00
jbw b7b9b18ac1 [IMP] account: Payments Form View Improvement
The Payment form view is simplified for a much less cluttered screen.
A paired internal payment is now created when an internal transfer is posted.

Task: 2403336
2021-04-02 06:11:11 +00:00
Nicolas (vin) 39d6e3d8c0 [IMP] account_reports: allow to carry over lines between periods
In belgian accounting, some tax lines in the tax report must be carried
over to the next period if they are negative.

If the balance for the next period is positive, it will be deduced by
the maximum possible amount that is carried over. If it is negative,
the negative balance will simply be added to the carried over balance.

This process repeats itself from one period to the other endlessly,
until the carried over balance come back to 0.

This is done by putting the carried over balance in dedicated analytic
accounts.

task id #2271978
2021-04-01 14:57:33 +00:00
Laurent Smet 3e1d81429b [REM] account: Remove on-the-fly payments when reconciling the statement line
This option is there because it was needed by the Mexican EDI to send payments to the government.
Since the refactoring made at revision:
https://github.com/odoo/enterprise/commit/1ccb480b8e95f5702b6fb4e01446d24107514550
... this feature is no longer needed.

closes odoo/odoo#68020

Signed-off-by: William André (wan) <wan@odoo.com>
2021-03-17 13:43:15 +00:00
Laurent Smet 8992955db2 [REM] account: Remove deprecated code since https://github.com/odoo/odoo/commit/8f5e137df71f83f9baa8886aedfd123f329841d7 2021-03-17 11:06:29 +00:00
oco-odoo 17610e8ca9 [IMP] account, account_edi, l10n_*, purchase, sale: Generalize the use of account_fiscal_country_id
Before, account_fiscal_country_id was only use for tax operations; and country_id was used for all the other accounting stuff. Now, with the new ability to use foreign tax reports (with foreign VAT fiscal positions), we can generalize the fiscal country, sot that it is the one that needs to be used for the whole accounting. Since foreign tax reports were not supported before, account_fiscal_country_id is already set on existing database as the country for the "main" accounting, so the impact of this change is small.

closes odoo/odoo#68349

Related: odoo/upgrade#2322
Related: odoo/enterprise#17299
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-04-01 12:09:20 +00:00
oco-odoo 7d678cc7f4 [IMP] account: introduce foreign VAT fiscal positions
Such fiscal positions define an alternate VAT for a specific region. When foreign_vat is set, a country must be set on the fiscal position; it'll be used to know for which tax report the fiscal position must be available as an alternate VAT (in the tax report; see enterprise branch). Note that it is possible to defined several foreign VATs for the same country, as long as they belong to different states within that country.

Note that this new feature is only for FOREIGN stuff; so, when you have to submit a tax report in different regions than yours. For example if you have a Belgian accounting, have French customers, and have a French VAT in addition to your Belgian VAT, to submit a tax report in France. For domestic operations, simply use your the vat field of your company, just like before.

[IMP] account: add country_id on taxes and filter them on invoices

The invoices now compute the country from which they should accept the taxes: it's either the one defined by fiscal_position_id.country_id (if fiscal_position_id is a foreign VAT fiscal position, i.e. it defines a foreign_vat value), or the company's account_fiscal_country_id.

Taxes from other countries are filtered from the view; we don't want them to be available there. There is also a constraint ensuring that. Same goes for tax repartition lines and tags from other countries.

We don't want to mix taxes, tags and foreign VAT fiscal positions from different countries, as it would break the tax report in enterprise. Doing this ensures the tax report can efficiently discriminate the move lines between the different regions whose report they have to appear in.

[IMP] account: add country_id to account.chart.template

This is done so that the taxes are created in the right country, and the fiscal country is initialized in a consistent way when instantiating the CoA on the company.

[IMP] account: print foreign VAT on invoice instead of company VAT if one is defined

[IMP] web: allow forcing company vat on document templates

This is done to allow the use of foreign vat fiscal position on invoices: in that case, we don't want to use the company VAT, but the value of fiscal_position_id.foreign_vat. So, when such a value exists, the invoice simply set the force_vat variable to the right value.

[IMP] base_vat: also validate VAT of foreign VAT fiscal positions

We generalize the code formerly only done for res.partner so that the foreign_vat field of account.fiscal.position can be checked in the same way.
2021-04-01 12:09:20 +00:00
oco-odoo 8a2be06f96 [IMP] account: allow switching CoA even when draft moves have a sequence
Before, we only cheked the name to know whether or not there were moves forbidding the deletion of the whole accounting to replace the CoA. This was too strict, as an accounting with only draft moves couldn't do it if some move had a sequence number (which could happend with moves that were reset to draft). If everything is in draft, we want to allow such deletion.
2021-04-01 12:09:20 +00:00
oco-odoo 7d541b9956 [IMP] account: allow deleting moves that were posted before it they are the last element of the sequence chain
We don't check anymore that a move has been posted before in order to allow its deletion. Instead, we look at its sequence: if it's set and is not at the end of the sequence chain it belongs to, we know removing the move will create a gap, whatever the move state, so we forbid it.

If the user really wants to remove the move anyway, it is possible, by manually emptying the name of the move to delete. This way, he won't have any sequence anymore, and will be deletable. Users should however, rather rely on move cancellations and reversals, just for the sake of a cleaner accounting.
2021-04-01 12:09:20 +00:00
Ivan Yelizariev 5a4e7b711e [FIX] core,account: avoid useless recomputations in res.config
User may use Settings menu just to click "Manage Users" buttons. Such simple
navigation sends ``create`` request, which may trigger a chain of
recomputations. To avoid that we redefine ``create`` method to check if a value
is really changed.

The previous explicit implementation lacks in v14 two fields at least:

* from module `account`
    ```
    qr_code = fields.Boolean(string='Display SEPA QR-code', related='company_id.qr_code', readonly=False)
    ```

* from module `enterprise/account_reports`
    ```
    account_tax_fiscal_country_id = fields.Many2one(string="Fiscal Country", related="company_id.account_tax_fiscal_country_id", readonly=False)
    ```

Performance Tests
=================

In this test we click "Manage users" and check stats for
``res.config.settings/create`` request.

Demo database with eCommerce and Accounting app installed:

```
|        | Number of queries | Query time, sec | Remaining time, sec |
|--------+-------------------+-----------------+---------------------|
| Before |               707 |           0.325 |               0.215 |
| After  |               382 |           0.283 |               0.174 |
```

The same, but with extra 1400 invoices:

```
|        | Number of queries | Query time, sec | Remaining time, sec |
|--------+-------------------+-----------------+---------------------|
| Before |               715 |           0.459 |               0.349 |
| After  |               382 |           0.176 |               0.107 |
```

---

opw-2489335

closes odoo/odoo#68620

X-original-commit: 5e3f37191a4687b305e2337780c7f10278f6a7aa
Signed-off-by: Ivan Yelizariev // IEL <yelizariev@users.noreply.github.com>
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-03-31 18:02:08 +00:00
Benjamin Frantzen (bfr) 90f23b6b5f [IMP] account: remove deprecated method _create_invoice_from_single_attachment
closes odoo/odoo#68596

X-original-commit: 079be25a1d994fa2166c90fa52216498b1b27d37
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: bfr-o <bfr-o@users.noreply.github.com>
2021-03-31 12:47:57 +00:00
wan 481b8f5e24 [FIX] account: restrict product deletion if used
Fixes #65445

closes odoo/odoo#68467

X-original-commit: 193271a9e84389527555e55f4b7a275d4d1a8011
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-03-29 11:45:47 +00:00
Josse Colpaert b3743556ab [FIX] account: avoid rounding error by not doing anything with empty fiscal positions
opw-2447155

closes odoo/odoo#68281

X-original-commit: fc0a2c515022cc6c200dd916462e44b1b79f8ea8
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-03-24 09:32:11 +00:00
oco-odoo 167655e2ce [FIX] account: make tax report duplication work properly
Before this, due to the order the lines were interated on (their sequence), some lines were duplicated without parent, making the duplicate report's layout different from its parent. We now ensure we treat the lines in an order that guarantees the parent line has always been copied before its children.

closes odoo/odoo#68011

X-original-commit: c815342b986851e0a4733ed5bf9fbcc7f8fb7442
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-03-17 11:59:42 +00:00
oco-odoo 758f09890a [FIX] account: forbid making refunds on incompatible journals
It shouldn't be possible to create refunds on misc journals, as the tax report would compute the wrong multiplicator sign, and hence end up being entirely wrong.

Introducing the constraint also allowed finding an issue within _move_autocomplete_invoice_lines_create: some tests directly create an invoice by giving it line_ids instead of using the invoice_line_ids helper. The former implementation of this function made it so that the default type wasn't set in the context properly, and these tests were putting their invoices on misc journals. We fix this here as well.

closes odoo/odoo#67965

X-original-commit: fdc96de0e411760f84a78c36543f9157332346de
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-03-16 14:23:32 +00:00
wan 06746c28c5 [FIX] account: sequence in the past after more precise sequence
Allow creating a journal entry in the past after having changed the
sequence number reset on newer sequences.

opw-2445559

closes odoo/odoo#67963

X-original-commit: 26a43f23ec2b2490aec0731e25568703729581f0
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-03-16 14:18:43 +00:00
Joseph Caburnay 3cbed4d4f6 [FIX] account,point_of_sale: ImbalanceJournalEntryError issue
The crash manager doesn't recognize ImbalanceJournalEntryError as
a user error and when creating a journal entry that is not balanced,
a traceback is shown instead of the normal UserError dialog.

In this commit, we fix this issue by getting rid of the new error
and put back the use of UserError when checking the balance of an
account move. We also make sure that the feature in pos where we
show a wizard to unblock the user from closing session with
imbalance amount is intact.

closes odoo/odoo#67743

Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2021-03-12 09:12:45 +00:00
wan 87818ba10f [FIX] account: wrong batching to compute the name
Fine tuning of f816c326f348ff78a982f91a736cc005d3e0cd31
We should not look at the `seq` when grouping again.

opw-2472061

closes odoo/odoo#67788

X-original-commit: fd36a69a6ed1484d6b7570dae3ff63d3f12ad035
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-03-12 17:40:09 +00:00
Rémy Voet (ryv) df96a8f292 [FIX] account: fix default context for group_id
Issue:
- Activate "Analytic Tags" and "Analytic Accounting" Settings
- Create an Analytic Tags and select "Analytic Distribution"
- Create Product -> Product type: Storable product, Update Quantity as
100, Sales Price like 100
- Product category -> Costing Method: Average Cost (AVCO)
Inventory Valuation: Automated
- Create Analytic Defaults Rules -> select created Analytic Tags
& Product.
- Create a SO -> Confirm it -> Delivery -> Validate it
then system give validation message message:
"The operation cannot be completed: another model requires the record
being deleted. If possible, archive it instead.
Model: Analytic Line (account.analytic.line),
Constraint: account_analytic_line_group_id_fkey”
But can be validated from the Inventory app.

Technical information:
It is due to the `default_group_id` in context put in
`action_view_delivery` method, it context key allows to create delivery
(tree view of `stock.picking`) with the correct `group_id`
("Procurement Group").
But the this name field is also used in the
`account.analytic.line` model. Moreover, the
the `_prepare_analytic_distribution_line` doesn't return any value for
`group_id` which means, that at the creation of the
`account.analytic.line` the `group_id` (id of `procurement.group`)
which will wrongly used.

Solution:
Because the `group_id` field on `account.analytic.line` is a related
store of `account_id.group_id`. We can set it directly in the
`_prepare_analytic_distribution_line` with the correct value.

opw-2442493

closes odoo/odoo#67780

X-original-commit: c9f55c5ecf174414f8e9ed6df56170ac2c6d6e3e
Signed-off-by: William André (wan) <wan@odoo.com>
2021-03-12 16:26:02 +00:00
Laurent Smet 1bbb97bf55 [FIX] account: Always display inactive taxes on journal items
closes odoo/odoo#67657

X-original-commit: f7dc4a4c8c6700cfecebffa1ef516e29a46aef61
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-03-11 10:30:16 +00:00