Commit Graph
169 Commits
Author SHA1 Message Date
Raphael Collet 1bb61c970e [ADD] fields: add option to store binary fields into attachments
Such a field is declared as:

    image = fields.Binary("Image", attachment=True)

With this option, the value of a binary field F is stored in an attachment with
`res_field=F`.  When attachments are stored into the filestore, binary fields
are consequently stored in the filestore as well.  Note that the option does
not work on old-API function fields.

By default searching on `ir.attachment` filters out attachments for binary
fields: the condition `res_field=False` is added to the domain unless a
condition on field `id` or `res_field` is already present.  The client uses
`search_read` with a domain like `[('id', 'in', ids)]` for reading the data on
a form view.  In that case, we should not filter out attachments that store
binary fields.

Also, do not filter search results for the superuser.
2015-09-28 15:19:47 +02:00
qdp-odoo bacd60dc1d [FIX] orm, fields: read_group on monetary fields now correctly makes the sum instead of ignoring them 2015-09-24 10:33:34 +02:00
Christophe Simonis 57168a9e90 [MERGE] forward port of branch saas-6 up to a669433 2015-09-23 14:34:26 +02:00
Raphael Collet 3a1483635e [IMP] fields: avoid search when recomputing a field on the same records
This avoids a few dumb queries.
2015-09-18 18:12:23 +02:00
Xavier Morel 1e2e38b96a [FIX] translate docstrings
rst literals are double-quoted
2015-09-16 10:02:37 +02:00
Raphael Collet 7e9e747a0c [IMP] fields: optimize invalidation of fields in draft mode 2015-09-14 13:26:54 +02:00
Christophe Simonis fa5fe2e693 [MERGE] forward port of branch 8.0 up to c345d29 2015-09-07 11:24:14 +02:00
Raphael Collet 1c4c64fe01 [FIX] fields: add support for date/datetime null values in field methods 2015-09-07 10:27:34 +02:00
Raphael Collet dc798e317e [IMP] models: add a check on table and column names
In particular, this checks that table names are less than 64 bytes.
2015-08-31 11:06:48 +02:00
Raphael Collet ab19215261 [IMP] fields: translated html fields must use xml_translate or a callable 2015-08-25 12:01:37 +02:00
Raphael Collet a0fb9d83c7 Revert "[IMP] fields: translated html fields must use xml_translate or a callable"
This reverts commit 75140d7ea1.
2015-08-21 16:44:48 +02:00
Raphael Collet 75140d7ea1 [IMP] fields: translated html fields must use xml_translate or a callable 2015-08-21 15:39:53 +02:00
Raphael Collet 6627409268 [IMP] fields: in onchange on x2many field, never update the field id 2015-08-19 16:54:50 +02:00
Raphael Collet 1b8c2a2078 [IMP] fields, web: change output format of onchange for x2many fields
Those fields are serialized as lists of commands.
2015-08-19 16:10:43 +02:00
Raphael Collet 9f81c6d651 [IMP] models, fields: change output format of method onchange for x2many fields
Use `field.convert_to_onchange` to format the output of method `onchange`.  By
default it behaves like `convert_to_read`.  This is useful for the many2one
case, as the client automatically receives the display name of the record.

For the *2many case, we return a list of dicts values, in recordset order, with
all the known fields in the view:

    [{id: 42, name: "Existing record"}, {name: "New record"}, ...]

Each dictionary contains the values of all known fields in the view.  The
client is responsible of determining which fields are dirty by computing the
difference with former values.

Since the method `onchange` now uses `field.convert_to_onchange`, the method
`field.convert_to_write` has been simplified, as it no longer needs its extra
parameters `target` and `fnames`.
2015-08-14 15:09:04 +02:00
Raphael Collet 44383c5502 [IMP] fields: improve API and implementation of resolve_all_mro
Make the function traverse the class hierarchy upwards, retrieve the value of
the attribute, and stop when the value does not satisfy the given condition.
2015-08-14 08:56:24 +02:00
Raphael Collet 7d6abb6f31 [IMP] fields: simplify implementation of method setup_triggers 2015-08-13 10:45:00 +02:00
Raphael Collet de363ce909 [IMP] fields: move computed_fields, inverse_fields and _triggers to models
This removes an obstacle for sharing fields across registries: regular fields
no longer contain metadata referring to other models/fields.
2015-08-13 10:45:00 +02:00
Raphael Collet ec0636a289 [IMP] fields: do not use methods bound to model classes
Avoid this reference from a field to a model class; this will allow the sharing
of fields across model classes.  Use `getattr` on class instances instead.
2015-08-13 10:45:00 +02:00
Raphael Collet 6161c85d55 [IMP] fields: optimize setup_base() for regular (non-related) fields
Split the methods `_setup_regular` and `_setup_related` in `base` and `full`
parts, such that the `base` part is done in `setup_base()`, and the `full` part
is done in `setup_full()`.

This optimizes the setup of models during the installation of modules: regular
fields are not set up again from scratch.  Only related fields (which are less
common) are always set up from scratch.
2015-08-13 10:45:00 +02:00
Raphael Collet c6c1824b7a [IMP] fields: rename methods set_class_name and setup, and change their API
The API of those method has been modified to take a recordset instead of a class
as parameter:

    field.set_class_name(cls, name)   ->   field.setup_base(model, name)
    field.setup(env)                  ->   field.setup_full(model)

The recordset gives access to an environment, and will ease code reorganization
in the field's setup methods.
2015-08-13 10:44:59 +02:00
Raphael Collet a4eaa86e44 [IMP] fields: split attribute _attrs into args and _attrs
Make an explicit distinction between both semantics of `_attrs`:
 - the parameters given to `__init__` in `args`
 - the non-slot attributes (memory optimization) in `_attrs`
2015-08-13 10:44:59 +02:00
Raphael Collet e6d4a63561 [IMP] fields: add attribute origin to avoid confusion with column
Making a distinction between the column from which the field was created, and
the one created from the field, allows to keep the second one from a registry
setup to the next one.  This opens a door for optimizations: the column may not
need to be recomputed.
2015-08-13 10:44:59 +02:00
Christophe Simonis 95ac2cfd10 [MERGE] forward port of branch saas-6 up to be58335 2015-08-06 16:09:19 +02:00
Christophe Simonis 3d26eb02ab [MERGE] forward port of branch 8.0 up to d3e9bde 2015-08-06 11:54:32 +02:00
Nicolas Martinelli 282fc4a850 [FIX] openerp: export empty string instead of None
xmlrpc 1.0 does not support None/null, so commit f3e4d0a will break xmlrpc api.
Therefore, we export an empty string if the field is empty, instead of False or
None. For integers and floats, zero is exported.

opw-643966
2015-08-03 08:16:23 +02:00
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