Since all the lines in a partial reconciliation share the same state and the same amount_residual, we need to keep only one 'result' line.
It was the first line found that was kept ; now it's the line whose amount is greater than amount_residual, whiwh most likely is the significant one.
Fixes#5129
In a workflow context (for instance, in the invoice workflow),
context is not passed.
Therefore, relying on the 'recompute' key being the context
in order to not recompute the fields does not work with Workflows.
It leads to huge performance issues,
as fields are recomputed recursively (instead of sequentially)
when several records are implied.
For instance, when reconciling several invoices with one payment
(100 invoices with 1 payment for instance),
records of each invoice are recomputed uselessly in each workflow call
(for each "confirm_paid" method done for each invoice).
With a significant number of invoices (100, for instance),
it even leads to a "Maximum recursion depth reached" errror.
closes#4905
When having an invoice with multiple lines having the same
product_id and account_id, the residual amount was wrong.
This is due to the fact the residual amount of each line
was computed on the residual amount of the invoice divided
by the number of lines of the invoice, and the fact the main
select of the sql view was grouped by product_id, account_id.
So, for an invoice defined as
Product Account Total
A 1 10
A 1 10
B 1 10
The invoice analysis, grouped by product, account, computed
Product Account Total Residual
A 1 20 10
B 1 10 10
The residual amount '10' of the first line being
30 (the residual amount of the invoice)
divided by 3 (the number of lines in the invoice)
The residual amount of the invoice should actually be divided by
the number of lines in the invoice * the count
of occurences in the group by clause
So, in this case, (30 / 3) * 2 = 20
Replacing the big jointure by
SELECT count(*) FROM account_invoice_line l where invoice_id = ai.id
to get the number of lines in the invoice
is just an optimization for performances
opw-621672
A record rule exists on currencies but not on rates.
If creates multiple currencies with rate = 1, we could fetch the wrong one in
the search and get a security exception while trying to convert rates.
Fixes#3323, opw 626353
This rev. is related to 6641c61ce6
During the above revision, a new jointure has been added
with product_uom, on product template uom_id
The join link was wrong, it was:
- LEFT JOIN product_uom u2 ON u.id = pt.uom_id
and it must be:
- LEFT JOIN product_uom u2 ON u2.id = pt.uom_id
as the alias 'u' is the previous jointure, not this new one.
Besides, the uom_name is now the name
of the product uom of this second jointure
As the uom is now the product default uom
instead of the category reference uom
The groupby clause has been adapted, as the selection was slightly altered
Besides, grouping by u.uom_type, u.category_id was pointless
Prevent creating/modifying accounting entries made on close periods.
The period_id and journal_id field on a account.move.line is a related so was
silently (without write call) updated so did not triggered the call to
_update_journal_check while modiying the linked account.move
Force the check in the validation of the move. As the move can not be balanced
without going through this method, this will prevent posted entries in closed
accounting period.
Fixes#1633, opw 615886
When fetching the VAT reports for several periods, only the last period was took into account
This is due to the fact that a browse record assignation no longer works in Odoo 8.0 API
at least not the same way.
code.sum_period = sum_tax_add just do nothing in Odoo 8.0.
Besides, using the variable "code" outside its loop is kinda crappy.
If the report was printed from the tax codes list
Accounting > Configuration > Taxes > Tax codes
There is no information concerning what should be displayed (periods, details, etc.)
as the user did not printed the report from the wizard
(from Accounting > Reporting > Generic Reporting > Taxes > Taxes report)
We therefore set default values, in order the report to not crash
Nevertheless, the user has obviously to go through the wizard
if he wants to set a configuration different than the default one
Before 8.0, the field journal_entry_id did not exist.
For database coming from older release, like 7.0, this field is not filled in during the migration, because this is not possible.
Set the needaction to depend only on the journal_entry_id will have as effect to have every bank statement line entered when the database was under 7.0 to match the domain, while the needaction is made to display the number of records that need an action.
Besides, even in 8.0, this is possible that a line has not the journal_entry_id set, while not needing any actions (see 2bb38ca89d)
For bank statement line having an account_id, but no journal_entry_id, it is not possible to reconcile the line in the bank statement reconciliation tool, as a filter is applied to only reconcile lines having journal_entry_id AND account_id not set.
As written in the help message of the account_id field:
This technical field can be used at the statement line creation/import time in order to avoid the reconciliation process on it later on. The statement line will simply create a counterpart on this account
Not allowing the reconciling should not prevent to close the statement in such a case. The button "close" was displayed only when all lines had journal_entry_id set.
Once the bank statement reconcilation done, the back button should not come back to Home when it does not found the bank statement list in the breadcrumb history, but simply perform a history_back action, which will come back to the previous action, the statement form for instance.
opw-625397
Revert edbd0df
Instead of removing the demo data (demo data is our friend), make the test more
specific, adding a date to match the rate of 1.5289 all year long.
Old demo data hardcoded the currency rate of USD to 1.5289 at the half
of the year, introducting new year red runbot.
Using assertAlmostEquals to avoid values like 32.730000000000004
Partners totals were not correct if the partner paid partially an invoice in advance
For an invoice of 20.000 in the future, with a payment made in advance of 5000
The column not due must contains 20.000, as the amount is not yet due
One of the column 1-30, 30-60, ... (accordingly on when the payment was made). must contains -5000
The total should be 15.000
This is related to rev. db98434e85
rev. abe5c803a0 forgot some partial reconciliations when the date domain was other than BETWEEN (for instance, <= stop date or >= start date, alone, not between)
Besides, the rev. abe5c803a0 did not care about account move being posted or not.
rev. db98434e85 took several times the same partially reconciled moves lines
Add restriction on product_id field to prevent the suppression of the product
if already present in an invoice.
This is to avoid the suppression of a used product variant when modifying
the list of attributes.#
Due to the constrain, the variant will be disabled instead of deleted.
Fixes#4129
Add warning message on the product form to warn users about the potential impact
of modifying variants.
The key 'novalidate' is added in the context when an operation not impacting
the validation of a move is made. The validation recreates analytic lines
which decrease the performances.
In case of registrating a payment, the skipped validation are the one from
the reconcile method (reconciliation does not change the validity)
Fixes#3787, opw 618529
During rev. cbe2dbb, type2journal was refactored, and set as a global variable in the top of the file, as it was use everywhere accross the file.
But, in this specific method _get_journal_analytic, this type2journal dict wasn't the same as everywhere else, as you can see at rev. d2ff95f for example. We must therefore set a specific type2journal dict for this specific method.
If a company contact (a partner with a company set as parent) had invoices, and the company of this contact was duplicated, all the invoices lines were duplicated, on the original invoice moreover (new lines were added on existing invoices)
- find a move line whose amount exactly matches the bank statement line amount even if it has no partner
- properly handle multicurrency
- if there's no exact match, look for a set of move line whose amount is <= to the statement line's amount
The payment term description (note) is meant
to be shown to customers. Restore it in the
default invoice report, as it was in 7.0.
If empty, assume the payment term is meant
to be hidden from customer, and do not show
anything.
By default the description includes the name
of the payment term, so no need to keep both.
the field section_id is created in addon sale, but used in the account
reporting views. This commit moves the search view definition
in the correct file.
The report includes all due payments, not only the one after the maturity date.
The maturity date is displayed in the report so no confusion is possible for payments below the maturity date.
Fixes#3064
[FIX] account: Preserve analytic account on tax lines which are on same general account as invoice line
After careful analysis, I'm now convinced it is a good thing to preserve
the analytic account on taxes line which have the same general account
as the invoice line.
This is the best default case and will save time for users,
while leaving the flexibility to adapt the analytic account on
taxes manually.
[FIX] account: Error when manually adding analytic account in the generated tax lines on an invoice
fixes#374
fixes https://bugs.launchpad.net/ocb-addons/+bug/1084822
The fix considers invoice tax lines with different analytic account
are equivalent for the purpose of checking if the list of tax line
is complete.
Caveat, this changes the structure of keys in the dictionary
returned by account.invoice.tax's compute method, I suppose this
is ok for the master branch.
When creating a new account.move.line, the computation of the default values should accept both `id` and `(id, name)` format.
The key partner_id may be containing a tuple so browsing should only be done on the first element of the tuple.
Fixes#3386
The store recomputation method failed as the search was made comparing id of account.move.line to the account.journal values. Search was returing no result most of the time (opw 615554)
Fixes#2454
The original tax should not be applied
if at least one destination tax was
applied. It should only be applied if
explicitly included in target taxes.
(Re-)Fixes #2261
General totals were not computed at all, due to the condition "if not self.ids" which was always true as self.ids wasn't set.
Besides, a parameter allows to display only partner with balance greater than 0, which was completely ignored by the totals computation methods: The totals always included all partners, even those having balance equals to 0
(This is a regression in Odoo 8)
It should now work when a fiscal position replaces 1 tax with
several taxes (for example : Fiscal position "Intra-EU B2B" in l10n_fr)
Fixes#2261, manual merge of PR #3316
First match a fiscal position for the given country, then for a country
group containing the country. If none found, search a fiscal position
without country nor country group
[FIX] account: reconciliation widget: for reconciliations with no partner, allow to select move lines from any partner and apply global move lines exclusion.
This way, the query method can be used with a custom domain. Such a domain
could match on a 'transaction_ref' field as well as on 'ref' and 'name'.
Example of implementation:
class account_bank_statement_line(orm.Model):
_inherit = 'account.bank.statement.line'
def _domain_reconciliation_proposition(self, cr, uid, st_line,
excluded_ids=None, context=None):
_super = super(account_bank_statement_line, self)
_get_domain = _super._domain_reconciliation_proposition
domain = _get_domain(cr, uid, st_line, excluded_ids=excluded_ids,
context=context)
new_domain = []
for criterium in domain:
if len(criterium) == 3:
field, op, value = criterium
if (field, op) == ('ref', '='):
new_domain += [
'|',
('transaction_ref', '=', value),
]
new_domain.append(criterium)
return new_domain
def _domain_move_lines_for_reconciliation(self, cr, uid, st_line,
excluded_ids=None, str=False,
additional_domain=None,
context=None):
_super = super(account_bank_statement_line, self)
_domain_meth = _super._domain_move_lines_for_reconciliation
domain = _domain_meth(cr, uid, st_line, excluded_ids=excluded_ids,
str=str, additional_domain=additional_domain,
context=context)
if not str and str != '/':
return domain
domain = domain[:]
domain.insert(-1, '|')
domain.append(('transaction_ref', 'ilike', str))
return domain
Commit f4e350ca3 defined an `onchange_company_id` method, never executed
because another `onchange_company_id` was defined below. Merged the first
in the second.
When no result is found on the function field 'invoice' (account.move.line), instead of returning {move_id: (False, '')}, return {move_id: False} (expected for m2o fields)
Fixes#2138, opw 613096
Looking for accounts with reconcile=True is enough.
Restricting on payable/receivable account types narrows the search
to much and makes it difficult to implement transfer account holding
the payment while they are in transit at the bank.
The methods product_id_change() and uos_id_change() have been converted to the
new api, and now use the decorator @multi. When invoked with the old api, by
convention the methods will take the last argument as the context. But this
will not work properly for those methods, as the context is passed in another
position. In order to avoid an argument swap in the api wrapper, we moved the
context to its expected position.
Fixes#1943
Otherwise, if done with the superuser:
- The multi-company rules won't work, the user will have the amount of all invoices, cross-companies
- The amount currency will always be the currency of the superuser
Explicitely refresh invoice browse_record(...) in order to have correct 'date' in account.move.
Use context_today() date instead of time.strftime() for date_invoice. (opw 611210)
At the confirmation of a bank statement, the name may not be set (e.g. generated by point of sale). This field is not requred so make a fallack on the statement line (which is required).
When the context contains 'recompute': False, the recomputation was not even
prepared. Now both create() and write() prepare the recomputation by invoking
method modified(). The flag only controls whether method recompute() is invoked.
In addintion, the former flag 'no_store_function' was converted to the flag
'recompute', so that both create() and write() use the same flag.
Fixes#1456
Avoid revalidating the complete account moves
that contain the lines being reconciled.
The reconciliation does not change the validity
of those moves anyway.
This represents a very important speed up of
reconciliation when moves with several hundred
lines are involved.
The residual amount is typically needed to render the
online payment forms (payment acquirers).
Payments on the other hand rely on account.move.line,
something that portal users should never be allowed to read.
Removing the field from the view by setting a model-level
group permission ensures they will not see an error.
The forward port of the fix 3609ba10f2 will be done separately, as the mrp scheduler has been completely refactored from saas-5.
Conflicts:
addons/l10n_be_coda/wizard/account_coda_import.py
addons/point_of_sale/static/src/xml/pos.xml
addons/procurement/schedulers.py
When computing the price difference lines, in move_line_get of account_anglo_saxon, we loop on the result of super call for each lines (n * n times) to compute the price difference.
The product_id was used to match the returned line and the original invoice line. This was wrong as we could get several lines with the same product_id (and then get n * n price difference lines).
This patch adds the line id to the result of move_line_get (from account) so that account_anglo_saxon can filter more efficiently and only get one price difference per invoice line.
Fixes#704
Problem: the field account_invoice.reconciled was invalidated by a workflow
signal sent from the compute method of the field. The purpose of the signal was
to re-open the invoice when the account move lines were no longer reconciled,
for instance after cancelling a reconciliation.
Solution: modify the workflow such that it makes an automatic transition from
'paid' to 're-open' when the condition 'not reconciled' is met. This works
because the field 'reconciled' is stored, and each recomputation forces a
reevaluation the workflow. The signal to re-open the invoice is thus no longer
necessary.