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
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
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`.
* 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
- 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.
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.
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
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.
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.
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.
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
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
In `__getattr__`, remove the test on accessing `_attrs`. This situation should
never happen, since the attribute `_attrs` is set in method `__init__()`.
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.
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.
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.
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.
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.