Commit Graph

126 Commits

Author SHA1 Message Date
Pedro M. Baeza
4f48467f71 [FIX] contract: Proper cron execution on multi-company
The invoice generation was only done for the last company found, as it
was called outside the loop.
2022-05-04 21:07:48 +02:00
OCA Transbot
e078e5ac6c Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: contract-10.0/contract-10.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-10-0/contract-10-0-contract/
2020-08-16 11:43:32 +00:00
Mario Montes
6240f066b7 Translated using Weblate (Spanish)
Currently translated at 100.0% (99 of 99 strings)

Translation: contract-10.0/contract-10.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-10-0/contract-10-0-contract/es/
2019-11-12 18:34:46 +00:00
OCA-git-bot
9d8b35fcd9 contract 10.0.4.3.1 2019-09-10 09:15:53 +00:00
OCA-git-bot
6c1a5d1d42 Merge PR #315 into 10.0
Signed-off-by pedrobaeza
2019-09-10 07:31:44 +00:00
sergiocorato
de5752d3dc Merge branch '10.0_imp_sequence_journal' of git+ssh://github.com/efatto/contract into 10.0 2019-08-13 15:20:40 +02:00
Ronald Portier
a666728774 [FIX] contract. Prevent wrong contract count.
Contract count could be wrong if the current date for the user is not the
UTC date.

So a contract created in for instance the Amsterdam timezone just after
midnight, would get maybe the 16th of july as date_start. but
_compute_contract_count would look for contracts valid on the 15th of july.
2019-07-18 11:27:13 +02:00
Maria Sparenberg
d73f0e2404 Translated using Weblate (German)
Currently translated at 100.0% (99 of 99 strings)

Translation: contract-10.0/contract-10.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-10-0/contract-10-0-contract/de/
2019-06-28 13:42:36 +00:00
OCA Transbot
d6c9ef2632 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: contract-10.0/contract-10.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-10-0/contract-10-0-contract/
2019-06-06 00:08:26 +00:00
oca-travis
c7068e4b05 [UPD] Update contract.pot 2019-06-06 00:08:03 +00:00
Ronald Portier
14f3cc2775 [10.0][IMP] contract. Enable automatic invoice generation before invoice date. (#282)
* [IMP] contract. Enable automatic invoice generation before invoice date.

* [IMP] contract pregenerate - improvements after review.
2019-06-06 01:32:08 +02:00
sergiocorato
71b886866f [IMP] add sequence in search default journal 2019-04-05 17:55:03 +02:00
Maria Sparenberg
1270a0a772 Translated using Weblate (German)
Currently translated at 100.0% (96 of 96 strings)

Translation: contract-10.0/contract-10.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-10-0/contract-10-0-contract/de/
2019-04-03 02:49:26 +00:00
OCA-git-bot
9d74f7faa5 [ADD] icon.png 2019-04-03 02:42:46 +00:00
Marta Vázquez Rodríguez
bec24343af Translated using Weblate (Spanish)
Currently translated at 100.0% (96 of 96 strings)

Translation: contract-10.0/contract-10.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-10-0/contract-10-0-contract/es/
2019-02-04 14:50:18 +00:00
OCA Transbot
2026bcca3a Update translation files
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
2019-01-24 19:48:28 +00:00
oca-travis
262c746580 [UPD] Update contract.pot 2019-01-24 19:48:04 +00:00
Jairo Llopis
173b2b2db2 [10.0][IMP] contract: Performance boost 🚀
With this patch we save about 83% of the execution time when generating invoices in batch.

# Optimizations made

## Recompute once at the end of the batch

This part avoids recomputing many fields per record. Instead, global recomputations are triggered at the end of the block:

```python
with _self.env.norecompute():
    ...
    invoices.compute_taxes()
_self.recompute()
```

Notice the explicit call to `compute_taxes()`, which was explicit before also, but it was done once per invoice, losing batch-computing boost.

## Disabling prefetch for extra fields

It's done in this part:

```python
_self = self.with_context(prefetch_fields=False)
```

Prefetching makes sense when we are going to use a lot of fields for a model that has only a few.

In our case, we are using not much fields, but the models involved have lots of them.

This produces more queries to get those fields, but the queries are noticeably smaller. At the end of the day, it saves a lot of time, which is what matters.

## Disabling track mail creation

This part does it:

```diff
         ctx.update({
+            'mail_notrack': True,
             'next_date': next_date,
```

It makes that when creating invoices, we don't create the "Invoice created" message.

## Precomputing price

Obtaining `price_unit` from `contract.recurring_invoice_line_ids` was quite expenisve in terms of CPU, and it was being made once per line, each one in a different context, which means also a different cache.

Instead of that, lines now share a single context, and are computed before starting the batch.

This code precomputes stuff:

```python
# Precompute expensive computed fields in batch
recurring_lines = _self.mapped("recurring_invoice_line_ids")
recurring_lines._fields["price_unit"].determine_value(recurring_lines)
```

And the usage of 2 different environments done inside `_create_invoice()` (`self` and `_self`) guarantee that the invoices are filled with the correct data, but also that the lines use the cached precomputed value instead of having to compute it each time.

# Performance gain

According to my tests, generating 10 invoices took 62 seconds before, and it takes about 18 seconds now.
2019-01-24 13:30:49 +00:00
OCA Transbot
d6cf976c84 Update translation files
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
2019-01-24 04:04:10 +00:00
oca-travis
901fd1504d [UPD] Update contract.pot 2019-01-24 04:03:44 +00:00
Ronald Portier
58e967f887 [FIX] contract. Optimize insertion of dates in invoice and lines. 2019-01-18 22:44:49 +01:00
OCA Transbot
2fc9eb5fc7 Update translation files
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
2019-01-15 10:45:06 +00:00
oca-travis
71f829a6d2 [UPD] Update contract.pot 2019-01-15 10:44:41 +00:00
Jairo Llopis
c23a752132 [FIX] contract: Process invoices limit in a lower method
To avoid blocking the queue when there are more than the specified limit
of contracts, we process the limit while creating invoices instead
of while searching for contracts, and break the process when the
max of invoices has been created.

See https://github.com/OCA/contract/pull/260#pullrequestreview-192187022
for more details.

In case you need to use this new feature in the cron, it is
also modified as `noupdate=1`.
2019-01-15 09:30:30 +00:00
David
be8e768905 [10.0] contract: allow to limit records on cron 2019-01-15 09:30:29 +00:00
Sunny Sheth
13acf42c62 [FIX] Issue-199: if not set Partner Language then language should be company's partner language for date format. 2019-01-08 23:11:18 +05:30
Pedro M. Baeza
5581a9048a [IMP] contract: Make price test more deterministic
As this uses demo data, it may returns an invalid price.
2018-11-16 18:25:59 +01:00
Pedro M. Baeza
738f75f65c [IMP] contract: Don't depend on external data
The test as it was, leaves to the demo pricelist the control on the price of
the product, so other modules that modifies this pricelist will make the
test to fail.

This is the minimum change needed for avoiding the problem.
2018-11-15 11:17:37 +01:00
Sergio Zanchetta
d918405b0a Translated using Weblate (Italian)
Currently translated at 76.0% (73 of 96 strings)

Translation: contract-10.0/contract-10.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-10-0/contract-10-0-contract/it/
2018-11-03 19:34:14 +00:00
lfreeke
f944b485c7 Translated using Weblate (Dutch)
Currently translated at 79.2% (76 of 96 strings)

Translation: contract-10.0/contract-10.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-10-0/contract-10-0-contract/nl/
2018-07-28 16:09:13 +00:00
lfreeke
998cd83307 Translated using Weblate (Dutch)
Currently translated at 72.9% (70 of 96 strings)

Translation: contract-10.0/contract-10.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-10-0/contract-10-0-contract/nl/
2018-07-27 15:09:19 +00:00
oca-travis
72fc61e92b [UPD] Update contract.pot 2018-07-21 21:55:07 +00:00
Dmytro Katyukha
cab7df4f1f Update addon versions
- contract
- contract_variable_quantity
2018-07-18 14:44:29 +02:00
Dmytro Katyukha
1d6cd308b0 Rename account_analytic_*_line files
In previous commit 'account_analytic_*_line' model files
were renamed to temporary names.

This commit renames these files to correct names
2018-07-18 14:40:44 +02:00
Dmytro Katyukha
3dec9ede41 Rename account_analytic_*_line files
In previous commit changed inheritance order of
'account.analytic.*.line' models, thus classes and models were renamed.

This commit only renames files to temporary names.

This commit does not change file contents.
2018-07-18 14:40:22 +02:00
Dmytro Katyukha
3c0c73c0f5 [FIX] analytic invoice/contract lines inheritance
Bug description
---------------

`account.analytic.contract.line` inherits
`account.analytic.invoice.line`

`account.analytic.invoice.line` defines field `analytic_account_id`:
   - comodel='account.analytic.account'

`account.analytic.contract.line` redefines field `analytic_account_id`:
   - comodel='account.analytic.contract'

On attempt to extend `account.analytic.invoice.line` model adding
field that depends on `analytic_account_id.date_start`
Odoo fails to update, because it adds this field to
`account.analytic.contract.line` through inheritance,
and `account.analytic.contract` model have no this field.

What is done
------------

Change inheritance order:
- `account.analytic.invoice.line` inherits
`account.analytic.contract.line`
- no file renames at this stage (this wil be done in next commit)
2018-07-18 14:39:16 +02:00
OCA Transbot
9bf323fccf OCA Transbot updated translations from Transifex 2018-05-26 04:16:44 +02:00
OCA Transbot
f4998a06fb OCA Transbot updated translations from Transifex 2018-05-05 04:13:46 +02:00
OCA Transbot
86c8389a8d OCA Transbot updated translations from Transifex 2018-04-21 03:40:29 +02:00
OCA Transbot
2158d517e6 OCA Transbot updated translations from Transifex 2018-04-14 04:12:00 +02:00
OCA Transbot
71319733e8 OCA Transbot updated translations from Transifex 2018-03-31 04:24:53 +02:00
Дмитро Катюха
a8ef7c939d [10.0] Added analytic tags to contracts
This commit adds ability to specify analytic tags on contracts invoice
lines, which will be propagated to invoice lines.
2018-03-28 18:52:29 +03:00
Pedro M. Baeza
c29a0ce7f8 [FIX] contract: Inverse of price unit referred to single record 2018-03-26 19:59:06 +02:00
OCA Transbot
526af8f324 OCA Transbot updated translations from Transifex 2018-03-24 04:16:05 +01:00
OCA Transbot
7c5679348e OCA Transbot updated translations from Transifex 2018-03-17 04:14:31 +01:00
OCA Transbot
26bd4e9bbf OCA Transbot updated translations from Transifex 2018-03-03 04:13:30 +01:00
OCA Transbot
d73cd79d61 OCA Transbot updated translations from Transifex 2018-02-03 04:14:55 +01:00
OCA Transbot
82d3401460 OCA Transbot updated translations from Transifex 2018-01-06 04:12:59 +01:00
Dave Lasley
817997270e Merge pull request #133 from Tecnativa/10.0-contract-automatic_price
[IMP] contract: Automatic prices for lines
2018-01-03 14:15:35 -08:00
OCA Transbot
364289e4cf OCA Transbot updated translations from Transifex 2017-12-30 04:10:19 +01:00