Commit Graph
3717 Commits
Author SHA1 Message Date
Julien Van Roy af69310b38 [IMP] account[_edi_ubl_cii]: new setting to uncheck the UBL/CII formats by default
Currently, the UBL/CII format (if enabled on the invoice) is checked by
default, which will trigger the validation checks upon generation. This
can be annoying (feedback: "error message when we want to send invoices
to customer. For some customer, there is a problem with the xml file. To
be able to send the invoice, we uncheck the box for the xml invoice. See
video:
https://drive.google.com/file/d/12IkhqQtHw0EUF3srqRX8uZjCXU2DYpns/view?usp=sharing)

To solve the issue, we add a new field `invoice_is_ubl_cii` to check or
uncheck the UBL/CII checkbox by default.

In addition, rename the field `invoice_is_print` to
`invoice_is_download` since it corresponds to the checkbox 'Download'.

Finally, make the `company_id` of account.move.send a computed field
instead of using the `_default_get`. Indeed, when creating the wizard
and passing a `move_ids` key, this key will not be detected as missing
by the `default_get`, and we will not enter the statement in the
`default_get` in `account_move_send.py` to set the `company_id`. As a
consequence, the `company_id` will not be set, and the subsequent
computed fields will not be correct (e.g.
`wizard.company_id.invoice_is_ubl_cii` will always be False inside
`_compute_checkbox_ubl_cii_xml` if `company_id` is not set).

task-3297308

closes odoo/odoo#119397

Related: odoo/upgrade#4581
Signed-off-by: William André (wan) <wan@odoo.com>
2023-05-12 19:54:42 +02:00
Laurent Smet 09af1764a8 [FIX] account: Fix _compute_linked_attachment_id
When the record is a draft record (with a NewId), the attachment is not retrieved correctly.
Indeed, `move_vals` contains the real ids.

closes odoo/odoo#121224

X-original-commit: 34ff1d66d5352f36d8d982d868e0b01c929c3c88
Signed-off-by: William André (wan) <wan@odoo.com>
2023-05-12 08:17:04 +02:00
Nshimiyimana Séna 63d7e39a09 [FIX] account: prevent sequence number gap in Accounting Firms mode
When modifying the accounting date of an invoice in Accounting Firms
mode, Odoo always generates a new invoice sequence number. This behavior
can introduce gaps in the sequences.

1. Activate Accounting Firms mode.
2. Create a new Draft Invoice and save it.
3. Create a second Draft Invoice and save it.
4. Modify the accounting date of the first invoice and save it.
5. Observe that the first invoice's invoice sequence number is updated
   to the next sequence, creating a gap.

Recompute the sequence only when the new date falls into a different
fiscal year.

opw-3164537

closes odoo/odoo#121215

X-original-commit: 28c5c37c420eda8f916dc0f031521313ac18ec08
Signed-off-by: Nshimiyimana Serge Séna (sesn) <sesn@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2023-05-12 08:17:01 +02:00
Laurent Smet 281fce54e6 [FIX] account: Fix cascading computation leading to wrong move_name computation
When l10n_mx_edi is installed and a payment is posted, the move_name field on account.move.line
being a related to move_id.name is not well computed.
That is because posting a move trigger the computed field in a protected mode due to `flush_recorset`.
This mode prevents any computed field to be recomputed twice.
This flush triggers `_compute_name` calling `sequence_mixin`, itself doing another `flush_recorset`.
This extra flush triggers `_compute_l10n_mx_edi_cfdi_uuid` that access to `move.payment_id.reconciled_bill_ids`.
This access to this field triggers its recomputation and then, `_compute_stat_buttons_from_reconciliation` is called.
This method does `self.env['account.move.line'].flush_model()` that force the computation of `move_name` to `/`.
`sequence_mixin` assigns the new `name` to the journal entry but `move_name` is not recomputed due to the
protected environment.

closes odoo/odoo#121114

X-original-commit: 33198b3443829d6d6e421cf9d6b8033a040b5263
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
2023-05-11 16:01:24 +02:00
smna-odoo 7a10c2756b [FIX] account: prevent traceback while add multiple attachment in chatter
the error will occur when adding more than one attachment to draft invoice
chatter and click on send button.

applying these changes will resolve this issue.

sentry-4059207297

closes odoo/odoo#120238

X-original-commit: a2fcf96df23a7eea7ff9ddb94798e8375590ae28
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Signed-off-by: Smit Nagar (smna) <smna@odoo.com>
2023-05-11 12:01:40 +02:00
Julien Van Roy e553f0b372 [FIX] mail,account_edi: fix creation of invoice upon email reception
When receiving an email on a mailbox with an alias that triggers the
creation of invoices, 4 bugs could occur.

1. If the xml received contains replacement characters (U+FFFD �), and
the charset of the part of the email is "US-ASCII" the encoding of the
string will fail, preventing the rest of the flow to be completed. Be
more resilient, encode the string and ignores these characters if this
case occurs.

NB: sometimes, the charset is omitted for a Content-type: text/xml. This
is valid but not recommended (see:
https://www.ietf.org/rfc/rfc2376.txt). In this case, the default used is
"US-ASCII". This means that any non-ascii char will be lost (they are
replaced by the replacement character: �, see:
https://github.com/python/cpython/blob/3.10/Lib/email/contentmanager.py#L67)
when decoding the attachment.

2. When the xml attachment is created in Odoo, the mimetype is
'text/plain' (rather than 'application/xml'). Thus, the
`_decode_attachment` needs to be more flexible when guessing the type of
the attachment (to know which function to use to read the content of the
attachment and create the invoice).

3. When creating an invoice from an email with an xml attachment, the
xml is attached as the `message_main_attachment_id`. It's only later on
that the content of the xml is read and we possibly find the PDF in
base64 inside. When creating the PDF attachment, it was not set as the
`message_main_attachment_id`, so the PDF was not rendered on the right
part of the invoice form view. Add a clause to replace the
`message_main_attachment_id` in such a case.

4. When the xml attachment represents a credit note, the move_type of
the invoice created by the email alias needs to be changed. Indeed, the
invoice is created before decoding the attachment, so we can only change
the `move_type` later.

opw-3144519
opw-3149649

closes odoo/odoo#121076

X-original-commit: 1e193a92b9c84e75b958985f8067873b90f686e0
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
2023-05-11 08:28:42 +02:00
oco-odoo 8dae77e6df [FIX] account: properly handle negative repartition lines in _compute_is_refund
Partial revert of b15116179e71040ffa01bb35161e32b16aac477d .
This fix introduced a new bug: when creating an write-off with taxes from the bank reconciliation widget, signs were all inverted in the tax report, because that commit was forcing the values of tax_tax_invert in a wrong way.

The proper fix is to fix the computation of the is_refund field in community, so that negative repartition lines are taken into account ("debit" is a refund for a "sales" tax only for positive repartition lines, for example).

Community part is in https://github.com/odoo/odoo/pull/120152

closes odoo/odoo#120924

X-original-commit: 67e789074cb00b9db6e3fd83ef92ed712b28edfb
Related: odoo/enterprise#40856
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: Laurent Smet <las@odoo.com>
2023-05-10 20:15:30 +02:00
oco-odoo b96dc99f03 [FIX] account: tax computation: when forcing the tags on caba taxes, also force the account
Cash basis taxes use a distinct transition account on their tax lines; the tax account set on the repartition lines is only used when the payment is received, on the cash basis move.

In enterprise, the bank reconciliation widget allows setting a tax on the manual write-off done for a statement line. When doing so, we expect the tax to behave just like on an invoice. For cash basis taxes, this means the "final" tax account has to be used instead of the transition one ; it wasn't the case.

OPW 3255511

X-original-commit: 991fa46081296c3560bd7ca195996693a81a46b8
Part-of: odoo/odoo#120924
2023-05-10 20:15:29 +02:00
yhu-odoo 1eb2e7c814 [IMP] {,mrp_,stock_}account, *: add default stock accounts and production cost
account

1. We introduced a new Production Cost account that can be set on
locations with Production type. When products move into/out of a
production location. The account entry will be post on this account
instead of previous Stock in/out account.

2. On the accounting setting page, we can now set the default values for
all stock accounts. Users can also disable automatically accounting for
stock there.

Task-3046333

closes odoo/odoo#113973

Related: odoo/enterprise#37653
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-05-10 15:19:32 +02:00
paso-odoo bffa4377ff [FIX] account: fix the issue of unsupported operand in payment terms
If applied, this commit will solve the issue of the payment terms 'Example Date'
issue while we keep that blank and try to save the Payment Term.

Steps to produce:
- Open any Payment Term.
- Remove the example date.
- Add a line in Due Terms and click on save button.

Added a default value while the example date is not getting.

sentry - 4065889321
see - https://tinyurl.com/2caru9dd

closes odoo/odoo#120234

X-original-commit: 980aa78c0d9228cba665066d08ea7cd2f83e0097
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Parth Solanki (paso) <paso@odoo.com>
2023-05-10 13:21:52 +02:00
Habib (ayh) 6d420a3324 [IMP] account: fix transaction demo data
The bank statement & transaction demo data has problems:
1. the statement doesn't have a name
2. the creation of the statement lines are postponed causing the opening/closing balances to be invalid (as the order of the statement lines is important)

This is due to the  _load_data method in account, which defers the creation of records to ensure that related records are created before they are referenced in relational fields.

This commit adds a condition to avoid deferring fields that have a list of ORM create commands, and fixes the statement name and balances.

closes odoo/odoo#120975

X-original-commit: 1d219de36944685153a77aeeb72920b06728383e
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Ayob Habib (ayh) <ayh@odoo.com>
2023-05-10 08:23:50 +02:00
Guillaume (guva)andHabib Ayob <ayh@odoo.com> & Laurent Smet <las@odoo.com> e0e7e3b832 [FIX] account: payment_state reversed/paid bill
When partially reversing a bill and paying the
difference, the payment state should be 'paid'.
In the particular case of having the bank account
as manual outstanding payment account on the bank
journal, payment state was 'reversed'.

opw-3235107

closes odoo/odoo#120967

X-original-commit: eb0baf273980957b522e3e41b5d371ba081c915d
Signed-off-by: Laurent Smet <las@odoo.com>
Co-authored-by: Habib Ayob <ayh@odoo.com> & Laurent Smet <las@odoo.com>
2023-05-10 08:23:47 +02:00
william-andre 9f13817425 [IMP] base: allow to add country flags on module kanban
The icons made for localization require tedious manual work where it
could be done easily with some css.

task-3166075

Part-of: odoo/odoo#108617
2023-05-10 04:14:49 +02:00
Andrea Grazioso (agr-odoo) 2d3f6f9488 [FIX] account: invoice mail subtitle
Have an invoice marked as paid
Send by email

Issue:
Email will contain "$ <amount> due <due date>" which is confusing for
the user as the invoice is already paid

opw-3289653

closes odoo/odoo#120905

X-original-commit: 5c66a766abed5142d77835dcfda423abdcb1429f
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
2023-05-10 02:00:53 +02:00
clesgow d22705b956 [IMP] account: display code and name on Incoterms
Display incoterm names the same way we display products with their
`internal_reference`.

Part of task-3218314

Part-of: odoo/odoo#119381
2023-05-09 21:04:03 +02:00
qdp-odoo be4e1d1400 [IMP] account: do not trust bank accounts at their creation
This comes as a followup of https://github.com/odoo/odoo/pull/120423 where we restrict unallowed users to toggle the field allow_out_payment when writing on res.partner.bank. Similarly, we'll now do the same check at the creation of bank accounts

closes odoo/odoo#120694

Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2023-05-09 18:26:59 +02:00
Antoine Dupuis (andu) 6e30206fdb [FIX] account: Correctly translate terms when loading CoA
Bugfix: at the moment, if the environment's language is not en_US,
loading a CoA doesn't correctly load the translations: the translations
for all languages are created with the en_US terms.

Steps to reproduce:
1. Create a DB and install l10n_be.
2. Switch to French.
2. Create a new company based in Belgium.
3. Install the Belgian CoA on the company.

Expected behaviour: The accounts should be in French.
Actual behaviour: The French translation of the accounts contains
the terms in English.

Analysis:
When the records are created by _load_records(), the language of the
environment is French. As a result, all translatable terms are created
with translations in en_US and in fr_FR.
See https://github.com/odoo/odoo/blob/39292a02ab34ea86abd5601055901eb968006944/odoo/fields.py#L1762-L1771

Later on, when the translations are loaded by _load_translations,
there already exists a name->'fr_FR', so our call to
translation_importer.save(overwrite=False) doesn't want to overwrite it.
See https://github.com/odoo/odoo/blob/2780c37cfdb8560ac7c725fd27f4fe272f1d3072/addons/account/models/chart_template.py#L787

As a result, we end up with the English terms in both the en_US and
fr_FR translations.

The fix:
Set the language to en_US when calling _load_records().

closes odoo/odoo#120863

X-original-commit: 52ef69aa8423a0fd5d78af1ab018a98dba87361c
Signed-off-by: William André (wan) <wan@odoo.com>
2023-05-09 11:57:39 +02:00
Andrea Grazioso (agr-odoo) 360b95e8eb [FIX] account: search for deprecated account
Duplicate the default Account Payable (211000)
Set the default Account Payable to Deprecated
Create a Vendor Bill with a line
Save

Error will raise
The account Account Payable (211000) is deprecated.

opw-3199157
opw-3229350

closes odoo/odoo#120799

X-original-commit: 0dc11ed2e4e530ddefe4310fa6bef7001f20ecc1
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
2023-05-09 06:07:49 +02:00
Andrea Grazioso (agr-odoo) c2182ae4d0 [FIX] account: payment reconciliation line order
Create 3 invoices for customer (A: $100, B: $300, C: $200)
Have a customer payment of $500
Reconcile the payment, in the widget add the line in the order:
- Payment line
- Invoice A
- Invoice B
- Invoice C (partial payment)
Reconcile
Check invoices

Issue:
C will be fully paid, the partial payment will be applied to B
After 5b2c1d243c0dd5b049ceae280dd270fc8a59f955
We order the lines by amount currency but the user provided order is
lost. Moving the original fix to point of sale

opw-3240586

closes odoo/odoo#120779

X-original-commit: 89f9028901a8b43aab605c12e3c7bcc2a7dd8d44
Related: odoo/enterprise#40805
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
2023-05-09 06:07:33 +02:00
hupo-odoo 8823e01040 [IMP] account: Express VAT in local currency on invoices
Display the totals and taxes on pdf invoices in the company currency when the invoice is in foreign currency. This is a requirement from some countries where local authorities need the VAT to be expressed on the invoice in the national currency even if the invoice has been issued in another currency. The tax groups details are also required. The new information is expressed using a rectangle at the bottom right of an invoice. It includes the same information as the detail of totals and taxes above, with the difference that it is in company currency. If cash rounding is activated, the total rounded must not be displayed in company currency.

task : 3256515

closes odoo/odoo#118234

Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
2023-05-09 04:44:28 +02:00
aliya 381da748c3 [IMP] account: add text, bool as possible values for manual expressions
Some reports require editable expressions to accept other inputs than just a float.
This commit adds support for a string or a boolean.
For string input, we need to specify that formula='text', figure_type='string'.
Boolean input: figure_type='bool'.

task-3098957

closes odoo/odoo#110692

Related: odoo/enterprise#36150
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
2023-05-08 15:17:57 +02:00
Habib (ayh) d7d02c44c6 [FIX] account: context issue when importing statements
The file uploader uses a context key `default_journal_id` to identify the journal to upload to. With commit https://github.com/odoo/enterprise/commit/0d7d1a2994f14b80cd8f3644871f87a472821741, we attempt to reconcile imported transactions immediately. When reconciling, if there is a partner and an account number, the res.partner.bank is created.

Problem:
When creating a partner bank account, the default_journal_id is in the context, and is interpreted as a default value, which causes a stack trace.

Solution:
Explicitly specifiy the journal_id when the partner bank account is created, so there is no invalid value when obtaining defaults.

task-3299109
opw-3291805
opw-3291064
opw-3291024

closes odoo/odoo#120554

X-original-commit: ff4e080d3e006104cf6345d96e56714b0f8be16d
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Ayob Habib (ayh) <ayh@odoo.com>
2023-05-04 23:30:54 +02:00
620c901847 [FIX] account,purchase,sale,l10n_it_edi: tax totals with global rounding
# Steps to reproduce

* create two 17% sales taxes. We'll call those taxes `17a` and `17b`.
* set rounding method to global
* create a SO with the following 2 lines:
  * Price = `50.4`, Taxes = `17a`
  * Price = `47.208`, Taxes = `17b`
* note that the total tax amount on the SO is `16.59`
* confirm and invoice the SO.

You should see that the total tax amount on the invoice is `16.60`. The
invoice and SO should have the same tax amount.

opw-3179228

closes odoo/odoo#120224

X-original-commit: 715d0e269c3d42a5e25f8ddf648d275069354aaa
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Nshimiyimana Serge Séna (sesn) <sesn@odoo.com>
Co-authored-by: Laurent Smet <las@odoo.com>
Co-authored-by: Yolann Sabaux <yosa@odoo.com>
2023-05-04 07:58:42 +02:00
william-andre 3d2f6a0c10 [FIX] account_sequence: flush fields depending on sequence
Because we are flushing, and because the business code might be flushing
elsewhere (i.e. to validate constraints), the fields depending on the
sequence field might be protected by the ORM. This is not desired, so we
already reset them here.

The symptoms were that sometimes the related field `move_name` on
`account.move.line` would stay at `/` even after the new `name` was
given.

closes odoo/odoo#120488

X-original-commit: e7db87db57e4f98719602502d80948a5ed51adc2
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2023-05-03 22:09:47 +02:00
Gauthier Wala (gawa) 4523a250e0 [FIX] account: avoid wrong taxes quick encoding
How to reproduce:
- Activate l10n_be and go on a Belgian Company
- Activate Quick Encoding on Bills
- Setup account 600000 with taxes 12% (Sales) and 12% M (Purchase)
- Create a Bill
- Put 112 as the amount Tax Incl.
=> Both taxes are put on the line, which makes no sense, resulting
a sale tax on a purchase document.

It was forgotten in https://github.com/odoo/odoo/commit/85d89a986b6adcf9d0ac0ce57599d4b2678b59a3

closes odoo/odoo#120486

X-original-commit: 04287db0045eefed1b03e04d745874caf206731f
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2023-05-03 22:09:45 +02:00
Nicolas (vin) ba6ff1b616 [FIX] account: res partner bank bugprovement
Improve some aspects of the recent res partner bank improvement:
    - the url toward the docs open in a new tab
    - fix the account creation by disabling the readonly when trusted
      while the record isn't existing in the database yet
    - improve the visual of the setting by putting it in the accounting
      section

closes odoo/odoo#120423

Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2023-05-03 13:57:29 +02:00
william-andre 209e2ebb04 [FIX] account: compute of the name issue when no tax
When posting a move without any taxes, and hashing in version 3,
as in the test `test_account_move_hash_versioning_3`,
there was a case when the move could have its name changed after
posting, and so, after hashing.

The issue came from the order of computation of the name, as
we gave the name in the values when we shouldn't.

closes odoo/odoo#115222

Related: odoo/enterprise#38163
Signed-off-by: William André (wan) <wan@odoo.com>
2023-05-02 14:47:02 +02:00
gawa-odoo 15b2c690e1 [IMP] account, l10n_ar: do not put default product taxes on aml
If there are no default taxes on product or account, or
predictive guess, there should be no default taxes on a new aml.
So the `account_sale_tax_id` (and `account_purchase_tax_id`)
field only concern new products (as specified in the tooltip
of the field).

In Argentina, there is a constraint so all lines should have
a tax. So, we need to add default tax on their demo products.
We also add it to the products in account demo to have taxes
by default on demo invoices for all localizations.

task-3045026

Part-of: odoo/odoo#115222
2023-05-02 14:47:02 +02:00
Rémy Voet (ryv) 302c7baa87 [REM] core,*: remove name_get_uid parameter from _name_search.
`name_get_uid` is unused (at least since v14) and the
documentation about it, is wrong.

closes odoo/odoo#117819

Related: odoo/enterprise#39483
Signed-off-by: Rémy Voet <ryv@odoo.com>
2023-04-28 16:04:27 +02:00
william-andre 0767e690f6 [FIX] account: import misc. operation by giving only foreign amount
Import a file with a content like this (specifying the amount in foreign
currency but not the amount in company currency)
```
Journal,Reference,Journal Items/Account,Journal Items/Label,Journal Items/Analytic Distribution,Journal Items/amount in currency,Journal Items/currency
Miscellaneous Operations,EUR March 2023,101000 Current Assets,label,,-29,EUR
,,201000 Current Liabilities,label,,29,EUR
```

The debit/credit were set to 0, but it would have been expected to compute
the amount from the foreign balance instead.

task-3287331

closes odoo/odoo#120022

X-original-commit: 5f2412ac0ebb7e5868fc6c60789914de2c213d3f
Related: odoo/enterprise#40467
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2023-04-27 20:37:52 +02:00
Nshimiyimana SénaandLaurent Smet cfeffc3c74 [FIX] account: invoice totals using Cash Discount and price-included taxes
## Summary

Currently, when using both an early payment discount (upon invoice) and
price-included taxes, the invoice totals are not calculated correctly.

## Steps to Reproduce

1. Set `Cash Discount Tax Reduction` to `Always (upon invoice)`.
2. Create an invoice with the payment term set to `2/7 Net 30`.
3. Add an invoice line with a price of 100 and a 21% price-included tax.
4. Save the invoice: The `Untaxed Amount` should be 100, but it
   incorrectly shows 100.35 instead.

## Cause

When calculating the totals, the price-included tax is applied to one of
the early payment discount lines. Since the tax is price-included, the
system recalculates a new base price for the EPD line, which ultimately
leads to an incorrect `Untaxed Amount`.

opw-3239904

Enterprise PR: odoo/enterprise#39007

closes odoo/odoo#119892

X-original-commit: 43b78a96a8961b83cf1c18f58bd549dabc90c50f
Related: odoo/enterprise#40404
Signed-off-by: Nshimiyimana Serge Séna (sesn) <sesn@odoo.com>
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Co-authored-by: Laurent Smet <las@odoo.com>
2023-04-27 08:09:39 +02:00
Andrea Grazioso (agr-odoo) 7df7f9b0bc [FIX] account: product description change with journal
Have 2 Customer invoices journals
Create an invoice
Add a line
Save
Edit product description
Change journal

Product description will reset to default

opw-3171099

closes odoo/odoo#119850

X-original-commit: 43b49f8cacff87e15102993ff4e2d06c9bff8ff4
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
2023-04-27 07:05:59 +02:00
det 244b8502d2 [IMP] account: helper to generate invoices via send&print
https://github.com/odoo/odoo/commit/955091e707df1206ccda8314f1f182e2a37a8362
changed the way we want to generate invoices.

This commit provides an helper method to be used in others modules to
properly generate and send invoices following the send&print flow.

task-id:3253019

closes odoo/odoo#119759

X-original-commit: 8dbf4c8390d9d0e4e2050b0ca318fcb2ec9dc3b0
Related: odoo/enterprise#40330
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2023-04-27 00:52:20 +02:00
Rodrigo ae4c249882 [IMP] account: improve tax name search
This commit allows the exact search of a text that is searched between dashes.
Examples:   0EUM      => VAT 0% EU M.
            21M       => 21% M , 21% EU M, 21% M.Cocont and 21% EX M.
            21 M"    => 21% M and 21% M.Cocont.
            21" M"co  => 21% M.Cocont.

X-original-commit: ad2682c513c82052539cf99a54994b035b2afe6d
Part-of: odoo/odoo#119756
2023-04-26 17:06:35 +02:00
Adrien Widart (awt) 4bccbb175f [FIX] {stock_,}account, stock_landed_costs: set categories properties
When a product category valuation is set to `real_time`, we use the
stock accounts. However, in the code, to know which account we
should use, we do: "use stock accounts if defined, else use basic
ones" (the best should be "use stock accounts if `real_time`" but
this refactoring task will be done in master). So, here, we need to
ensure that stock accounts are not defined when the valuation is manual.

This is the case when installing `stock_account` module: the
valuations will be set to manual, so we need to force the stock
accounts to `False`. Same when creating a new company, we also need to
ensure that the stock accounts are not defined. This explains the
changes in `_post_load_data`

About changes in `_check_valuation_accouts`, the explanation is in
the method body: the defined values directly depends on the value of
`property_valuation`

Note about test modification: for the tests in `stock_landed_costs`
module, we set the categ to auto so the stock accounts are defined.
Otherwise, when validating the landed costs, it will lead to an error
https://github.com/odoo/odoo/blob/9cd316f038dc95051814ede9474f8f15f7d165df/addons/stock_landed_costs/models/stock_landed_cost.py#L396-L397

OPW-2746384

X-original-commit: 2780c37cfdb8560ac7c725fd27f4fe272f1d3072
Part-of: odoo/odoo#119564
2023-04-26 17:06:13 +02:00
Habib (ayh) 65044ad205 [FIX] account: bank balance confusion
Due to performance issues, the computation of the balance in GL was changed (odoo/odoo#103697)
Since it is computed in `_get_journal_dashboard_bank_running_balance` as the last statement balance (balance_end_real) + transactions (account.bank.statement.line since the last statement), we rename the label on the journal dashboard to "Running Balance".
Also, fix the order clause of the "Last Statement" balance as it has a problem when there are 2 statements on the same day.

OPW-3265511

closes odoo/odoo#119764

X-original-commit: 383f52ac2b75a839469323a1e71b4c2ea76f8393
Related: odoo/enterprise#40334
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Ayob Habib (ayh) <ayh@odoo.com>
2023-04-26 11:25:53 +02:00
Victor Feyens f4ea6d3226 [FIX] *: strict api for main orm methods
Enforce strict types for returned values for
* create
* write
* unlink
* default_get

to make those methods more consistent and reliable.
Also make sure they can be called with empty self/values,
i.e. that they follow the same behavior as the base methods
defined in the main orm Model.

closes odoo/odoo#116809

Related: odoo/enterprise#38880
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-04-25 15:20:43 +02:00
Habib (ayh) 39c78c92ff [IMP] account: add generic base_vat methods to enable vat validation without the dependency
To enable VAT validation (VIES/ simple), the base_vat module needs to be installed.
base_vat extends models where the validation should apply. This means it only works with models in account, unless the module is added as a dependency (base_vat depends on account)
To avoid this dependency (in account reports - see enterprise PR odoo/enterprise#34068), two methods required for VAT validation are added to res.partner so that the enterprise module is able to use this feature with/without base_vat.

closes odoo/odoo#106046

Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
2023-04-25 14:06:57 +02:00
william-andre 40967ac434 [FIX] account: computation of "Use in Tax Closing"
The computation of `use_in_tax_closing` was overlooked when refactoring[^1]
the CoA templates. Since it was using a `onchange` with an extra code in
`create` of the `account.tax.repartition.line.template`, it didn't work on
its own after the refactoring.

[^1]: 5125748616

closes odoo/odoo#119440

X-original-commit: e51ffcb01be3238338f23946b75f7e034032cf37
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2023-04-22 06:54:00 +02:00
hupo-odoo 04489abea9 [REV] account: journal task reminder
Revert the following commit : https://github.com/odoo/odoo/commit/66672cf7f63548638ad218d5cae44cde5868b318
The reason is that it is at the end not functionally desired. We do want to see the task reminder for tax return on journal dashboard no matter the date.

task : 3231957

closes odoo/odoo#119428

X-original-commit: f1f5c5025ac2c7132590065fe701e3117490680c
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2023-04-22 06:53:57 +02:00
Julien Alardot (jual) 1fddf0d02d [FIX] account: fix lockdates in sequence holes
The lockdate date should not be included in the check
for sequence holes, as it is supposed to be locked

Task-3280680

X-original-commit: 18573b7c47f19933e6a420f8bb8d72687b568a5b
Part-of: odoo/odoo#119427
2023-04-22 06:53:54 +02:00
Claire Bretton (clbr) 2fb19756ef [FIX] account: dashboard crashes when activity set on misc.op.
When you create an entry on Miscellaneous Operations journal and
schedule an activity on that entry, the Accounting dashboard
crashes and gets completely inaccessible because of an untranslated
field on mail.activity.type.

closes odoo/odoo#119318

Task: 3283382
Opw: 3277677
X-original-commit: 14481724cb5d6a164332586eb18f3195c6508b12
Signed-off-by: John Laterre (jol) <jol@odoo.com>
Signed-off-by: Claire Bretton <clbr@odoo.com>
2023-04-22 05:52:04 +02:00
Florian(flg) e3bb3cd9c4 [IMP] account: Add transaction_details field on bank statement line
For some reasons, we need to store information about a transaction
in the bank statement line. This commit adds the field to handle
this information.

task-3270965

closes odoo/odoo#118943

Related: odoo/enterprise#39955
Signed-off-by: Laurent Smet <las@odoo.com>
2023-04-22 03:20:11 +02:00
Nshimiyimana Séna f19de6f5cd [FIX] account: Early Payment Discount Grouping Error with Tax Grids
## Summary

The early payment discount (EPD) grouping functionality can break when
using taxes that add tax tags on their base lines.

## Steps to Reproduce

1. Install the `l10n_be` module
2. Ensure that `Cash Discount Tax Reduction` in the settings is set to
   `Always (upon invoice)`
3. Create a bill and set the payment term to `2/7 Net 30`
4. Add a product line (`l1`) with any Belgian tax and save
5. Add the same product line again (`l2`) and save
6. Attempt to add another product line or remove an existing one and
   save: an error will occur, stating that the move is not balanced

## Cause

The EPD grouping key depends on various factors, including the
`tax_tag_ids` (tax grids) of the product lines. However, the system
currently processes mixed EPDs before taxes. As a result, when saving at
the end of step 5, EPDs are calculated for `l2`. However, `l2` does not
have tags at this stage, while `l1` does, since it was saved earlier.
This discrepancy leads to incorrect EPD grouping.

opw-3129639

closes odoo/odoo#119226

X-original-commit: 044957eac66bad04aa64dd16488843369cd0833e
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Nshimiyimana Serge Séna (sesn) <sesn@odoo.com>
2023-04-21 15:02:20 +02:00
Mahamadasif Ansari 4fa6ed837b [FIX] account: assign current date in due_date if date_ref not available
Unsupported operand type(s) for +: 'NoneType' and 'relativedelta'
occur when we create payment terms without a preview date (date_ref).
This is because date_ref has no value.

This commit solves the issue by adding a condition if date_ref is not
available, so it adds current date instead of it.

sentry-4068322613

closes odoo/odoo#119187

X-original-commit: a9f556c0d45c32574c94765462d4b59726fc3f19
Signed-off-by: William André (wan) <wan@odoo.com>
2023-04-20 15:21:53 +02:00
Renilkumar Kajavadra c70a46b8bf [FIX] account: fix IndexError in payment terms
If applied, this commit will solve the tuple index out of range error when the
'Percent' value is not set in the Due Terms and the user tries to add 'Fixed'
value in more than one line.

To reproduce this issue, follow the steps.
- Open Accounting -> Configuration -> invoicing -> payment terms.
- Open any payment term, and change the value from 'Percent' to 'Fixed' in Due
  Terms.
- Add another line with a value as 'Fixed'.

see-https://tinyurl.com/22e2yj2a

sentry-4072967091

closes odoo/odoo#119131

X-original-commit: fcb3c237e24ec44fd6df0de5f2a0f329efb1bf13
Signed-off-by: William André (wan) <wan@odoo.com>
2023-04-20 00:50:00 +02:00
Andrea Grazioso (agr-odoo) 8deeb10ef8 [FIX] account: lock posted entry issue with cash rounding
- Enable Cash Rounding in settings.
- Create the cash rounding as
  - Rounding precision: 5.00
  - Rounding Strategy: Add a rounding line
  - Profit Account: Any
  - Loss Account: Any
  - Rounding Method: Half-up
- Enable "Lock Posted Entries with Hash" on Customer Invoices Journal.
- Create a draft invoice and set the cash rounding on it.
- Confirm

Error will raise
You cannot edit the following fields: Account, Label, Partner.
The following entries are already hashed

This occurs because cash rounding is recomputed during post,
after hash was written

opw-3235377

closes odoo/odoo#119126

X-original-commit: 5cb044dd8a2385c9a3c09520ed97eb4faa39216d
Signed-off-by: William André (wan) <wan@odoo.com>
2023-04-19 23:41:44 +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
Maruan Aguerdouh (magm) 5e637beeb9 [FIX] account: show suggestion only after second line and don't apply taxes from suggestions
Steps to reproduce:

- Go to accounting > journal entries > create a new journal entry.
- Add a line with an account.
- Add a second line.

Previous behavior:

We are going to get in the second line a suggestion of the first line
introduced, also even if we don't select the suggestion the taxes of
the suggestion will be applied.

Current behavior:

As discussed with the PO, we only want to get suggestions when we used 2
accounts in a row, so the 3rd line will be the one getting the
suggestion. And we also avoid seting the taxes of the suggestion if we
don't select it.

Related to #39784

opw-3098361

closes odoo/odoo#118865

X-original-commit: 927890d0178c361ef8d80fe6a1ec2ffaefaf73fd
Related: odoo/enterprise#39921
Signed-off-by: William André (wan) <wan@odoo.com>
2023-04-18 03:10:47 +02:00
Antoine Dupuis (andu) d1834758ea [IMP] tools, account: remove XSD crons; download XSD button
At the moment, XSD files are automatically downloaded at database
initialization, which is quite unnecessary.

The idea is to change Odoo's use of XSDs from being systematically
downloaded and used for validation to simply being available if desired
(e.g. for development or for customers who want them).

To achieve this, this commit does the following:

- remove the XSD download crons;
- provide a 'download XSDs' button in the Settings (next to the debug
  mode button) which is available in debug mode;
- skip XSD validation if any required XSD file is not present; and
- deprecate the 'force_reload' option.

Entreprise PR: odoo/enterprise#38350
Task id: 3010716

closes odoo/odoo#118790

X-original-commit: c8174c7914e567489de74b574b076467440bdb2d
Related: odoo/enterprise#39879
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-04-17 18:01:18 +02:00