Commit Graph
207 Commits
Author SHA1 Message Date
Christophe Simonis e37ba61832 [MERGE] forward port of branch saas-6 up to b87a93a 2016-06-20 14:20:03 +02:00
Christophe Simonis b87a93a091 [MERGE] forward port of branch 8.0 up to 5b1beec 2016-06-20 13:34:46 +02:00
Xavier ALT f02b23006b [FIX] fields: during an onchange(), do not invalidate *2many fields because of their domain
Our usage of domain on fields One2many seems to trigger an obscure behaviour on
onchange.

With the following (simplified) config:

    Message(models.Model):
        _name = 'test_new_api.message'
        important = fields.Boolean('Important')

    Discussion(models.Model):
        _name = 'test_new_api.discussion'
        name = fields.Char('Name')
        important_emails = fields.One2Many('test_new_api.emailmessage', 'discussion',
                                           domain=[('important', '=', True)])

    Email(models.Model):
        _name = 'test_new_api.emailmessage'
        _inherits = {'test_new_api.message': 'message'}

        discussion = fields.Many2one('test_new_api.discussion', 'Discussion')
        message = fields.Many2one('test_new_api.message', 'Message')

Steps:
- We change 'name' on discussion, triggers an `onchange()` call
- we ends up filling cache on virtual record (on secondary fields, we calling
  record.mapped('important_emails.important'))
- we get a cache miss ('important' field not provided, only 'important_emails' ids,
  i.e with no change on existing records)
- we fill the cache, this mark 'important' field as modified
- because of commit 5676d81 and because 'important' is that case is a related (i.e
  computed) field we triggers cache recomputation
- as there is no way to recompute 'important_emails' for virtual record (no real
  ID) we ends up with empty 'important_emails' generating removal of existing records.

=> Finally changing any value for 'test_new_api.discussion' that trigger an onchange
will always reset 'important_emails' to empty

Fixed by Raphael Collet <rco@odoo.com>, and test by Xavier Alt <xal@odoo.com>.
2016-06-17 17:50:25 +02:00
Christophe Simonis ca2dad4c44 [MERGE] forward port of branch 8.0 up to b9a006c 2016-06-06 15:41:50 +02:00
Denis Ledoux 950fd97d06 [FIX] fields: translations of the help of inherited fields
This is similar to revision 54140331f3

opw-673716
2016-06-06 11:44:34 +02:00
Christophe Simonis 820f7e11c1 [FIX] core: correct fields.modified_draft for triggers on other models 2016-05-13 17:32:00 +02:00
Christophe Simonis 7e999ece01 [MERGE] forward port of branch saas-6 up to 19a77d9 2016-05-12 18:20:08 +02:00
Christophe Simonis 2f374c4cba [MERGE] forward port of branch 8.0 up to 3a32021 2016-05-12 12:38:02 +02:00
Raphael Collet 5676d8121d [FIX] fields: invalidate x2many fields with a domain
Invalidate the cache of a x2many field when any of the fields appearing in its
domain is modified.  Use the invalidation triggers mechanism for that purpose.
2016-05-09 12:10:23 +02:00
Christophe Simonis db935df398 [MERGE] forward port of branch saas-6 up to e2faeab 2016-05-02 14:11:40 +02:00
Christophe Simonis 396facfaf0 [MERGE] forward port of branch 8.0 up to 8651d08 2016-05-02 11:04:21 +02:00
Raphael Collet 233c7780e6 [FIX] fields: filter result of 2many related fields with related_sudo
When traversing relational fields as superuser, you end up with a recordset for
which only a subset is accessible to the current user.  An earlier fix to this
issue completely dropped the `related_sudo` feature; change its implementation
to keep the feature.
2016-04-28 11:46:44 +02:00
Raphael Collet ce217acf18 [FIX] fields: *2many convert_to_cache for new records
When interpreting commands, the initial value for new records is an empty list.
This regression was introduced by 0939738479.

Fixes #11239.
2016-03-15 10:40:38 +01:00
Raphael Collet a4ea258176 [FIX] fields: company-dependent (property) fields should not be stored or copied 2016-03-03 16:47:05 +01:00
Denis Ledoux 04b2d910ac [MERGE] forward port of branch saas-6 up to fead627 2016-02-08 13:39:28 +01:00
Denis Ledoux fead627dd5 [MERGE] forward port of branch 8.0 up to 3ff4dae 2016-02-08 13:31:27 +01:00
Raphael Collet a3ec5a35a5 [FIX] fields: in copy_cache, add single records to set todo 2016-02-04 14:33:53 +01:00
Raphael Collet 0f2e7d783e [FIX] fields: make copy_cache use a todo list instead of recursion
The recursion was based on an incorrect assumption: the cache of the target
environment is initially empty.  If another computation left some value there,
the copying is incomplete, and that causes bugs in onchanges.
2016-02-04 13:48:28 +01:00
Christophe Simonis 9ca7ad87b2 [MERGE] forward port of branch 8.0 up to 3ac46ee 2016-02-02 12:25:06 +01:00
Raphael Collet a688bcdbbd [FIX] fields: make copy_cache not invalidate the cache! 2016-02-01 18:01:02 +01:00
Raphael Collet bac6889c53 [FIX] fields: make related_sudo work for draft records (used by onchange)
Accessing a related field with `related_sudo=True` on a draft record should
effectively traverse the fields as the admin user.  Traversing new records in a
different cache requires that all new records on the path are copied across
caches.  Make the copy across caches recursive when the first record on the
path is a new record.
2016-02-01 17:59:31 +01:00
Denis Ledoux 6c8bbc3d46 Revert "[FIX] fields: make related_sudo work for draft records (used by onchange)"
This reverts commits
 - 995b257a6c
 - 2ebdb5f36e
 - 748a719fd9.

The commit 748a719fd9 leads to an issue
bigger than what it aims to solve:
 - as demo user
 - create a new invoice
 - add a new line
 - select a product
-> traceback

opw-668141
2016-01-29 16:55:23 +01:00
Denis Ledoux a842199687 [MERGE] forward port of branch saas-6 up to 2616def 2016-01-29 12:29:17 +01:00
Denis Ledoux 2616defe35 [MERGE] forward port of branch 8.0 up to edeb5a8 2016-01-29 11:41:24 +01:00
Raphael Collet 812332855a [IMP] fields: speedup Float.convert_to_cache by not rounding the value 2016-01-29 09:37:27 +01:00
Raphael Collet f0646cb51b [IMP] fields: use a "lazy" cursor to compute attribute digits
Borrowing a cursor each time you access `field.digits` may be costly, because
of the connection reset.  Moreover, in most cases, the cursor is not used at
all, since the decimal precision are kept in cache.

For the installation of module `product` with its demo data, the number of
cursor allocations was reduced from ~1500 to about 50!
2016-01-29 09:37:27 +01:00
Raphael Collet 995b257a6c [FIX] fields: make related_sudo work for draft records (2)
Traversing new records in a different cache requires that all new records on
the path are copied across caches.  Make the copy across caches recursive when
the first record on the path is a new record.
2016-01-28 16:33:09 +01:00
Christophe Simonis 2ebdb5f36e [FIX] fields: correct related_sudo computation.
Correctly merge commit 748a719fd9 in 9.0
2016-01-26 19:46:55 +01:00
Christophe Simonis 2ce9311cfe [MERGE] forward port of branch saas-6 up to a576f2b 2016-01-26 19:13:41 +01:00
Christophe Simonis 50b0b075a9 [MERGE] forward port of branch 8.0 up to ab245fc 2016-01-26 14:04:55 +01:00
Raphael Collet 748a719fd9 [FIX] fields: make related_sudo work for draft records (used by onchange)
Accessing a related field with `related_sudo=True` on a draft record should
effectively traverse the fields as the admin user.

This fixes #5121, #7138.
2016-01-22 16:06:27 +01:00
Raphael Collet 1fb0136f5a [FIX] fields: in onchange, do not serialize the inverse field of a one2many 2015-12-16 15:39:15 +01:00
Denis Ledoux 56ef99d050 [MERGE] forward port of branch saas-6 up to 105b1c0014 2015-10-23 18:31:55 +02:00
Raphael Collet 6c8e53a087 [FIX] translate: separate html_translate from xml_translate, fix serialization
The serialization gives different results for some elements.  For instance, an
empty element `i` must be serialized as `<i/>` in XML and `<i></i>` in HTML.
It must be done like that, otherwise the world (of web browsers) would break.

Add a test case for `html_translate`.
2015-10-22 16:33:56 +02:00
Raphael Collet 061a1d7255 [IMP] fields: improve performance of method field.modified(records)
Reduce the number of calls to `search` by grouping fields by model and by path.
2015-10-09 15:22:10 +02:00
Denis Ledoux 105b1c0014 [MERGE] forward port of branch 8.0 up to 25634df 2015-10-05 16:20:13 +02:00
Raphael Collet a9c43bba82 [FIX] fields: fix assignment of related field on several records 2015-10-02 17:05:35 +02:00
Raphael Collet 20da3a3915 [IMP] fields: enable grouping of fields that are computed together
Do not convert the value of `field.compute`, as this conversion prevents the
grouping of fields that have the same `field.compute` otherwise.
2015-09-29 14:14:48 +02:00
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