Commit Graph
143 Commits
Author SHA1 Message Date
Christophe Simonis 2cf91d16a5 [MERGE] forward port of branch saas-6 up to 63e92cb 2015-07-22 16:17:54 +02:00
Christophe Simonis 4a2aee45be [MERGE] forward port of branch 8.0 up to 9654b54 2015-07-10 17:12:57 +02:00
Nicolas Martinelli f3e4d0a2e8 [FIX] openerp: export None instead of False in raw_data mode
If we export False or an empty string, the Excel export will consider the field
similarly to a boolean, and en empty value will be converted into "=False()" in
Excel. To prevent this, we return "None" in the following cases:

- String
- Date
- Datetime
- Selection
- Reference
- Many2one
- RelationalMulti

Introduced by 6243d18

opw-643966
2015-07-09 11:49:04 +02:00
Christophe Simonis fe92deaa1d [MERGE] forward port of branch 8.0 up to 2de301d 2015-07-07 18:13:57 +02:00
Xavier Morel 95e56a109d [ADD] doc: new theme
Pretty much completely rewritten theme with custom HTML translator and a
few parts of the old theme extracted to their own extensions.

Banner images thought not to be that huge after all, and not worth the
hassle of them living in a different repository.

co-authored with @stefanorigano
2015-07-07 11:22:50 +02:00
Raphael Collet ad659c39b0 [IMP] ir_translation: sanitize the values of translated fields 2015-07-06 16:58:04 +02:00
Raphael Collet 8ddfb1888b [IMP] models, fields: handle the case where field.translate is a callable
Using `field.translate(callback, value)` returns the translation of the given
field value by using the function `callback` to translate simple terms in
`value`.  In practice, the function `callback` uses a translation mapping
retrieved from `ir.translation`.
2015-07-06 16:58:03 +02:00
Raphael Collet 848c220180 [IMP] ir_model: use ir.model.fields to store translations of fields string and help
* add the necessary fields in `ir.model.fields`
* when loading translations, convert types 'field', 'help' into 'model'
* add specific methods to retrieve translations of field string and help
2015-07-06 16:58:03 +02:00
Raphael Collet 1fc4a3424f [IMP] fields: add method traverse_related to ease the handling of related fields 2015-07-06 16:58:03 +02:00
Raphael Collet 5ebc100253 [FIX] fields: handle the case of fields declared with store=False
Those fields should be considered as "dummy" fields": they are typically useful
for hackish onchange methods that need to store something into a form.
2015-07-06 11:02:39 +02:00
Raphael Collet 64b7875fd5 Revert "[FIX] fields: support fields with store=False"
The commit is causing unexpected failures when creating views.

This reverts commit 72399a195a.
2015-07-02 17:47:30 +02:00
Raphael Collet 72399a195a [FIX] fields: support fields with store=False
Fix method `to_column` to not create columns for non-stored fields.
2015-07-02 16:56:04 +02:00
Christophe Simonis 4c2a1de75a [MERGE] forward port of branch 8.0 up to 22bd3bd 2015-07-01 18:11:32 +02:00
Raphael Collet 0939738479 [IMP] fields: speedup of convert_to_cache for x2many fields
The algorithm's complexity changed from O(n²) to O(n).
2015-07-01 13:49:14 +02:00
Raphael Collet 125ec28e71 [FIX] fields: change exception type (bug found because of missing import) 2015-06-29 12:23:16 +02:00
Christophe Simonis a304194936 [MERGE] forward port of branch saas-6 up to 81b5c60 2015-06-25 00:26:31 +02:00
Christophe Simonis 13468c271f [MERGE] forward port of branch 8.0 up to ed3065e 2015-06-18 19:41:31 +02:00
Martin Trigaux 6bb3be5ba3 [FIX] doc: api.multi/one confusion
As the methods are using @api.multi, it should be accessed with rec, not self
2015-06-17 09:41:09 +02:00
Olivier Dony 0bd4545348 [LEGAL] Use global LICENSE/COPYRIGHT files, remove boilerplate text
- Preserved explicit 3rd-party copyright notices
- Explicit boilerplate should not be necessary - copyright law applies
  automatically in all countries thanks to Berne Convention + WTO rules,
  and a reference to the applicable license is clear enough.
2015-06-02 03:16:04 +02:00
Christophe Simonis fe2b5f35a4 [MERGE] forward port of branch saas-6 up to bf1e999 2015-05-28 14:27:38 +02:00
Christophe Simonis 14a7d52307 [MERGE] forward port of branch 8.0 up to 327e471 2015-05-21 14:50:39 +02:00
Christophe Simonis 1cf5723835 Revert "Revert "[FIX] fields: digits() computation""
Thamks to parent commit, `request.env` doesn't raise `AttributeError`
anymore for requests without session bound to a database.

This exception was bubbling up to `digits` property (and `__getattr__`)

This reverts commit 49cb46fb78.
This reinstate commit eeedd2d9f5.
2015-05-21 13:13:23 +02:00
Denis Ledoux 49cb46fb78 Revert "[FIX] fields: digits() computation"
This reverts commit eeedd2d9f5.

This revision introduces an issue more serious than the ones
it fixes. This is no longer possible to receive an email
aimed a sale.order thread with catchall.

To reproduce the issue:
 - Create a new sale order
 - Send a message in the thread to the customer
 - Reply to the mail received in the customer mailbox
 - Traceback, AttributeError: digits

 opw-640370
2015-05-20 19:13:04 +02:00
Christophe Simonis eeedd2d9f5 [FIX] fields: digits() computation
Ensure we always have an valid cursor when determining `digits()`.

fixes #6605, fixes #6650
2015-05-19 19:59:10 +02:00
Raphael Collet 49c614e9e1 [FIX] fields: an inherited required field is expected to be required 2015-05-19 13:40:30 +02:00
Christophe Simonis 0da722aa6a [MERGE] forward port of branch 8.0 up to bff6dff 2015-05-11 15:12:24 +02:00
Raphael Collet 5efac22043 [FIX] fields: when determining digits(), make sure to use a valid cursor 2015-05-07 16:56:26 +02:00
Raphael Collet 926aa5bcf9 [IMP] fields: when computing a field, do not recompute other stored computed fields
In the process of determining a stored computed field's value, the field could
not be read from the database if the environment was in "draft" mode.  The idea
behind this condition was that during an onchange, no computed field should be
read from the database.  We fix the condition by checking whether we are in
"onchange" mode instead of "draft" mode.

The change may be critical for performance: one of the purposes of storing a
computed field is to avoid recomputing it when not necessary.  Now a computed
field can read the value of a stored computed field from the database.

This issue was spotted by Cédric Snauwaert (csn), who came with a concrete
example were a stored computed field was recomputed without apparent reason.
2015-05-07 11:29:20 +02:00
Christophe Simonis 2260496879 [MERGE] forward port of branch 8.0 up to a939a27 2015-05-05 18:48:34 +02:00
Raphael Collet 071152216f [FIX] fields: when computing digits, use an existing cursor instead of a new one
The computation of property `digits` was creating a new cursor to call the
function that determines digits.  This technique is fragile because the current
cursor may have pending updates that the new cursor will not see.

The issue was discovered by Cécile Tonglet (cto).  She observed an infinite
loop during a database migration, and a traceback inside the loop showed the
presence of the `digits` property.  This change fixes the infinite loop issue.
2015-05-05 17:33:16 +02:00
qdp-odoo c04065abd8 [IMP] accounting v9. Yeeeeaah 2015-05-05 17:28:04 +02:00
Raphael Collet 0280a5f390 [FIX] fields: do not infer a related field to be required
Forcing a related field to be required causes some issues.  Having such a field
in a one2many relation may block the creation of records in the field, as the
main record does not exist yet, and the field has no value.

It may also cause trouble if the field is stored: being required constrains the
corresponding column to be NOT NULL.  Inserting a row will fail, because
related fields are currently determined *after* the row insertion.
2015-04-28 11:49:47 +02:00
Christophe Simonis 9750c1eae3 [MERGE] forward port of branch 8.0 up to 44059bc 2015-04-20 12:33:31 +02:00
Ravi Gohil 3557fe124a [FIX] fields: timezone aware context_timezone
context_timestamp should always return a timezone aware timestamp, even when
no timezone is set on the user.
7f88681 fixed the bug in old api fields (openerp/osv/fields.py) but it was not
applied to new api fields (openerp/fields.py). opw 616612
2015-04-17 17:59:47 +02:00
Cedric Snauwaert 9d87d15db6 [ADD] new fields.Monetary + updated widgets
Enhance current widget="monetary" client-side feature and
convert it to a first-class type of field, allowing proper
server-side behavior.

- fields: add field.Monetary, similar to fields.Float but
  supporting a `currency_field` attribute instead of the
  decimal_precision attribute.
  `currency_field` indicates the field holding the
  related currency on the same record.
  The symbol of that currency is used when displaying
  the field, and the rounding of the currency is applied
  instead of the usual decimal precision.
- avoids application of a second decimal precision rounding,
  as was the case when the model field was a `fields.float`.
- removes the need for adding explicit boilerplate to each
  view containing a monetary field, i.e.:
    widget="monetary" options="{'currency_field': 'currency_id'}"
- res.currency: add new field decimal_places needed to round
  value at the correct decimal places
- web: cache all currencies, rounding and symbols at
  webclient startup to speedup monetary fields
- new widget monetary for list view + adapt widget monetary
  on form view

Limitations:
- if the currency_field is a related field, the server-side
  application of currency rounding will only work when the
  record already exists, not during creation (to be fixed)
- this field is only supported in the new API
2015-04-09 19:05:44 +02:00
Christophe Simonis fb8b970567 [MERGE] forward port of branch 8.0 up to 0ed63d7 2015-03-23 16:35:03 +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 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 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
Christophe Simonis a329aa1949 [MERGE] forward port of branch 8.0 up to e27744d 2015-03-18 14:05:02 +01:00
Raphael Collet 7ac4639a24 [FIX] fields: fix determination of field.selection for custom fields
In the case of custom fields, `field.selection` is set directly instead of
being set in overridden fields.
2015-03-16 15:34:16 +01:00
Christophe Simonis 0894bdafe2 [MERGE] forward port of branch 8.0 up to 5e3e41b 2015-03-09 16:06:29 +01:00
Olivier Dony 13476c844d [FIX] fields.html, forum: opt-in stripping of @style attrs
For public-facing HTML content provided by the user,
`<style>` tags and `style` attributes should be stripped
automatically, as they can easily be abused to deface
pages for abusive users and spammers.
<style> tags were already stripped, the optional `strip_style`
for fields.html enables the automatic stripping of style
attributes.

This is opt-in because custom style attributes are still
desirable in trusted HTML fields.
2015-03-09 14:41:14 +01:00
Christophe Simonis bc2fd0515b [MERGE] forward port of branch 8.0 up to 017f346 2015-03-04 15:16:10 +01:00
Raphael Collet 983dcf193c [FIX] fields: make base_field recursive in case a field is inherits'ed across several models 2015-03-03 13:18:04 +01:00