Commit Graph
720 Commits
Author SHA1 Message Date
Cédric Krier 0d50aa9c05 Filter extra pattern in get_multivalue and set_multivalue
The pattern can be passed from one field to another and so it may contains
extra keys that does not exist in the Value model as field.

issue6672
review47291003
2018-04-09 10:50:19 +02:00
Cédric Krier 60f167bcfe Add index method to order field set calls
issue7090
review46301002
2018-04-05 19:18:52 +02:00
Cédric Krier 710c0ab2e9 Rename with_inactive_records decorator
issue7026
2018-04-03 14:55:01 +02:00
Cédric Krier 8c61a67c2b Remove active test in search_domain of Many2One and Reference
As the target is stored on the record, the target is always visible so
searching on it should not add active clause.

issue7026
review41231002
2018-04-03 13:20:37 +02:00
Sergi Almacellas Abellana bfb76a70ad Add deactivable mixin and ensure active field is present
issue4341
review38401002
2018-03-26 14:07:45 +02:00
Nicolas Évrard ff5b79819b Add support for search_* attributes on relational fields
issue6081
review25871002
2018-03-21 17:59:55 +01:00
Cédric Krier b15f3fb4c5 Do not append Exclude where clause if empty 2018-03-19 17:48:55 +01:00
Cédric Krier b3ca13748b Add Exclude constraint
issue1422
review44061002
2018-03-19 16:57:49 +01:00
Nicolas Évrard acdbe5a08f Allow to perform unaccented searches on Char fields
issue7115
review44611002
2018-03-16 18:17:53 +01:00
Cédric Krier 57248f9655 Clear cache for all records of ModelSingleton
As write and delete can be called with any ids for records and the super calls
are always on the real record, the cache is only cleared for the real record.
So ModelSingleton must ensure to clear the cache for any record ids.

issue7205
review44731002
2018-03-15 00:23:11 +01:00
Sergi Almacellas Abellana ff2bded417 Ensure that all buttons are registered in ir.model.button
issue6389
review36621002
2018-03-01 11:59:23 +01:00
Cédric Krier 62a90a603e Use unicode instead of str for DatabaseIntegrityError
The exception message could contain non-ASCII errors for which standard
__str__ may fail, but as the database should always be in UTF-8 we may except
that unicode will not fail.

issue6128
review43971002
2018-02-19 19:09:06 +01:00
Sergi Almacellas Abellana 54f70e2971 Add depends on Button
issue6919
review40811002
2018-02-19 11:35:37 +01:00
Cédric Krier b197b6b13d Add cache for check_xml_record
This allows fast return when the checked model has no record in ir.model.data
which is the most common case. This allow to prevent to search for non
existing records.

issue7119
review37991002
2018-02-14 19:35:57 +01:00
Cédric Krier f911f48ed4 Delete translations only when model has translatable field
The call to Translation.delete_ids has a cost as it does search queries. So it
is better to not call it if we already know that there is nothing to delete.

issue7118
review37981003
2018-02-11 14:59:58 +01:00
Sergi Almacellas Abellana b53fcf111a Do not strip trailing zeros on Decimal digits validation
In order to support the 0 digits case rstrip was introduced in changeset
d3fec5da0dbdbut it breaks the case where the number of digits is high
as python uses manting representation when converting the float value
to string. This causes the last trailing zero is also removed which
breaks the validation.

issue7091
review37981002
2018-02-07 12:26:59 +01:00
Cédric Krier 478c4e6928 Refactor fields tests
issue7085
review40051002
2018-02-02 00:04:19 +01:00
Cédric Krier b32d158d10 Remove MySQL backend
issue7017
review41771002
2018-01-24 20:12:42 +01:00
Cédric Krier d813ac2090 Add limit to SQL queries consumed with a single fetchone call
This remove some load on the database server.
This is only needed for queries that may have more than one rows.

issue7040
review43001003
2018-01-09 18:31:00 +01:00
Cédric Krier c63d0f8188 Use integer division
The count of grouped_slice must be an integer and not a float.
2017-12-26 17:56:35 +01:00
Cédric Krier 10042b9597 Improve validation of PYSON domain
Use a different strategy if we are close to one domain per record.
It will use combined multiple domain at once instead of doing one query for
almost each record validated.

issue6983
review39021002
2017-12-26 17:28:42 +01:00
Cédric Krier 2d2ec90141 Use field name to call searcher or domain of Function field
The name from the domain may be nested.

issue7015
review44511002
2017-12-26 17:26:00 +01:00
Cédric Krier 8cfd0eb692 Use JSON canonical form for Dict value
It allows to make equality comparison.

issue7013
review39041002
2017-12-20 19:26:44 +01:00
Cédric Krier af498348a7 Allow to search and order translated fields using the derivative translations
Since rev 049635454a98, translations are derivatives so the search and order
must be done using all the parent languages.

issue6934
review39971002
2017-12-18 17:45:37 +01:00
Cédric Krier 87dfddc17a Do not use defaultdict as changed value
xmlrpclib can not dump it and _changed_value is used by RPC on_change methods.

issue6943
review44431002
2017-11-18 11:12:45 +01:00
Cédric Krier 5b68d85117 Do not reset target link of one2many if it does not exist
The _save_values reset the target link of one2many because it will be set by
the setter. But when the one2many is a Function field, it may not have a
target.

issue6872
review42761002
2017-10-28 01:46:49 +02:00
Cédric Krier 87bbc9ee1a Apply filter when searching on xxx2many with one
The changeset b16a085824ce, which implements the filter, did not update the
search_domain of the fields to also apply the filter on the searched result.

issue6871
review36721003
2017-10-24 22:19:40 +02:00
Cédric Krier d3adf56163 Do not copy fields which are not ModelStorage or using table_query
It is not allowed to create/write/delete on such ModelSQL.

issue6819
review39751002
2017-10-13 23:31:33 +02:00
Cédric Krier 36c0ea7a1b Enforce required Reference field to have valid record
issue6749
review36661002
2017-10-11 22:41:05 +02:00
Cédric Krier a17386e970 Let default value of copy converted for the type of field
The default value of copy is expected to be the same format as for the default
methods. So the value for xxx2Many fields must be converted.

issue6818
review37751002
2017-10-06 11:00:41 +02:00
Albert Cervera i Areny 8f1242da3e Change rec_name label to "Record Name".
issue5643
review23211003
2017-10-02 20:19:10 +02:00
Cédric Krier 83656053c8 Order operation on relational field to avoid constraints
The order on which the operations are applied can trigger constraints.
So it is safer to first delete then write and finally create.

issue6790
review43511002
2017-09-28 23:44:48 +02:00
Cédric Krier 9eafd65d2e Add translated descriptor for Reference field
issue5667
review39671002
2017-09-26 01:25:26 +02:00
Cédric Krier 6d783acf42 Make save parameter of set_multivalue public
It can be useful for performance when setting values for MultiValue field on a
large set of records.

issue6625
review39491002
2017-07-27 00:05:04 +02:00
Cédric Krier 79fb0bcb7d Use next to get first record instead of index
This allows to use set with ModelStorage.save.

issue6633
review40521002
2017-07-19 19:57:30 +02:00
Cédric Krier fe674cef55 Enforce unique list of records on method calls
An option is added on RPC definition to enforce uniqueness of records
instantiated. The key methods ModeView.button and Workflow.transition have an
assert to detect error in development code.

issue6184
review36411002
2017-07-16 23:49:15 +02:00
Cédric Krier 4130a14d48 Use _changed_values for added record on One2Many
This allows to have the 'rec_name' set for xxx2One and Reference field but we
need to ensure that even the initial values are returned because the instance
does not come from the client.

issue6579
review40471002
2017-07-10 23:59:26 +02:00
Sergi Almacellas Abellana 1aae453480 Don't use an sql query to delete target models if not ModelSQL
issue6525
review35431002
2017-06-30 09:46:21 +02:00
Cédric Krier a53883484e Update MPTT before the validation of created records
This prevent to fill the cache of the instances created with wrong values for
left/right fields. And it ensure that the validation code has valid MPTT
values.

issue6591
review34211002
2017-06-29 23:08:36 +02:00
Nicolas Évrard ddf4e0fe3c Remove empty pages from notebook
issue3295
review40421002
2017-06-09 16:07:03 +02:00
Sergi Almacellas Abellana b637c503e7 Only convert dict fields when they are strings
issue6382
review28101002
2017-06-09 13:22:42 +02:00
Cédric Krier 4520afedd3 Convert into hash too long data name
Some back-ends have constraint on the length of data name, they usually
silently truncate them, but this can create collision. The solution is to hash
the name when it is too long.

issue4620
issue6494
review37381003
2017-05-12 12:00:44 +02:00
Sergi Almacellas Abellana 7ed3976d80 Use issubclass to test if foreign keys must be created
issue6491

review42321002
2017-05-08 12:00:37 +02:00
Cédric Krier 8479768619 Ensure Many2One target join is unique if Target has history
The joins added in tables must ensure to make a Cartesian product.
So when joining on a history table, the target id is not unique so the latest
must be used only for the join. Otherwise a search query may return multiple
times the same id.

issue6458
review37341002
2017-04-26 19:33:32 +02:00
Sergi Almacellas Abellana 7cc9585630 Ensure all _parent_ values are set on fields.depends
If the client does not sent all the values of the parent model fields, we must
ensure that the empty ones have None value

issue6450
review40271002
2017-04-26 13:56:30 +02:00
Cédric Krier f7c1de84c4 Support instantiate model with _parent_ of _parent_
This is a valid depends value for a field but the __init__ method lose the
second _parent_ once it has been instantiated a first time.
Setting _parent_ value must be done recursively.

issue6441
review40261002
2017-04-19 10:31:45 +02:00
Cédric Krier a178546d0d Use _field for sql_format of Function field
It is useful to allow to use sql_format on Function field when writing SQL
query that emulate the field.

issue6410
review34051002
2017-04-01 19:55:35 +02:00
Cédric Krier 826f30219d Re-use method as default parameter of TableHandler add_column
There is no guarantee that the method will not raise a database error on the
first registration because it can rely on other tables being registered.
So the method must be called only when needed. This is when the table already
exists and has records. In this case other tables also already exist.

issue6409
2017-04-01 16:14:36 +02:00
Cédric Krier a908e8cc74 Add MultiValueMixin and ValueMixin and remove Propery
issue2349
review23351002
2017-04-01 00:24:55 +02:00
Nicolas Évrard aa9c9cc9e7 Use sql type instead of field related argument in the column creation
issue6348
review26231002
2017-03-31 13:21:51 +02:00