Commit Graph

92896 Commits

Author SHA1 Message Date
Goffin Simon 940a0e45d4 [FIX] account: choosing the right fiscal position
for a partner who has vat number, fiscal positions with vat_required
are prefered.

opw:630849
2015-03-24 13:00:39 +01:00
Anton Chepurov a70ea6d03b [FIX][#5182] speed up product form loading
removes obsolete (and faulty) check
2015-03-24 12:58:25 +02:00
Raphael Collet 0ed63d73a6 Merge pull request #5676 from odoo-dev/8.0-memory_optimization-rco
Reduce memory footprint of server

The tricks used are:
- use a global LRU for `ormcache` (auto-balancing between registries);
- remove unnecessary data structures (binary class hierarchy of models);
- compute some data structures on demand (`_all_columns`);
- optimize field attributes (empty collections may be shared);
- optimize memory size of fields and columns by using slots.

On a database with modules sale, purchase and stock installed, the memory footprint of the registry went from 20.3Mb to 7.4Mb (as measured with heapy). In other words, the memory footprint was reduced to 1/3 !
2015-03-23 14:39:21 +01:00
Raphael Collet 5aa23f8280 [IMP] ormcache: compute hit/miss/err statistics per database
In ormcache, those statistic numbers were counted per cached method for all
registries.  We introduce separate statistic counters, and create a counter per
(database, model, method).  The existing attributes that are no longer used
have been removed.
2015-03-23 14:36:15 +01:00
Raphael Collet 68969c9716 [IMP] fields: avoid redundant slot in class many2one 2015-03-23 14:36:15 +01:00
Raphael Collet c0d79a78f0 [IMP] fields: rename methods to avoid collisions with `__slots__` names 2015-03-23 14:36:15 +01:00
Raphael Collet 524bb0a520 [IMP] fields: simplify the definition of `__slots__` via the `Field` metaclass 2015-03-23 14:36:15 +01:00
Raphael Collet b156c2e27e [IMP] registry: adapt LRU sizes for registries and ormcache
The registry size is now assumed to be around 10Mb, and ormcache size is
proportional to the maximum number of registries.  Statistics about ormcache
usage is shown to the log when receiving signal SIGUSR1.
2015-03-23 14:36:15 +01:00
Raphael Collet 93c341a52c [IMP] models: avoid using `map` instead of a `for` loop (thanks chs@odoo.com) 2015-03-23 14:36:15 +01:00
Raphael Collet f93a14e3b2 [IMP] fields: remove comments about `_all_columns`, and improve its docstring 2015-03-23 14:36:15 +01:00
Raphael Collet 1df3467888 [IMP] fields: remove unnecessary code
In `__getattr__`, remove the test on accessing `_attrs`.  This situation should
never happen, since the attribute `_attrs` is set in method `__init__()`.
2015-03-23 14:36:15 +01:00
Raphael Collet 4259fe0072 [IMP] openerp/osv/fields: add `__slots__` on all column classes
Use the same technique as for field classes.
This saves about 1.6Mb of memory per registry.
2015-03-23 14:36:15 +01:00
Raphael Collet e7928e1265 [IMP] fields: add `__slots__` on all fields
Introduce slots on all field classes for common attributes; slots take much
less memory than a `__dict__`.  The other attributes are stored in a dictionary
`_attrs`; all fields with an empty value for `_attrs` (common case) share the
same empty dictionary.  This saves quite some memory (around 4.5Mb per
registry), given the number of field instances created for a registry.

Another mechanism is used for the default values of attributes, since slots
cannot be assigned on classes.
2015-03-23 14:36:15 +01:00
Raphael Collet 915af86a91 [IMP] fields: simplify definition of ID field 2015-03-23 14:36:15 +01:00
Raphael Collet ffa7f28d34 [IMP] fields: reduce memory footprint of list/set field attributes
The optimization consists in using tuples for attributes `inverse_fields`,
`computed_fields` and `_triggers`, and to let them share their value when it is
empty, which is common.  This saves around 1.8Mb per registry.
2015-03-23 14:36:15 +01:00
Raphael Collet 3df7754087 [IMP] fields: reduce memory footprint of `field._attrs` and `column._args`
The optimization consists in sharing the dictionary when it is empty, which is
the common case.  This saves around 1.5Mb per registry.
2015-03-23 14:36:15 +01:00
Raphael Collet 4d232969a3 [IMP] fields: remove attribute `_free_attrs` and use `_attrs` instead
This saves about 400Kb per registry by not allocating those lists, which are in
most cases empty.  The removal of the attribute will also simplify a bit the
management of free attributes.
2015-03-23 14:36:15 +01:00
Raphael Collet 9aad3d873b [IMP] fields: turn field.digits and column.digits into dynamic properties
The computed value of parameter digits is no longer stored into fields and
columns; instead the value is recomputed everytime it is needed.  Note that
performance is not an issue, since the method `get_precision` of model
'decimal.precision' is cached by the orm.  This simplifies the management of
digits on fields and saves about 300Kb per registry.
2015-03-23 14:36:15 +01:00
Raphael Collet bf703fd9a3 [FIX] models: reorder the base classes of models following an equivalent class hierarchy
Sometimes, the expected mro of the model is not the same as the one built with
a binary class hierarchy.  So we reorder the base classes in order to match the
equivalent binary class hierarchy.  This also fixes the cases where duplicates
appear in base classes.
2015-03-23 14:36:14 +01:00
Raphael Collet 9bce04de79 [IMP] models: build a flat hierarchy of classes for models
Instead of composing classes in a binary tree hierarchy, we make one class that
inherits from all its base classes.  This avoids keeping intermediate data
structures for columns, inherits, constraints, etc.  This saves about 600Kb per
registry.
2015-03-23 14:36:14 +01:00
Raphael Collet 0f9b452c33 [IMP] models: convert deprecated model._all_columns into a dynamic property
The mappings model._all_columns takes quite some memory (around 2MB per
registry) because of the numerous dictionaries (one per model) and inefficient
memory storage of column_info.  Since it is deprecated and almost no longer
used, it can be computed on demand.
2015-03-23 14:36:14 +01:00
Raphael Collet e2ea691cef [IMP] ormcache: turn it into a global LRU cache shared among registries
The ormcache is now shared among registries.  The cached methods use keys like
(DBNAME, MODELNAME, METHOD, args...).  This allows registries with high load to
use more cache than other registries.
2015-03-23 14:36:14 +01:00
Denis Ledoux e3a80afbaf [FIX] im_livechat: prevent translation of JS snippet
QWeb templates can be translated, javascript code
included. Nothing prevents you to translate
the javascript reserved word "undefined", for instance.

Preventing the livechat JS snippet to be translated
prevent translations mistakes, like translate
```undefined``` by ```Niet gedefinieerd```

opw-630335
2015-03-23 13:50:23 +01:00
Josse Colpaert 23873da6b6 [FIX] stock: quant_ids relations should not be copied when copying moves fixes #5848
The same holds for the inverse history_ids relationship.  When an object is copied,
the many2many fields their links are copied.

When we copy a done move as is done in the return wizard to create the reverse, it copied also
 the relationship with the quants.  This is problematic as this field indicates the quants that
were transferred by the move and the new move will think it will have returned all the quants
even before it is done.
2015-03-23 10:15:57 +01:00
Christophe Simonis 77a75d4e1f [FIX] web: remove leftover `future_display_name`.
see 694fe1f
2015-03-21 15:59:05 +01:00
Nicolas Lempereur efe8bfe5f1 [FIX] report_invoice: minor css fix to right align
A field was not rightly aligned in a report, this fix add a class which fixes this.

opw-630789 (fix by gab)
2015-03-20 16:16:07 +01:00
Nicolas Piganeau accd3b472a Fix unwanted opening of stock.picking when scrapping from production 2015-03-20 12:12:12 +01:00
Nicolas Lempereur d539be329e [FIX] view_form: add context to search_count
Currently, the view_form search_count doesn't propagate the context, so when
searching on a translated field, the count can be different than the one we
would expect and get with a search in a current language different than en_US.

opw-628792 opw-630212 closes #5825
2015-03-20 10:39:33 +01:00
Christophe Simonis 7780004f95 [FIX] web: correct many2one dropdown visibility.
The dropdown should only be append to visible elements.
2015-03-19 18:41:45 +01:00
Goffin Simon ac67ce4ecc [FIX] stock: quants not being reserved correctly
`product_qty` field is not recomputed at record creation.
Force field recomputation at any change
Removing the trigger on `product.product` should not be a problem as
product uom can't be changed once there are move lines.

opw:629650
2015-03-19 15:01:54 +01:00
Nicolas Martinelli 3da6c1a610 [FIX] web_calendar: reactivate the possibility to remove a calendar from side list
It is now possible again to remove a calendar from the side list
thanks to the 'X'

opw: 629511
2015-03-19 13:26:37 +01:00
Goffin Simon 05908a0fac [FIX] account_payment: supplier invoice on more then one payment oder
The field move_line_id in payment.order.form only shows account move lines that still have
an amount to pay. This was lost during 333e83f.
2015-03-18 16:45:25 +01:00
Dharmraj Jhala 01f2c5c9d2 [IMP] Allow custom ordering of files contained in zip dumps
This will allow to speed up our migration platform: as funzip can pipe
the output of the first file of the archive, even if the file is not
fully unzipped yet. This is useful to plays with dump.sql without waiting
for the full archive decompression.
2015-03-18 14:22:22 +01:00
Olivier Dony d93148240b [FIX] ir.model.data: update_dummy should mark `inherits` parents too
When a `noupdate` record is processed during an update,
the update_dummy method marks the record as "seen" so
it won't be deleted at the garbage collection step,
and seen as an obsolete external ID.

This needs to be done also for the parent records via
_inherits, because they have also received an implicit
external ID at creation, and must not be garbage
collected, even if their `noupdate` flag (db side)
is not set because the flag was added later.

This rare problem could be reproduced by creating a product
in a module, then referencing it in e.g. a sales order,
then updating the module after changing the product
record to be in a `noupdate` block.
At the end of the update the implicit product.template
record would be garbage collected, and trigger a cascade
deletion of its children - blocked by the SO reference
to the product.
2015-03-18 14:10:18 +01:00
Olivier Dony d8c4e4fa76 [FIX] product: unused import as of 489a96c257 2015-03-18 14:10:18 +01:00
Olivier Dony 694fe1fb3f [FIX] web: remove deprecated hack for future_display_name
This temporary patch was used to simulate the presence of a
`display_name` field in all models. It is not needed anymore
as of version 8.0, which comes with the actual magic to make
`display_name` work everywhere.
2015-03-18 14:10:18 +01:00
Christophe Simonis e27744df0c [MERGE] forward port of branch saas-3 up to b79f64f 2015-03-18 13:16:23 +01:00
Antony Lesuisse 7dbd495985 [IMP] website: server actions allow trailing paths 2015-03-18 13:10:58 +01:00
Christophe Simonis b79f64f1f8 [MERGE] forward port of branch 7.0 up to e1daaff 2015-03-18 12:52:33 +01:00
Nicolas Lempereur e1daaff8e0 [FIX] kanban: propagate context of many2many field
Propagate the context in kanban view when displaying a many2many field.

fixes #5623, closes #5681

opw-629698
2015-03-18 12:32:24 +01:00
Olivier Dony 489a96c257 [FIX] product.template: name_search order + mismatch on IDs
Improve commit bf31ab6718a8b9c8afdd29120e5056533b0a2ade:
 - do not use the product.product name_search() when there is no
   search term (it's only useful with a search term
 - do not use the product.product name_search() when the extra
   domain (args) has a criterion on IDs - these will be *template*
   ids, not *variant* ids, so the results would be wrong
 - Since templates and variants use a different natural `_order`,
   perform an extra name_search() on templates after gathering the
   ids to return, to apply the proper sort ordering. Increases the
   penalty by doing 2 name_search() calls.

This issue could be seen e.g. in the breadcrumbs where the
display_name variable is displayed for templates, and indirectly
relies on name_search() due to an old hack in call_kw in order to
implement the "future_display_name".
2015-03-18 11:40:51 +01:00
Raphael Collet 6aa28a89bb [FIX] models: compute many2many field on existing records when field is introduced by an update 2015-03-18 09:43:45 +01:00
Christophe Simonis 98c1a82e68 [FIX] mail, share: correct module update.
a6eac0f08e introduced a new `res.groups`
belonging to the "Sharing" category.
As this group has the flag `shared`, it is ignore when generating the
group's user view (and its virtual fields).

When updating `mail` module, the `share` module (which depend on mail)
is not loaded yet. This mean this new group is taken into account when
getting the `res.users` virtual fields.
As this group belong to the same category as the `share.group_share_user`
group but dont have an inheritance link between them (`implied_ids`),
they are generated as `boolean` instead of a single entry `selection`
field. This create a missmatch between the fields and the previously
generated view, which forbid inheritance application.

Force view regeneration, to avoid it.

Also change the group's category as this group is purely technical and
must be hidden anyway.
2015-03-17 19:29:54 +01:00
Jeremy Kersten 082a6ce0ab [FIX] point_of_sale: don't overwritte title from pos template 2015-03-17 18:53:26 +01:00
Josse Colpaert fffd52a16b [FIX] stock: Inventory theoretical qty should only consider the location itself, not its children. Same for reservations.
When the theoretical_qty of the stock is calculated, we should only consider the location itself, not its children.
That way you can have correct inventory for e.g. iPads that are both in Stock and Stock/Shelf 1
2015-03-17 17:17:44 +01:00
Josse Colpaert 50cdacba90 [FIX] stock: search qty available correction when searching zero quantities
When =, >=, <= 0 it cannot use the read_group of quants because the results will not be in the read_group Fixes #5701
2015-03-17 16:50:50 +01:00
Nicolas Martinelli 3d05ddab50 [FIX] sale_stock: Cancel all procurements linked to a sale order
During the creation of a Sale Order containing a product for which 'Make To Order' is activated
in the Procurements, two procurements are created:
- one for 'Partner Locations/Customers' location
- one for 'WH/Stock' location

If the Sale Order if cancelled, the user must first cancel the picking (delivery order).
This will trigger the cancellation of the procurement with the 'Partner Locations/Customers'
location.

The new behavior is to cancel the procurements linked to the Sale Order, which will trigger
the cancellation of the picking.

opw: 630170
issue: https://github.com/odoo/odoo/issues/3805
2015-03-17 16:37:24 +01:00
Olivier Dony 3239d5fb74 [FIX] account_payment: typo in 9562bf8398 2015-03-17 15:50:11 +01:00
Olivier Dony 6411619811 [FIX] account_payment: typo in 9562bf8398 2015-03-17 15:45:00 +01:00
Raphael Collet e182da22f4 [FIX] base/ir_model: upon custom field creation, always clear manual fields in registry
The invalidation in registry was done only if the field's model was already in
registry.  This situation is not the case when you create a custom model with a
custom field.
2015-03-17 11:51:22 +01:00