Commit Graph
15850 Commits
Author SHA1 Message Date
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 5925001c19 [IMP] account: tests framework: add explicit label to invoice lines created with only amount, to avoid crashing in some tests
We also inject a context key to ignore prediction in case account_predictive_bills (enterprise) is installed. This way, having the same label on invoice lines generated by the helper will still behave in the same way, even if enterprise is installed.

closes odoo/odoo#67998

X-original-commit: b6c37754532ae6a7cc1f68a345fde6258abdc893
Related: odoo/enterprise#17125
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-03-17 09:30:39 +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
Laurent Smet fbe1cca0d6 [FIX] account: Set 'move_id.ref' as payment memo with vendor bill
The current behavior was to set the label as memo in the payment register wizard.
However, this is to restrictive when a vendor bill hasn't any payment reference but a bill reference.
In that case, the user is expecting to have the bill 'ref' in the payment 'memo'.

Since the matching rules in the reconciliation widget are matching line.name, then line.move_id.ref and then line.move_id.name, the same logic is applied here to construct the payment 'memo'.

closes odoo/odoo#68004

Opw: 2440389
X-original-commit: 92ceb86d58f4d78c8a4256f29d101d3730517b93
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-03-17 11:08:05 +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
Romeo Fragomeli 3be272361e [IMP] account,sale: show product image in kanban SO
Before this commit, in the kanban view of sale order lines, the
product's image was not visible.

This commit adds the image to be more consistent with the kanban view in
accounting.

Note: we have also tweaked the view in accounting for better clarity.

Task ID : 2200168 (6.b)

closes odoo/odoo#67691

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2021-03-12 14:49:29 +00:00
Romeo Fragomeli 841d29f129 [FIX] web, account: dashboard's links are not well placed on mobile
Before this commit, on mobile in the Accounting app, the link in a
kanban card was not well placed.

After this commit, in mobile we consider a link as a block so he is
moved below.

Steps to reproduce:
* Open Odoo on Mobile
* Go to Accounting => Bug ("Create Manually" is in a strange position)

Task ID : 2200168 (4.a)

closes odoo/odoo#67692

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2021-03-11 16:22:29 +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
Goffin Simon 87fbc4faa2 [FIX] account: Entries from Expense journal
Steps to reproduce the bug:

- Create an Expense E
- Create a report R from E in the journal J (type=purchase)
- Generate the journal entry JE from R
- Go to Accounting Dashboard and click on J in the kanban view

Bug:

JE was not displayed in the entries filtered for J

PS: When creating a journal entry from an expense sheet, the move_type of the entry
is 'entry'.

opw:2474729

closes odoo/odoo#67674

X-original-commit: 31ca461ee3a6b9560fe6d78642e8fe5017b1085e
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-03-11 12:08:08 +00:00
Florian Gilbert e131ce8e54 [IMP] account: move lines group by move views improvement.
This commit modifies the views of the move lines grouped by
move. Its purpose is to optimize the UI.

Task ID: #2443795

closes odoo/odoo#66928

Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-03-10 12:00:30 +00:00
Laurent Smet 25dcf48225 [IMP] account: Allow tax to not be affected by a previous one
In India, we need to configure taxes like this:
- 6% applied on base amount
- 6% applied on base amount
- 1% applied on 1.12 * base amount

If both 6% taxes are affected the base of subsequent taxes, it gives the following result:
- 6% applied on base amount
- 6% applied on 1.06 * base amount
- 1% applied on 1.06 * 1.06 *  base amount

Thanks to the new 'is_base_affected' field set on the second tax, it gives the expected results.

closes odoo/odoo#66134

Task: 2343958
Related: odoo/upgrade#2254
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2021-03-08 15:37:08 +00:00
Paul Morelle 2a32f6184f [FIX] account: avoid useless account move synchronization
Account move synchronization has already taken place during the creation
of the moves. No need for this additional check during the
reconciliation itself.

This commit helps when a lot of move lines are being reconciled at once.
For instance, the duration of the reconciliation of a batch of about 700
payments on a large database took 20 minutes before this commit, and
takes about 4 minutes after this commit.

closes odoo/odoo#67447

X-original-commit: e883fffaebd05727b399b26ca86cc54df79cde93
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-03-08 10:05:14 +00:00
Laurent Smet cc07cfdb69 [REV] account: Revert "set memo to ref if not payment_reference"
This reverts commit a59f255ef33c47449d028930e15c5390c62e39ed.

github issue: 67098

closes odoo/odoo#67255

X-original-commit: 86e2c6b7126e2e73f5acfc7ebfee490808a70df7
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-03-04 14:32:38 +00:00
wan 9b3c19b41e [FIX] account: fix standalone test with demo data creation
The test is running in sudo mode, so we need to specify the company in
the search.

Also do not load the demo data when installing as we would do the work
twice for most localization.

closes odoo/odoo#67235

Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-03-04 14:11:50 +00:00
qdp-odoo bb1f14e728 [IMP] hr_expense: add "payment_status" field + change error msg
- Add "payment_status" field to be more explicit.
- Turn error message "Expenses must have an expense journal specified to
  generate accounting entries." into "Specify expense journal in tab
  Other Info to generate accounting entries."

closes odoo/odoo#65528

Task: 2424870
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-03-03 09:39:46 +00:00
Laurent Smet 7791a0bf1e [FIX] account: Fix tests depending the date after 18 months
Tests are crashing when the number of months between the data date and today is higher than 18 months due to the 'past_months_limit' field on account.reconcile.model.

closes odoo/odoo#67051

X-original-commit: fd2c14374598b7009b70196ccc6ac3607b30245a
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-03-02 11:32:27 +00:00
Laurent Smet 75df756751 [IMP] account: Use currency rate when populating journal entries
closes odoo/odoo#67036

X-original-commit: f6761a7e8b012f5357711303af532fa0ac5bd77a
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-03-02 09:16:29 +00:00
Laurent Smet 4eb1cb2fd7 [FIX] account: Fix always set currency_id on aml with populate
Since 14.0, 'currency_id' and 'amount_currency' should always be filled when creating account.move.lines.

X-original-commit: 7827875271adafbfc656fe09c87e37e7d1a3802f
2021-03-02 09:16:29 +00:00
Odoo's Mergebot 64749aaeaf [FW][FIX] *: various localisation issues
Cf commit messages, courtesy of Erwin van der Ploeg

closes odoo/odoo#66983

Forward-port-of: odoo/odoo#66940
Forward-port-of: odoo/odoo#66790
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-03-02 10:30:29 +01:00
Martin Trigaux f1f41b68b7 [FIX] account: translate "Balance Sheet" selection
Was using the wrong method to translate

X-original-commit: 57611ac95718643b2cb03871e655864dbd74967a
2021-03-01 10:31:33 +01:00
Martin Trigaux 706ff8fbff [FIX] account: translate selections
X-original-commit: 4b6e933d5826830b24297355a9cea8a8615bc646
2021-03-01 10:31:31 +01:00
Martin Trigaux 52a7efbaf5 [FIX] account: translate wizard line message
X-original-commit: 2f3701d97568d965a7665bf7126032d3b7527ae4
2021-03-01 10:31:30 +01:00
alt-odoo f241fc6504 [FIX] account: wrong journal in test_match_multi_currencies
A move with type 'entry' cannot be posted in a 'sales' journal. It should be
the default 'miscellaneous' journal instead.

closes odoo/odoo#66851

X-original-commit: 1c45685922b5561b8bce1c91b158184837391089
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
2021-02-25 13:40:32 +00:00
alt-odoo ecd94d6978 [FIX] account: wrong sequence number reset for refund type moves
In case a yearly sequence is set for out_invoice/in_invoice types and if we set
a monthly sequence on the corresponding out_refund/in_refund type, we will not be
able to validate the refund the next month as it will be wrongly identified as a
yearly sequence. We should include the move type when retrieving the last
sequence name instead.

X-original-commit: 612f453a7424c582ba0f581b241d9a41f8908e2c
2021-02-25 13:40:32 +00:00
Laurent Smet bbc6ed0323 [FIX] account: Fix analytic lines when reconciling a statement line
When reconciling a statement line from the bank reconciliation widget, the journal entry of the statement line is already posted and then, the analytic lines was never created.
This commit fixes the issue by refreshing the analytic lines at the end of the statement line's reconciliation.

closes odoo/odoo#66850

Opw: 2466236
X-original-commit: 2c38dc6e34ebb8d4590adead74ebf02fee40d66a
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-02-25 15:48:58 +00:00
Laurent Smet 89d5237547 [FIX] account: Fix reversal of exchange diff entry when unlinking the full reconcile
Suppose an invoice of 1200USD = 3600EUR reconciled with a payment 1800USD = 3600EUR.

The generated exchange difference journal entry is:
600USD = 0EUR because 1800 - 1200 - 600 = 0 and 3600 - 3600 = 0
=> Everything is reconciled and all residual amounts are 0.

Remove the reconciliation. The exchange difference entry is reversed in other to cancel it.
Because the current exchange difference entry contains a line of 600USD, the reversal is creating a line of -600USD.

Before this commit:

Because both lines were sharing the same foreign currency (EUR) but have an amount_residual_currency of 0, no partial was created and then, a new exchange difference was generated in order to fix the amount_residual of 600 in USD.

After this commit:

A partial is created to handle the residual amount in USD even the residual amount in foreign currency is already zero.

Note: this issue is also there when the reconciliation is made using the company's currency with different foreign currencies.
In that case, amount_residual is zero but not amount_residual_currency.

closes odoo/odoo#66825

Opw: 2450699
X-original-commit: 07d5735de0e1b3080676ab26e872e55120fa2628
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-02-25 11:47:06 +00:00
Florian Gilbert c61f32ecef [IMP] account: Back 2 Basics improvements
Now when duplicating a bank or cash journal, the outstanding accounts are
the same as the original journal.

Added a compute method for payment_credit_account_id and payment_debit_account_id
to retrieve the default value from the company. These default accounts can be
changed in the settings.

Change UI for some settings (Default accounts).
Moving transfer_account_id into account module (from account_accountant).

Changing the tree view of account.journal:
  - Edit journal_group_ids: Optional show
  - Add currency_id: Optional hide
  - Add code: Optional show
  - Add default_account_id
  - Add payment_debit_account_id: Optional hide
  - Add payment_credit_account_id: Optional hide
  - Add active: Optional hide
  - Edit company_id: Optional hide

Task ID: #2451842

closes odoo/odoo#66087

Related: odoo/enterprise#16314
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-03-01 09:10:45 +00:00
Nicolas (vin) 620412fa0a [IMP] account: Hide the search panel when opening the app menu from acc
The search panel showing app categories in the app list is unnecessary
when opening the list with the context of searching for a localization.

This will change it so that panel is hidden in this case.

task id #2370971

closes odoo/odoo#61456

Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-02-26 14:27:14 +00:00
Adrien Widart 0f202b2222 [FIX] account: register attachment only if it exists
When printing an invoice, the server tries to register one attachment as
main one (see #65320). However, if there is not any attachment, this
will raise an error.

OPW-2465995

closes odoo/odoo#66755

X-original-commit: 03d2e457b69b07f315187cd7f7299be4c838e177
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-02-24 12:51:41 +00:00
Nicolas (vin) 7c9c9e391a [IMP] account: add mail template for send&print credit note
There is only a single mail template for invoices at the moment.
To make things easier to work with, this will add a new template for
credit notes.

Task id #2343331

closes odoo/odoo#58244

Signed-off-by: William André (wan) <wan@odoo.com>
2021-02-22 12:51:48 +00:00
Laurent Smet 98156d0eb8 [FIX] account: Fix missing dependencies of '_compute_is_reconciled'
closes odoo/odoo#66572

X-original-commit: 367ffd7757cf892c2ad08cc0bf35f23d78083ccc
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-02-19 17:55:59 +00:00
Laurent Smet 62dc50bf7e [FIX] account: Fix use_in_tax_closing on 'base' lines
This field shouldn't be visible on the view for 'base' repartition lines.

closes odoo/odoo#66570

X-original-commit: 69ba2db0cb480c298400fa0bbcbb1a7aa9a0a96b
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-02-19 17:54:11 +00:00
Adrien Widart 649eedaa2e [FIX] account: set main attachment only for posted invoices
When printing a draft invoice, it raises an error.

The error comes from fix #65320: the latter registers the printed
invoice as main attachment, but this needs to be done only with posted
invoices.

OPW-2427247

closes odoo/odoo#66563

X-original-commit: 49a57dd5b34b66733564b31ed861fe9bfcbda2b3
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-02-19 17:03:10 +00:00
Laurent Smet ec396230d4 [FIX] account: Set memo to ref if not payment_reference
Issue

	- Install "Accounting" module
	- Create a new bill :
	- Set vendor
	- Set no payment reference
	- Set a bill reference
	- Add products to bill
	- Confirm and click on Register Payment

	Memo field has no value.

Cause

	The memo field is based on lines name.
	Lines name is computed in `_onchange_payment_reference`
	and depends only on payment_referecence.

Solution

	If no `payment_reference`, fallback on `ref` to set line name.

opw-2440389

closes odoo/odoo#66491

Co-author: nboulif <bon@odoo.com>
X-original-commit: 7a7dc212af7279544cffba362bce7daa4fc00865
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-02-18 16:05:57 +00:00
Martin Trigaux 9741ef5ee6 [I18N] *: export saas-14.2 source terms
For odoo-master Transifex project, no demo data

closes odoo/odoo#66500

X-original-commit: 813931ac850e5ba4181259a5957ec72226fb670c
Related: odoo/enterprise#16510
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-02-19 08:02:58 +00:00
Nasreddin (bon) f234b4fba4 [FIX] account_facturx: Parse pdf attachment
Solution is different in the case of the foward-port, see bellow.

Issue

	- Init an instances of Odoo v13.0 'A' and v14.0 'B'.
	- Install "Accounting" app on instance A & B.
	- Set your email server on instance A & B.
	- Activate 'External email server' in settings of instance A.
	- Set an email alias for "Vendor Bills" on instance A.
	- Send a "Customer Invoice" from instance B to alias of instance A.
	- Fetch for new mail (in case new vendor bill don't appear) on instance A.
	- Open the new Vendor bill on instance A.

	Data are not parsed from pdf attachment.

Cause

	No managing all attachements types:
	- list(tuple(str,str), tuple(str,str, dict) or int) attachments : list of attachment tuples in the form
          ``(name,content)`` or ``(name,content, info)``, where content is NOT base64 encoded
	- list id attachment_ids: list of existing attachement to link to this message
          - Should only be setted by chatter
          - Attachement object attached to mail.compose.message(0) will be attached
            to the related document.

Solution

	In this fw-port, we override `_message_post_after_hook` instead of
	`_message_post_process_attachments` because the later is also called
	from portal and with sudo rights. We don't want to update invoices with
	files coming from portal, since it could cause a security issue.
	Also, because of the way attachments are parsed for invoice, this could
	cause the OCR not to work any longer because at the time
	`_message_post_process_attachments` is called,`move.message_main_attachment_id`
	is not set yet, and OCR relies on it.
	The solution is rather to override `_message_post_after_hook` because
	it ensures that all the attachments have been properly treated and are
	present in `new_message.attachment_ids`, and `message_main_attachment_id`
	is properly set.

opw-2411002

closes odoo/odoo#66458

X-original-commit: 0f6ad2a690f76d6bbbe92106fc8360f99eaac6c2
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2021-02-18 12:48:34 +00:00
Goffin Simon d4b6ee53f9 [FIX] account: Printing journal entries"
This commit ba32244c10396ff8605e5533e08675a64fbf9d88 introduced an error when
validating pickings or reconciling

closes odoo/odoo#66366

X-original-commit: b20e689659a3e1c89279caf028592bf18a17c4f7
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-02-17 13:25:03 +00:00
wan db6d031bba [FIX] account: wrong batching to compute the name
Reproduce:
* Create one move in a journal
* Create another move in another journal but in the same year
* Both journals should have a yearly sequence reset
* Post both moves at the same time

Bug:
They both are using the same sequence.

Expected:
Both should be using their own sequence.

closes odoo/odoo#66383

X-original-commit: f816c326f348ff78a982f91a736cc005d3e0cd31
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-02-17 15:02:29 +00:00
Adrien Widart b63e4ad8de [FIX] account: set printed invoice as main attachment
When printing some invoices, they are not registered as main
attachment. Therefore, when sending a follow-up report, a UserError
message asks the user to print the invoices first.

To reproduce the error:
(Need account_accountant, use demo data)
1. Go to Accounting > Configuration > Invoicing > Follow-up Levels
2. Select "First Reminder Email"
3. Enable "Join open Invoices"
4. Create an invoice INV01 for customer C01 + Post INV01
5. Go back to Accounting > Customers > Invoices, select INV01
	- ! Do not open the invoice. Just select it.
6. Print > Invoices
7. Go to Follow-up Reports
8. Select C01
9. Send by mail

Error: An error message is displayed: "You are trying to send a followup
report to a partner for which you didn't print all the invoices" but it
does not make sense because the invoice has been printed.

For a follow-up report to be sent, the invoices must have the field
`message_main_attachment_id` defined (see
[code](https://github.com/odoo/enterprise/blob/476d862aba396c54c7a47950e02af7aed008a2db/account_followup/models/account_followup_report.py#L311-L313)).
There are two ways for this field to be set:
- When sending the invoice, `_message_set_main_attachment_id` is called,
select one attachment and mark it as main one
https://github.com/odoo/odoo/blob/437b49860b46b5abb8f55ced349fece984968998/addons/mail/models/mail_thread.py#L1918-L1924
- When opening the invoice, if the sreen is large enough, a pdf viewer
is opened next to the invoice. This pdf viewer will call
`register_as_main_attachment`, the latter marks the `ir_attachment` as
main one:
https://github.com/odoo/odoo/blob/e6a41b118a94c5b101d127f6b70fc54958e9346b/addons/mail/models/ir_attachment.py#L17-L20

However, when the user only prints an invoice, nothing will set the
`message_main_attachment_id` field. Thus, this fix will call
`register_as_main_attachment` when a pdf is generated and will mark it
as main attachment.

OPW-2427247

closes odoo/odoo#66356

X-original-commit: 643e7b06aee2a91190a3a7271211e70e4888d595
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-02-17 12:27:31 +00:00
wan 7da284ea5b [FIX] account: assertTaxGridAmounts independent from demo data
Part of task 2124952

If another company uses the same tags, they showed up in the assert.
2021-02-17 08:39:28 +00:00
wan 3b086e75da [IMP] account: make test class usable for l10n without tax
Part of task 2124952

This is required to run tests defined in l10n_ar for instance
2021-02-17 08:39:28 +00:00
wan d31c5c70e0 [IMP] account: make demo data for all localization
Task 2124952

Extract all the demo data from `l10n_generic_coa` to a new way of
generating the demo data for accounting modules.
Because the data needs to be created multiple times, and right after the
chart template instanciation, it cannot be done the usual way. Instead,
we use python generators to declare the data. It allows us to reference
data that was not created yet at the start of the creation of the demo.
An xml_id is given, prefixed with the id of the company it is created
for (just like the instanciation of the chart template)

To find the correct accounts, a helper method has been added to
`account.account`. It will look for an account with the correct xml_id
(which is the one of the l10n_generic_coa, that we have to put on the
other l10n modules too, in the future). If it didn't find the xml_id, it
will look for an account with the correct type. If it still didn't find
one, just take any account.
2021-02-17 08:39:28 +00:00
oco-odoo a967eb3fa7 [FIX] account: tax_tag_invert computation on aml: add missing dependencies
closes odoo/odoo#66203

X-original-commit: e1b23c3ebc43a48fdd5dc70a5250c8f63b66d20d
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-02-15 17:05:13 +00:00
wan ce2115966c [FIX] account: don't return recordset on action_post
Fixes #65706

closes odoo/odoo#66258

X-original-commit: 398751954ef1735bfb2757328189cf57f8beeb1c
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-02-16 12:06:18 +00:00
Joseph Caburnay 51a08bbfa3 [IMP] point_of_sale: show wizard when closing pos.session failed
When closing pos.session and it turned out that during the creation
of journal entry the move lines are not balanced, pos automatically
balances the lines by crediting the amount to balance and recording
it to the default pos receivable account.

In this commit, we are changing the behavior by allowing the user
to choose which account the imbalance amount be recorded. So the
workflow becomes:

1. Close pos session fails.
2. Wizard shows the amount to balance and asks which account to
record it.
3. Confirm the wizard to successfully close the session.

closes odoo/odoo#62425

Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2021-02-15 12:06:31 +00:00
Anh Thao Pham (pta) d85889f50f [FIX] account: fix counterpart values of Reconciliation Models for Statement Line with no Partner
- Go to Accounting > Configuration > Reconciliation Models
- Create a Reconciliation Model:
  * Type: Suggest counterpart values
  * Amount Nature: Amount Paid/Received
  * Label: Contains test
  * Counterpart Values: [Add a line with "Percentage of balance" as Amount Type and 100 as Amount, for example]
- Create a Bank Statement of any amount with "test" as Label and no Partner
- Post Bank Statement and Reconcile it
Created Bank Statement matches conditions of Reconciliation Model but Counterpart Values are not suggested.
No counterpart values are suggested if there is no Partner on Bank Statement

During preparation of reconciliation, reconciliation is skipped because an open balance
has to be created but no receivable/payable account is retrieved as there is no Partner
on Bank Statement.

If no Partner is set, receivable/payable account is retrieved from company.

opw-2441484
opw-2442491

closes odoo/odoo#66167

X-original-commit: b9052f30dd8c26e0402a7f4a55b72204e9f1e633
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-02-15 12:48:08 +00:00