Steps to reproduce :
1. Create a new customer
2. Create an invoice with an amount of 50.- for this new customer and validate it
3. Create a refund with an amount of 70.- for the same customer and validate it
4. Create a Customer Payment for this customer and validate it. The Invoice will be paid with 50.- of the refund. 20.- are still on residual in the refund.
5. Create a new invoice with an amount of 50.- for the same customer.
6. Create a new Customer Payment for the same Customer and validate it.
The Full Reconcile Boolean stays checked inspite of "Open Balance" of Refund amount is less than the Invoice amount.
After the fix:
Full Reconciliation Boolean doesn't get checked and Allocation amount on invoice journal item line should be same
as Open balance of the Refund Journal Item. So Invoice stays open with Balance amount.
opw:691577
This is possible to unreconcile and then remove journal
items associated to `account.voucher.line`.
When it's done, the voucher is within a corrupted state,
with debits and credits lines without journal item, which
is required.
Because the journal item of this line is empty,
while required, this is no longer possible to use
the "Unreconcile" button, because the form is invalid.
In order to allow to unreconcile a posted customer/supplier
payments with missing journal items, we set
the journal items as required only when the payment
is within the `draft` stage.
opw-667232
When column 'writeoff_amount' gets displayed on a tree view and function
_get_writeoff_amount() is called with multiple ids, the returned amounts keeps
getting bigger every row.
Closes#7211
VAT error shouldn't be displayed as it doesn't look deep enough for information.
It is better to raise this kind of exception at the creation of a VAT than at its use.
opw:631769
In the accounting settings, we prevent having gain and loss accounts that are linked to a
different company than the one selected for the chart of account.
opw: 630494
The method recompute_voucher_lines() is used by several onchange methods of
account.voucher. It used to unlink() the voucher lines before recomputing new
voucher lines. As a side effect, if you edit a voucher and discard your
changes, your voucher has lost its lines, although you did not save your
changes! Moreover, the call to unlink() is invalidating the record cache,
which screws up completely the onchange() method.
So, instead of unlinking the existing lines, the onchange generates commands
[(2, id), ...] to remove the existing lines only when saving the changes.
The conversion of currencies in vouchers are made based on payment_rate_currency_id field (instead of usual currency_id).
This field was not present in the purchase view and not correctly set when we change the journal (and thus the currency) which was leading to rates of 1. With a rate of 1, the amount is equal to the currency amount (which is rarely correct). opw 611254
The field tax_amount is fieled with onchanges and the compute_tax method. Setting a different value than the one computed by the system may lead to unbalanced move (which is obviously wrong).
In the future, handeling these operations by setting the correct value to the tax accounts would be better.
The field partner_id is not required on an account.voucher but the validation was failing if none was set (opw 611663).
This patch makes a fallback on the account of the voucher if neither a partner nor a writeoff account is specified.
Fixing several issues for refunds in multicurrency mode that prevented the moves to be balanced.
The amount_currency needs to use the absolute value, as a refund will have a negative amount.
The sign for currency_rate_difference needs to use the line instead of the voucher as they can have different value. e.g. a voucher of 1000$ with invoice of 1200$ and refund of 200$ will have two lines and their currency_rate_difference should have different signs.
Avoids doubling the value in foreign_currency_diff
Fixes#1490, opw 607118 & 611580
When we cancel a voucher, we may be trying to unlink a reconciliation that was already removed on another move (just looking at the version in cache). In such cases, the unlink would fail with traceback. opw 610287
A squashed merge is required as the conversion of the apiculture branch from
bzr to git was not correctly done. The git history contains irrelevant blobs
and commits. This branch brings a lot of changes and fixes, too many to list
exhaustively.
- New orm api, objects are now used instead of ids
- Environements to encapsulates cr uid context while maintaining backward compatibility
- Field compute attribute is a new object oriented way to define function fields
- Shared browse record cache
- New onchange protocol
- Optional copy flag on fields
- Documentation update
- Dead code cleanup
- Lots of fixes