Merge lp://qastaging/~openerp-dev/openobject-server/trunk-apiculture-rco into lp://qastaging/openobject-server

Proposed by Raphael Collet (OpenERP)
Status: Work in progress
Proposed branch: lp://qastaging/~openerp-dev/openobject-server/trunk-apiculture-rco
Merge into: lp://qastaging/openobject-server
Diff against target: 11970 lines (+6435/-2392)
92 files modified
doc/03_module_dev_02.rst (+1/-0)
doc/03_module_dev_03.rst (+13/-4)
doc/api_models.rst (+16/-2)
doc/index.rst (+4/-3)
doc/new_api.rst (+138/-0)
openerp/__init__.py (+15/-0)
openerp/addons/base/__openerp__.py (+1/-2)
openerp/addons/base/base.sql (+1/-36)
openerp/addons/base/base_menu.xml (+4/-0)
openerp/addons/base/ir/ir_actions.py (+6/-6)
openerp/addons/base/ir/ir_attachment.py (+2/-2)
openerp/addons/base/ir/ir_cron.py (+5/-4)
openerp/addons/base/ir/ir_mail_server.py (+3/-6)
openerp/addons/base/ir/ir_model.py (+38/-42)
openerp/addons/base/ir/ir_rule.py (+2/-2)
openerp/addons/base/ir/ir_sequence.py (+4/-3)
openerp/addons/base/ir/ir_translation.py (+3/-3)
openerp/addons/base/ir/ir_ui_menu.py (+18/-16)
openerp/addons/base/ir/ir_ui_view.py (+14/-8)
openerp/addons/base/ir/ir_values.py (+26/-1)
openerp/addons/base/module/module.py (+66/-45)
openerp/addons/base/res/ir_property.py (+3/-4)
openerp/addons/base/res/res_company.py (+2/-1)
openerp/addons/base/res/res_config.py (+2/-2)
openerp/addons/base/res/res_currency.py (+11/-18)
openerp/addons/base/res/res_partner.py (+147/-143)
openerp/addons/base/res/res_users.py (+13/-13)
openerp/addons/base/security/base_security.xml (+0/-5)
openerp/addons/base/test/base_test.yml (+1/-1)
openerp/addons/base/test/test_ir_rule.yml (+1/-1)
openerp/addons/base/test/test_osv_expression.yml (+2/-2)
openerp/cli/server.py (+1/-0)
openerp/exceptions.py (+15/-1)
openerp/modules/loading.py (+2/-0)
openerp/modules/module.py (+18/-16)
openerp/modules/registry.py (+34/-14)
openerp/netsvc.py (+2/-6)
openerp/osv/__init__.py (+3/-2)
openerp/osv/api.py (+760/-0)
openerp/osv/expression.py (+125/-105)
openerp/osv/fields.py (+138/-110)
openerp/osv/fields2.py (+995/-0)
openerp/osv/orm.py (+1679/-1348)
openerp/osv/scope.py (+380/-0)
openerp/report/custom.py (+5/-6)
openerp/report/print_xml.py (+12/-30)
openerp/report/report_sxw.py (+18/-87)
openerp/service/model.py (+1/-1)
openerp/service/security.py (+1/-1)
openerp/tests/__init__.py (+3/-3)
openerp/tests/addons/test_impex/models.py (+55/-39)
openerp/tests/addons/test_impex/tests/test_export.py (+8/-11)
openerp/tests/addons/test_impex/tests/test_import.py (+5/-5)
openerp/tests/addons/test_impex/tests/test_load.py (+6/-6)
openerp/tests/addons/test_inherit/__init__.py (+3/-0)
openerp/tests/addons/test_inherit/__openerp__.py (+15/-0)
openerp/tests/addons/test_inherit/ir.model.access.csv (+1/-0)
openerp/tests/addons/test_inherit/models.py (+29/-0)
openerp/tests/addons/test_inherit/tests/__init__.py (+12/-0)
openerp/tests/addons/test_inherit/tests/test_inherit.py (+17/-0)
openerp/tests/addons/test_new_api/__init__.py (+2/-0)
openerp/tests/addons/test_new_api/__openerp__.py (+15/-0)
openerp/tests/addons/test_new_api/demo_data.xml (+14/-0)
openerp/tests/addons/test_new_api/models.py (+196/-0)
openerp/tests/addons/test_new_api/tests/__init__.py (+18/-0)
openerp/tests/addons/test_new_api/tests/test_attributes.py (+25/-0)
openerp/tests/addons/test_new_api/tests/test_field_conversions.py (+11/-0)
openerp/tests/addons/test_new_api/tests/test_new_fields.py (+397/-0)
openerp/tests/addons/test_new_api/tests/test_onchange.py (+46/-0)
openerp/tests/addons/test_new_api/tests/test_related.py (+3/-58)
openerp/tests/addons/test_new_api_extend/__init__.py (+3/-0)
openerp/tests/addons/test_new_api_extend/__openerp__.py (+14/-0)
openerp/tests/addons/test_new_api_extend/models.py (+12/-0)
openerp/tests/addons/test_new_api_extend/tests/__init__.py (+8/-0)
openerp/tests/addons/test_new_api_extend/tests/extend_class.py (+26/-0)
openerp/tests/addons/test_workflow/models.py (+8/-7)
openerp/tests/addons/test_workflow/tests/test_workflow.py (+1/-1)
openerp/tests/common.py (+7/-2)
openerp/tests/test_acl.py (+34/-20)
openerp/tests/test_api.py (+462/-0)
openerp/tests/test_orm.py (+14/-0)
openerp/tools/__init__.py (+1/-1)
openerp/tools/cache.py (+86/-86)
openerp/tools/convert.py (+3/-1)
openerp/tools/func.py (+29/-1)
openerp/tools/misc.py (+7/-0)
openerp/tools/test_reports.py (+1/-1)
openerp/tools/translate.py (+46/-41)
openerp/tools/yaml_import.py (+3/-1)
openerp/workflow/workitem.py (+3/-4)
openerpcommand/read.py (+1/-1)
setup.py (+34/-1)
To merge this branch: bzr merge lp://qastaging/~openerp-dev/openobject-server/trunk-apiculture-rco
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+157040@code.qastaging.launchpad.net

Description of the change

Task: RD Framework / new api: ORM
 - encapsulate session data (cr, uid, context) into a separate object, called a "scope"
 - scopes are nestable, and introduced with the statement "with" => scope is global and implicit
 - introduce "record", "recordset" and "null" as instances of BaseModel => methods available on all instances
 - removed former classes browse_record, browse_record_list and browse_null
 - attach record cache to scopes => automatic cache sharing
 - add cache invalidation => cache consistency
 - introduce method decorators to define record, recordset or model methods => real object style method API
 - in model class, use docstring as default _description, and class name as default _name

To post a comment you must log in.
4892. By Raphael Collet (OpenERP)

[IMP] orm: improve str representation of model instances

4893. By Raphael Collet (OpenERP)

[IMP] orm: support the creation of non-scoped records

* By default, method browse(ids) returns scoped records (backwards compatible
  behavior), while browse(ids, scoped=False) returns non-scoped records.
* The decorator @returns generates non-scoped records.

4894. By Raphael Collet (OpenERP)

[IMP] ir.model.access: automatically invalidate the record caches when access rights are modified

4895. By Raphael Collet (OpenERP)

[IMP] test_api: improve tests on scopes

4896. By Raphael Collet (OpenERP)

[IMP] orm: better error handling in new code

4897. By Raphael Collet (OpenERP)

[IMP] orm: when converting exception, attach existing traceback

4898. By Raphael Collet (OpenERP)

[IMP] api: new record-map convention: map results into a list instead of a dict

4899. By Raphael Collet (OpenERP)

[FIX] test_impex: change calls to name_get() to follow new record-map convention

4900. By Raphael Collet (OpenERP)

[FIX] workflow: when evaluating a trigger expression, handle the case of a single output

4901. By Raphael Collet (OpenERP)

[MERGE] from trunk

4902. By Raphael Collet (OpenERP)

[IMP] orm tests: move test on related fields in openerp/tests/addons/test_fields

4903. By Raphael Collet (OpenERP)

[IMP] openerp.osv.fields2: new module with new-style fields

4904. By Raphael Collet (OpenERP)

[IMP] new fields: record.X and record['X'] are now equivalent

4905. By Raphael Collet (OpenERP)

[IMP] orm: method read() now handles new-style fields
 - existing method read() has been renamed _read();
 - method _read() takes care of old-style fields only;
 - new higher-level read() handles both field styles.

4906. By Raphael Collet (OpenERP)

[IMP] orm: add automatic recomputation of new-style function fields

4907. By Raphael Collet (OpenERP)

[IMP] orm: improve methods invalidate_cache()

4908. By Raphael Collet (OpenERP)

[IMP] orm tests: improve test on new-style fields

4909. By Raphael Collet (OpenERP)

[IMP] new fields: improve field recomputation, and handle stored fields as well
 - redesign the recomputation algorithm such that it handles field dependencies
 - use it to compute fields for existing records when column is created in db

4910. By Raphael Collet (OpenERP)

[FIX] orm: invalidate the whole cache upon record delete, because of ondelete='cascade', etc.

4911. By Raphael Collet (OpenERP)

[IMP] orm: improve names of method that implement record.field, and check for deleted records

4912. By Raphael Collet (OpenERP)

[IMP] new fields: add test for a regular field (no compute method)

4913. By Raphael Collet (OpenERP)

[IMP] orm: internally recordsets use a tuple of ids instead of a list
 - this is only internal stuff, and does not break anything
 - this enforces the idea that a recordset is an immutable collection

4914. By Raphael Collet (OpenERP)

[IMP] new fields: small improvement when deriving string attribute

4915. By Raphael Collet (OpenERP)

[IMP] new fields: add test for compute method defined on recordset

4916. By Raphael Collet (OpenERP)

[MERGE] from trunk

4917. By Raphael Collet (OpenERP)

[FIX] new fields: in recompute_spec(), avoid returning useless specs (empty ids)

4918. By Raphael Collet (OpenERP)

[FIX] orm: rewrite method read() to always check access rights before doing anything else

4919. By Raphael Collet (OpenERP)

[IMP] orm: make method is_null() more robust

4920. By Raphael Collet (OpenERP)

[IMP] new fields: add method _set_field() in BaseModel

4921. By Raphael Collet (OpenERP)

[IMP] new fields: improve field copy, and fix check for non-attribute fields

4922. By Raphael Collet (OpenERP)

[IMP] new fields: add new-style fields to interface all columns

4923. By Raphael Collet (OpenERP)

[ADD] new fields: add boolean and float fields

4924. By Raphael Collet (OpenERP)

[ADD] new fields: add char, text, html, date and datetime fields

4925. By Raphael Collet (OpenERP)

[IMP] new fields: refactor methods from_column and to_column

4926. By Raphael Collet (OpenERP)

[IMP] new fields: check value format when assigning a field

4927. By Raphael Collet (OpenERP)

[ADD] new fields: add binary and selection fields

4928. By Raphael Collet (OpenERP)

[IMP] new fields: small refactoring of field methods

4929. By Raphael Collet (OpenERP)

[IMP] new fields: add missing option 'translate' on string fields

4930. By Raphael Collet (OpenERP)

[IMP] orm: make null instances a subset of records

4931. By Raphael Collet (OpenERP)

[IMP] new fields: fix recomputation (spec stored in thread-local instead of scope proxy), and improve tests

4932. By Raphael Collet (OpenERP)

[ADD] new fields: add relational fields (many2one, one2many, many2many)

4933. By Raphael Collet (OpenERP)

[ADD] new fields: add reference fields + fix small error in selection fields

4934. By Raphael Collet (OpenERP)

[MERGE] from trunk

4935. By Raphael Collet (OpenERP)

[IMP] orm: browse() always returns instances attached to a scope

4936. By Raphael Collet (OpenERP)

[IMP] orm: refactor record and recordset instances creation
 - add explicit conversion method to_record(), to_recordset()
 - null(), record(), recordset() return instances attached to the current scope
 - consequently, all BaseModel instances (except the registry one) are attached
   to a scope
 - adapt existing code using those methods

4937. By Raphael Collet (OpenERP)

[IMP] orm: recordset implementation now refers to records instead of ids

4938. By Raphael Collet (OpenERP)

[IMP] openerp.osv.scope: improve api of scope proxy

4939. By Raphael Collet (OpenERP)

[IMP] orm: method recordset() called without params returns an empty recordset

4940. By Raphael Collet (OpenERP)

[MERGE] from trunk

4941. By Raphael Collet (OpenERP)

[IMP] orm: remove instance property scope, and add method to attach instances to the current scope

4942. By Raphael Collet (OpenERP)

[IMP] orm: in the record cache, store values at the record level

4943. By Raphael Collet (OpenERP)

[IMP] orm, scope: change the implementation of the record cache
 - the cache is a dictionary like {model_name: {record_id: record, ...}, ...}
 - each record holds its own cache: record._data = {field_name: value, ...}
 - the code to get/set fields on records has been adapted

4944. By Raphael Collet (OpenERP)

[FIX] new fields: attach model instances to the same scope as a record's cache

4945. By Raphael Collet (OpenERP)

[IMP] new fields: improve test methods

4946. By Raphael Collet (OpenERP)

[IMP] orm: small code improvements

4947. By Raphael Collet (OpenERP)

[IMP] orm: avoid methods record() and recordset() looking up for records in the cache

4948. By Raphael Collet (OpenERP)

[IMP] orm: make method to_record() more tolerant, and method one() to be strict

4949. By Raphael Collet (OpenERP)

[FIX] orm: when assigning record field with setattr, call write() in record's scope

4950. By Raphael Collet (OpenERP)

[IMP] orm: interface all _columns with new-style fields

4951. By Raphael Collet (OpenERP)

[FIX] new fields tests: improve selection of partners when assigning parents!

4952. By Raphael Collet (OpenERP)

[FIX] reports: fix method setLang() so that it 're-scopes' the objects in a clean way

4953. By Raphael Collet (OpenERP)

[IMP] orm: rename instance attributes (_id -> _record_id, _data -> _record_cache)

4954. By Raphael Collet (OpenERP)

[IMP] orm: improve error handling in method _get_field()

4955. By Raphael Collet (OpenERP)

[IMP] orm, new fields: small code cleanup

4956. By Raphael Collet (OpenERP)

[IMP] orm: introduce draft records

4957. By Raphael Collet (OpenERP)

[IMP] orm: add pseudo-class Draft for draft records

4958. By Raphael Collet (OpenERP)

[IMP] fields: make method read_to_cache() more robust

4959. By Raphael Collet (OpenERP)

[IMP] orm: rewrite method default_get() in order to simplify refactoring with draft records

4960. By Raphael Collet (OpenERP)

[IMP] orm: small improvements for draft records, and add __setitem__ method

4961. By Raphael Collet (OpenERP)

[FIX] new fields: forgot method record_to_read() on one2many and many2many fields

4962. By Raphael Collet (OpenERP)

[ADD] new fields: add related fields (non-stored ones)

4963. By Raphael Collet (OpenERP)

[IMP] orm: interface inherited fields with new-style related fields
+fix the field 'date' in res.currency to avoid cache inconsistencies

4964. By Raphael Collet (OpenERP)

[FIX] scope cache: never remove records from the cache, as it breaks an implementation property

This fixes a subtle issue that may happen after a cache invalidation. If you
remove a record from the scope cache, you may still refer and read that record,
but the values read from the database will be stored in another record instance!

In fact this issue did not cause a bug, because the record was "forced" into the
cache before fetching data from the database. But the "prefetching" effect (read
all records of the same model in the cache) was broken if you try to read other
records that were also removed from the cache!

4965. By Raphael Collet (OpenERP)

[IMP] scope cache: fix the consistency check of the cache (because of the modified behavior of read())

4966. By Raphael Collet (OpenERP)

[IMP] orm: code simplification, using the fact that all fields are interfaced with new-style fields

4967. By Raphael Collet (OpenERP)

[IMP] fields2: determine inverse fields, and improve cache invalidation and recomputation

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

one note during reading, wouldn't the `decorator.decorator(self.lookup, method)` call in cache.py work just as well as `functools.partial(self.lookup, method)`?

4968. By Raphael Collet (OpenERP)

[IMP] orm: put all conversion method from/to cache in new fields classes

4969. By Raphael Collet (OpenERP)

[IMP] orm: change implementation of draft records, add them a specific cache

4970. By Raphael Collet (OpenERP)

[IMP] orm: reimplement default_get with draft records

4971. By Raphael Collet (OpenERP)

[IMP] orm: optimize method add_default_value() by caching defaults from ir_values

4972. By Xavier (Open ERP)

[IMP] rename new API test module for clarity

4973. By Xavier (Open ERP)

[ADD] bunch of todos in doc (for both implementation and documentation of new API)

4974. By Xavier (Open ERP)

[ADD] start of onchange implementation

* fix _get_field for non-stored fields on draft records: computed
  fields will be stored in _record_draft, not _record_cache

* add handling of cache invalidation to draft fields: when setting a
  value on a field, invalidate the stuff which depends on it (nb: not
  currently recursive)

The current contract for Model.onchange is simple: give it the field
change which triggered the call and all values[0], onchange will build
a draft record with all values *but* the trigger in its cache (as if
they were defaults or had been read from the db) then set the changed
field via the normal UI.

Then iterate all fields and see what changed from the values provided,
this should yield only the fields which 1. were recomputed 2. to a
value different than the one they previously had.

[0] this may be a very, very bad idea for huge & complex objects full
    of o2ms & m2ms

4975. By Xavier (Open ERP)

[DOC] more todos

4976. By Xavier (Open ERP)

[FIX] forgot to add onchange tests

4977. By Xavier (Open ERP)

[FIX] apparently we still need to manually mark methods as api.record

4978. By Xavier (Open ERP)

[FIX] log_access fields

4979. By Xavier (Open ERP)

[REM] _protected attribute has been unused since revision 921 (2008)...

4980. By Xavier (Open ERP)

[FIX] m2o fields and conversion to columns

* Fix handling of ondelete when converting to a column

* Allow Field -> Column overwriting when the field was created
  explicitly (not field.interface), otherwise when overwriting a field
  in an _inherit the corresponding Column object is outdated and
  incorrect.

4981. By Xavier (Open ERP)

[FIX] correctly get default value from new-style fields when adding required attribute/constraint

4982. By Xavier (Open ERP)

[IMP] un-generalize getattr: since all _columns are also set up as fields, it's only a source of errors

in case of e.g. method name typos it'll go into _get_field then blow up

4983. By Xavier (Open ERP)

[FIX] fields_view_get for purely computed new-style fields

* generate a function column if store=False

* handle all setting on old-style (base and generated) fields

* slighly improve Field.to_column flow

* bypass db write on setattr if store=False

* remove more special handling of concurrency field (it's now a basic
  Field@store=False)

4984. By Vo Minh Thu

[IMP] fields2: add domain attribute to x2x.

4985. By Raphael Collet (OpenERP)

[MERGE] orm: store model attributes shared by all instance in the class instead of the instances

4986. By Raphael Collet (OpenERP)

[REF] orm: refactor the addition of a new-style field on a model's class

4987. By Raphael Collet (OpenERP)

[IMP] orm: turn some internal methods into class methods, and make them private

4988. By Raphael Collet (OpenERP)

[REF] orm: introduce 'id' as an explicit field (with special getter)

4989. By Xavier (Open ERP)

[IMP] enable debug mode post_mortem on CLI use of the server, not just rpc

4990. By Xavier (Open ERP)

[FIX] generalized symbol_* handling on function fields

4991. By Xavier (Open ERP)

[IMP] default values for ir_model datetime fields: use fields.datetime.now

4992. By Xavier (Open ERP)

[IMP] query building in create: string concatenation is 'orrible

4993. By Xavier (Open ERP)

[IMP] extract addition of defaults to a column so they stay in sync between new column and old-column-becoming-required

4994. By Xavier (Open ERP)

[IMP] creation of access fields & handling of concurrency computation methods, ensure access rights fields can't be written by a user

4995. By Xavier (Open ERP)

[IMP] remove creation of ir.ui.menu table in SQL, move security stuff around to get it to work correctly

4996. By Xavier (Open ERP)

[REM] useless creation of workflow tables in raw SQL

4997. By Raphael Collet (OpenERP)

[IMP] orm: reimplement fields_get with new-style fields

4998. By Raphael Collet (OpenERP)

[IMP] new fields: do not create columns for non-stored fields

4999. By Raphael Collet (OpenERP)

[FIX] orm: duplicate model attributes like _columns to avoid sharing their default value!

5000. By Xavier (Open ERP)

[IMP] use unittest2.TestCase.addCleanup for rollback global alteration to registry/fields in tests

5001. By Raphael Collet (OpenERP)

[IMP] scope: change the cache structure (to ease upcoming changes)

5002. By Raphael Collet (OpenERP)

[IMP] orm: in draft records, use a sentinel for a missing value

5003. By Raphael Collet (OpenERP)

[IMP] orm: remove attribute _record_cache from record instances

5004. By Raphael Collet (OpenERP)

[IMP] ir_model: introduce right scope when creating instance in registry

5005. By Raphael Collet (OpenERP)

[IMP] api: improve internal code, and rename decorators: @recordset -> @multi, @record -> @one

5006. By Raphael Collet (OpenERP)

[IMP] api: improve code for extracting context from arguments

5007. By Raphael Collet (OpenERP)

[IMP] orm: NEW DESIGN - now all model instances are recordsets

5008. By Raphael Collet (OpenERP)

[FIX] service: fix test on model returned from registry

5009. By Raphael Collet (OpenERP)

[MERGE] from trunk

5010. By Raphael Collet (OpenERP)

[REV] revid:<email address hidden>
this changeset was not correct:
 - column wkf_instance.uid still used in openerp/workflow/instance.py
 - table wkf_witm_trans still used in openerp/workflow/workitem.py
one has to clean up the code first...

5011. By Raphael Collet (OpenERP)

[FIX] test_impex: fix exports by reimplementing __export_row()

5012. By Raphael Collet (OpenERP)

[MERGE] from trunk

5013. By Raphael Collet (OpenERP)

[IMP] scope: do not use class Scope in non-ORM code

5014. By Raphael Collet (OpenERP)

[IMP] openerp: improve imports for module code

5015. By Raphael Collet (OpenERP)

[REM] orm: remove pseudo-classes Recordset, Record, Null

5016. By Raphael Collet (OpenERP)

[IMP] cache invalidation: simplify the 'spec' parameter

5017. By Raphael Collet (OpenERP)

[IMP] field recomputation: do not search for records in the case of non-stored fields

5018. By Raphael Collet (OpenERP)

[FIX] scope: handle the case of calls like scope(cr, uid, None)

5019. By Raphael Collet (OpenERP)

[IMP] orm: new implementation of draft records that fits better with the design

5020. By Raphael Collet (OpenERP)

[MERGE] from trunk

5021. By Raphael Collet (OpenERP)

[IMP] orm: reimplement new-style method onchange

5022. By Raphael Collet (OpenERP)

[ADD] orm: union, intersection, difference of recordset + set comparison

5023. By Raphael Collet (OpenERP)

[IMP] orm: test error cases for set operations

5024. By Raphael Collet (OpenERP)

[IMP] orm: improve record cache management
 - better prefetching: browse() introduces cache entries for its records
 - quicker access: memoize access to the cache in model instances

5025. By Raphael Collet (OpenERP)

[IMP] fields attribute cleanup: f.model, f.comodel and f.inverse_field are the objects instead of their names

5026. By Raphael Collet (OpenERP)

[IMP] scope: improve the cache invalidation API

5027. By Raphael Collet (OpenERP)

[REF] orm: improve management of recomputation of stored function fields
 - make fields manage their dependencies and recomputation triggers
 - introduce a global recomputation manager object (simpler than "specs")

5028. By Raphael Collet (OpenERP)

[IMP] scope: simplification of API and implementation
 - scopes are no longer iterable, use scope.args to retrieve cr, uid, context
 - use named args when calling a scope: scope(user=42), scope(context={...})

5029. By Raphael Collet (OpenERP)

[MERGE] from trunk

5030. By Raphael Collet (OpenERP)

[IMP] orm, fields: small code improvements (avoid __class__ and such)

5031. By Raphael Collet (OpenERP)

[IMP] new fields: when searching for records to recompute, make sure to retrieve all of them

5032. By Raphael Collet (OpenERP)

[IMP] orm: add automatic cache invalidation for non-stored fields.function

5033. By Raphael Collet (OpenERP)

[IMP] orm: delegate compute/read fields on fields themselves

5034. By Raphael Collet (OpenERP)

[IMP] orm: change API of draft records

5035. By Raphael Collet (OpenERP)

[REF] orm: improve the representation of model instances
 - each instance refers directly to its records' cache dictionaries
 - the 'id' of each record is in its cache dictionary (except new records)
 - VirtualID is no longer needed
 - the access to a record's cache is faster

5036. By Raphael Collet (OpenERP)

[IMP] record cache: better implementation for cache invalidation
 - the record cache is no longer a built-in dict
 - the model cache keeps track of which fields are present in record caches
 - invalidating an already-invalidated field simply does nothing

5037. By Raphael Collet (OpenERP)

[IMP] new fields: when dealing with modified fields, invalidate the cache in a more direct way

5038. By Raphael Collet (OpenERP)

[IMP] scope: improve code for checking the cache

5039. By Raphael Collet (OpenERP)

[IMP] new fields: add helper function to provide a constant default for a field

5040. By Raphael Collet (OpenERP)

[IMP] orm: separate concepts of 'new' and 'draft' instances

5041. By Raphael Collet (OpenERP)

[IMP] orm: fix the mess with 'id' in record cache

5042. By Raphael Collet (OpenERP)

[IMP] scope: use better exception type when checking the cache

5043. By Raphael Collet (OpenERP)

[IMP] fields: when computing the value of a field, do it for all records in cache

5044. By Raphael Collet (OpenERP)

[IMP] orm: improve the recomputation manager to hide some hack

5045. By Raphael Collet (OpenERP)

[IMP] record cache: small code cleanup

5046. By Raphael Collet (OpenERP)

[FIX] orm: fix instance comparison, which was not independent from scope!

5047. By Raphael Collet (OpenERP)

[IMP] record cache: add special values to missing default values, fields being computed, etc.

5048. By Raphael Collet (OpenERP)

[IMP] new fields: make date/datetime conversions more robust

5049. By Raphael Collet (OpenERP)

[FIX] orm: fix computation of field __last_update

5050. By Raphael Collet (OpenERP)

[FIX] new fields: add missing method redirection in related fields

5051. By Raphael Collet (OpenERP)

[IMP] new fields: refactor conversion methods to the cache level

5052. By Raphael Collet (OpenERP)

[IMP] orm: small code cleanup

5053. By Raphael Collet (OpenERP)

[ADD] new fields: add inverse computation of fields

5054. By Raphael Collet (OpenERP)

[ADD] osv/cache: make the record cache read/write-through

5055. By Raphael Collet (OpenERP)

[IMP] record cache: improve implementation, use named tuples for cache slots

5056. By Raphael Collet (OpenERP)

[IMP] osv cache: improve documentation

5057. By Raphael Collet (OpenERP)

[MERGE] from trunk

5058. By Raphael Collet (OpenERP)

[ADD] new fields: add search on fields
 - add an option to rewrite a condition on a field
 - in expression.py, rename local variables to fit new terminology

5059. By Raphael Collet (OpenERP)

[FIX] test_impex: make code consistent with values in selection function (ints not strings)

5060. By Raphael Collet (OpenERP)

[FIX] test_workflow: use 'class' instead of type() to create model classes,
because type() registers the class under the wrong module name (openerp.osv.api)

5061. By Raphael Collet (OpenERP)

[IMP] api: improve documentation of attributes set on methods

5062. By Raphael Collet (OpenERP)

[ADD] orm: add new-style Python constraints with a decorator

5063. By Raphael Collet (OpenERP)

[IMP] orm: fix and extend a bit the generic onchange method

5064. By Raphael Collet (OpenERP)

[FIX] test_new_api: make test pass when test_new_api_extend is installed

5065. By Raphael Collet (OpenERP)

[IMP] new fields: reimplement related fields as compute fields

5066. By Raphael Collet (OpenERP)

[IMP] new fields: when setting up a related field, complete the setup of a field before getting its attributes

5067. By Raphael Collet (OpenERP)

[MERGE] from trunk

5068. By Raphael Collet (OpenERP)

[FIX] registry: buggy non-zero test on model

5069. By Raphael Collet (OpenERP)

[IMP] orm: make result of onchange() backwards-compatible

5070. By Raphael Collet (OpenERP)

[IMP] fields2: reorganize code, and ensure that _ready is reset upon copy

5071. By Raphael Collet (OpenERP)

[IMP] base/ir.module.module: optimize state_update() (minimize calls to write)

5072. By Raphael Collet (OpenERP)

[FIX] new fields: on related selection fields, the selection must be computed by the target field

5073. By Raphael Collet (OpenERP)

[MERGE] from trunk

5074. By Raphael Collet (OpenERP)

[IMP] fields2: remove pudb invocation

5075. By Raphael Collet (OpenERP)

[FIX] scope: make scope() more robust when None is given as context

5076. By Raphael Collet (OpenERP)

[FIX] orm: introduce scope explicitly in method scoped()

5077. By Raphael Collet (OpenERP)

[FIX] fields2: bypass access rights to compute related fields

5078. By Raphael Collet (OpenERP)

[FIX] fields2: catch exceptions when computing related fields

5079. By Raphael Collet (OpenERP)

[FIX] orm: apparently, some code in mail needs explicit cache invalidation

5080. By Raphael Collet (OpenERP)

[IMP] cache: simplify implementation of cache slots

5081. By Raphael Collet (OpenERP)

[FIX] orm, registry: add hooks on models before and after a registry update
This fixes a bug where some new fields were keeping a reference to a model
that has been updated in the registry (Many2one's comodel, for instance).

5082. By Raphael Collet (OpenERP)

[FIX] new fields: in *2many values, one may have a dict in the list of commands

5083. By Raphael Collet (OpenERP)

[IMP] fields2: add attributes 'states' to new fields

5084. By Raphael Collet (OpenERP)

[MERGE] from trunk

5085. By Raphael Collet (OpenERP)

[IMP] orm: make read(), create() and write() tolerate unknown fields (with warning)

5086. By Raphael Collet (OpenERP)

[IMP] orm: improve warning message when read/create/write with unknown fields

5087. By Raphael Collet (OpenERP)

[MERGE] from trunk

5088. By Raphael Collet (OpenERP)

[IMP] new fields: in case a field depends on '*', it should not depend on itself

5089. By Raphael Collet (OpenERP)

[IMP] new fields: small code reorganization

5090. By Raphael Collet (OpenERP)

[IMP] orm: add field display_name, and reimplement name_{get,create,search} in terms of it

5091. By Raphael Collet (OpenERP)

[ADD] fields2: add option delegate=True in many2one fields to include field in dict _inherits

5092. By Raphael Collet (OpenERP)

[IMP] orm: small simplification in method _set_magic_fields()

5093. By Raphael Collet (OpenERP)

[MERGE] trunk-apiculture-snakecase-rco: use snake-casing for model names

5094. By Raphael Collet (OpenERP)

[FIX] fields: fix _symbol_set for fields.model

5095. By Raphael Collet (OpenERP)

[IMP] fields2: do not compute fields on non-existing records
 - This reduces the need to handle exceptions when computing fields.

5096. By Raphael Collet (OpenERP)

[IMP] orm: make inverse and search on display_name more robust

5097. By Raphael Collet (OpenERP)

[FIX] base: in ir_module_module, snakecase model names explicitly

5098. By Raphael Collet (OpenERP)

[MERGE] from trunk

5099. By Raphael Collet (OpenERP)

[FIX] openerp.tools: make snake_dict raise KeyError when looking up with a non-string

5100. By Raphael Collet (OpenERP)

[IMP] api: reduce methods wrappers to a single layer; this eases debugging

5101. By Raphael Collet (OpenERP)

[MERGE] from trunk

5102. By Raphael Collet (OpenERP)

[FIX] test_workflow: remove unexpected argument that is mistakenly interpreted as a context

5103. By Raphael Collet (OpenERP)

[FIX] orm: avoid doing None + list in name_search()

5104. By Raphael Collet (OpenERP)

[FIX] ir_ui_view: snake-case model name in sql query

5105. By Raphael Collet (OpenERP)

[IMP] fields2: small code cleanup

5106. By Raphael Collet (OpenERP)

[IMP] openerp/osv/*: remove unused imports

5107. By Raphael Collet (OpenERP)

[FIX] orm: make resolve_2many_commands() robust when argument is False

5108. By Raphael Collet (OpenERP)

[FIX] orm, fields2: make field 'id' non-overridable
The implementation fields2.Id is critical to make "record.id" work properly.

5109. By Raphael Collet (OpenERP)

[MERGE] from trunk

5110. By Raphael Collet (OpenERP)

[IMP] fields2: cleanup of Field.interface

5111. By Raphael Collet (OpenERP)

[IMP] fields2: improve code about digits in field Float

5112. By Raphael Collet (OpenERP)

[IMP] fields, fields2: cleanup of code converting one to another

5113. By Raphael Collet (OpenERP)

[IMP] fields2: uniformize internal API to export field attributes

5114. By Raphael Collet (OpenERP)

[FIX] orm: in _add_missing_default_values, do not ask default values for magic fields

5115. By Raphael Collet (OpenERP)

[IMP] openerp/tools: optimize lazy_property.reset_all()

5116. By Raphael Collet (OpenERP)

[REVERT] snake-casing of model names: not worth the bugs and performance penalty

5117. By Raphael Collet (OpenERP)

[MERGE] trunk-apiculture-stw: make logs from mail server less noisy

5118. By Stephane Wirtel (OpenERP)

[FIX][TMP] Use a fields.char instead of the fields.function(selection) for the ir.ui.view#type field

5119. By Stephane Wirtel (OpenERP)

[FIX] Authorize the modules to define new kind of views.

5120. By Raphael Collet (OpenERP)

[IMP] ir_ui_view: improve method name

5121. By Stephane Wirtel (OpenERP)

[MERGE] trunk-apiculture-recname: avoid non-null constraint if _rec_name is required

5122. By Raphael Collet (OpenERP)

[FIX] ir_ui_menu: put the menu cache on the model's class, instead of an instance

5123. By Stephane Wirtel (OpenERP)

[FIX] In the ORM, the functions who start with 'set_' are used by the
default_get method. But it's not the case for set_default_value_on_column.
We rename this method to avoid this mistake.

5124. By Raphael Collet (OpenERP)

[FIX] ir_model_data: put the cache dictionary 'loads' on the class instead of an instance

5125. By Raphael Collet (OpenERP)

[IMP] orm: refactor method create_instance()

5126. By Raphael Collet (OpenERP)

[IMP] orm: remove method __getattr__ from BaseModel; it is bug-prone and not really useful

5127. By Raphael Collet (OpenERP)

[IMP] scope: small code refactoring

5128. By Raphael Collet (OpenERP)

[IMP] ir_sequence: small code cleanup to help API converters

5129. By Raphael Collet (OpenERP)

[IMP] orm, scope: move the 'draft' flag on the scope instead of the records

5130. By Raphael Collet (OpenERP)

[IMP] scope: draft mode is now global to all scopes

5131. By Stephane Wirtel (OpenERP)

[FIX] openerp/report: use_global_header is a transient field on the ir.action.report.xml object. We use it to avoid a change in the API.

5132. By Stephane Wirtel (OpenERP)

[FIX] test_mail: Rewrite the XSS test

5133. By Raphael Collet (OpenERP)

[IMP] orm: simplify the records cache (remove slots)

5134. By Raphael Collet (OpenERP)

[IMP] api, fields: @depends can now be given a function to compute dependencies
For field 'display_name', this optimizes triggers, since dependencies were given
as '*', which adds a trigger on *all* fields of the model!

5135. By Raphael Collet (OpenERP)

[MERGE] from trunk

5136. By Raphael Collet (OpenERP)

[MERGE] from trunk

5137. By Raphael Collet (OpenERP)

[FIX] orm: insert the instance in the registry sooner (fixes missing fields in _inherits_reload())

5138. By Stephane Wirtel (OpenERP)

[IMP] Add a new test for the inheritance computing.

5139. By Stephane Wirtel (OpenERP)

[IMP] Add a test for the new api. This test will create a new model and checks
that we can add a new attribute on the instance of a model.

Sometimes, by example, in the report engine, we add a new attribute on the
instance. By the way, we can add this attribute without any write to the
database.

5140. By Stephane Wirtel (OpenERP)

[FIX] Add a new attribue into the instance of the ir.actions.report.xml instance
because we need of a flag to use or not the right header in the report engine.

The previous implementation was wrong! Sorry

5141. By Stephane Wirtel (OpenERP)

[REF] Rewrite the fields_get method of the ORM. Especially the part for the
translation. This new implementation is just a refactoring and does not change
the behavior the function.

5142. By Raphael Collet (OpenERP)

[IMP] orm: improve __sub__ and __and__ on records, avoid comparing dict contents

5143. By Raphael Collet (OpenERP)

[IMP] base: always use method read() with multiple ids (this is necessary to change its API)

5144. By Raphael Collet (OpenERP)

[FIX] res_company: fix call to read()

5145. By Raphael Collet (OpenERP)

[IMP] new fields: decorator @one enables recursive computation of fields

5146. By Raphael Collet (OpenERP)

[IMP] new fields: enable recursive computation of stored fields, too

5147. By Raphael Collet (OpenERP)

[IMP] orm: reimplement method read() using the new API
 - call chain:
    record.read() uses new API to get and convert values
    -> field.__get__() retrieves value from cache or compute it
    -> field.determine_value() determines whether to compute or read value
    -> record._prefetch_field() determines which records and fields to read
    -> record._read_into_cache() actually reads data and store it in cache
 - exceptions are stored as values in cache, and raised upon reading cache
 - added a new exception for missing records
 - ISSUE: we cannot reproduce the behavior of read() with a single id; it now
   returns a list of dicts instead of a dict

5148. By Stephane Wirtel (OpenERP)

[FIX] base: The default value for the name of a currency rate is now a
field.datetime, and thus in this case, we have to use the default value for this
kind of a field.

5149. By Stephane Wirtel (OpenERP)

[FIX] openerp/osv/orm: Check if the fields parameter of the read method is not
None or False. In this case, the method will use the _fields attribute of the
current object. Otherwise, this code will crash because a boolean is not
iterable.

5150. By Raphael Collet (OpenERP)

[IMP] scope: optimize API of scope.invalidate(), resulting in 5% to 10% speedup
 - every call to proxy.invalidate iterates over all scopes (which is costly to access)
 - the new api groups many calls into a single one, which leads to less access to all_scopes

5151. By Raphael Collet (OpenERP)

[IMP] orm: rename _read_cache into _get_cache to make it less confusing

5152. By Raphael Collet (OpenERP)

[IMP] orm: change structure of the cache, resulting in 5-10% speedup
 - new cache is indexed by field object, then by record id
 - cache access is a bit slower, but invalidation is way faster

5153. By Raphael Collet (OpenERP)

[IMP] orm: private method _update_cache now updates all records in self

5154. By Raphael Collet (OpenERP)

[REF] fields2: generalize FailedValues to special values stored in the cache
 - SpecialValue encapsulates null values in new records missing default values
 - FailedValue encapsulates exceptions for various kinds of failures to report
 - These special values transmit information from the point where a field value
   is determined to the point where the cache is actually read.

5155. By Raphael Collet (OpenERP)

[FIX] fields2: undefined variable

5156. By Raphael Collet (OpenERP)

[FIX] base: missing dependency on computed field

5157. By Raphael Collet (OpenERP)

[MERGE] from trunk

5158. By Raphael Collet (OpenERP)

[IMP] scope: rename method SUDO() into sudo()

5159. By Raphael Collet (OpenERP)

[FIX] new fields: fix scope mess in related fields, and evaluate name_get() in sudo mode in convert_to_read()

5160. By Raphael Collet (OpenERP)

[FIX] fields2: add cache converter on text fields, and remove it from binary fields
 - this fixes two broken tests in test_impex
 - change type of field 'domain' on 'ir.rule' to 'binary' (value is a Python list)

5161. By Raphael Collet (OpenERP)

[FIX] fields: add missing comma in tuple

5162. By Raphael Collet (OpenERP)

[FIX] orm: method name_get() must evaluate display_name in the current scope, not self's own scope

5163. By Raphael Collet (OpenERP)

[REF] orm: make AccessError and MissingError children classes of except_orm
Why? Because some modules handle access right errors by catching except_orm!

5164. By Raphael Collet (OpenERP)

[FIX] orm: before getting records in cache, always make sure the record to read is in cache!

5165. By Raphael Collet (OpenERP)

[IMP] orm: improve method check_field_access_rights()

5166. By Raphael Collet (OpenERP)

[FIX] fields2: when setting related fields, do not assign null records

5167. By Raphael Collet (OpenERP)

[IMP] orm: add properties _cr, _uid, _context on recordsets (bw compatibility w/ browse records)

5168. By Stephane Wirtel (OpenERP)

[IMP] Keep the backward compatibility with the old version of OpenERP

5169. By Stephane Wirtel (OpenERP)

[FIX] Pass the rights parameter to the right method in the wrapper

5170. By Raphael Collet (OpenERP)

[MERGE] from trunk

5171. By Raphael Collet (OpenERP)

[IMP] orm: simplify the query for reading 'classic_write' columns

5172. By Stephane Wirtel (OpenERP)

[FIX] On OSX, the system has a lot of Bitmap fonts, and in this case, Reportlab
can not load the 'head' table from the structure of the TTF file. There is no
good way to check if a TTF file is an old style or new style.

5173. By Raphael Collet (OpenERP)

[FIX] orm: add access rights check for fields in read()

5174. By Raphael Collet (OpenERP)

[IMP] api: add method decorators 'old' and 'new' to manually define api implementations
This allows to remove the hack that handles the case of method 'read': its old-style
implementation is given explicitly.

5175. By Raphael Collet (OpenERP)

[FIX] fields: decorate functions used in fields (selection, domain) to make them callable with both apis

5176. By Raphael Collet (OpenERP)

[IMP] api: make scope getter function more specific

5177. By Raphael Collet (OpenERP)

[MERGE] from trunk

5178. By Stephane Wirtel (OpenERP)

[MERGE] from trunk

5179. By Raphael Collet (OpenERP)

[FIX] fields: add api wrapper for selection function in function fields

5180. By Raphael Collet (OpenERP)

[IMP] orm: improve code of method create()

5181. By Raphael Collet (OpenERP)

[MERGE] from trunk

5182. By Raphael Collet (OpenERP)

[IMP] orm: modify the chain of calls for reading records such that overridden read() is taken into account
 - motivation: if method read() is overridden, field.__get__() uses it!
 - records.read() calls records._read_from_database() to store values in cache,
   then it retrieves values from the cache (included computed fields)
 - field.__get__() retrieves stored fields by calling record._prefetch_field(),
   which calls records.read() for stored fields only (no call loop!)

5183. By Raphael Collet (OpenERP)

[FIX] orm: in _read_from_database(), avoid getting post fields with empty ids list

5184. By Raphael Collet (OpenERP)

[FIX] scope: make the draft switch more robust in case of exceptions

5185. By Raphael Collet (OpenERP)

[IMP] api: make the decorators 'old' and 'new' more intuitive

5186. By Raphael Collet (OpenERP)

[IMP] orm scope: use a weak dictionary to store the set of scopes

Unmerged revisions

5186. By Raphael Collet (OpenERP)

[IMP] orm scope: use a weak dictionary to store the set of scopes

5185. By Raphael Collet (OpenERP)

[IMP] api: make the decorators 'old' and 'new' more intuitive

5184. By Raphael Collet (OpenERP)

[FIX] scope: make the draft switch more robust in case of exceptions

5183. By Raphael Collet (OpenERP)

[FIX] orm: in _read_from_database(), avoid getting post fields with empty ids list

5182. By Raphael Collet (OpenERP)

[IMP] orm: modify the chain of calls for reading records such that overridden read() is taken into account
 - motivation: if method read() is overridden, field.__get__() uses it!
 - records.read() calls records._read_from_database() to store values in cache,
   then it retrieves values from the cache (included computed fields)
 - field.__get__() retrieves stored fields by calling record._prefetch_field(),
   which calls records.read() for stored fields only (no call loop!)

5181. By Raphael Collet (OpenERP)

[MERGE] from trunk

5180. By Raphael Collet (OpenERP)

[IMP] orm: improve code of method create()

5179. By Raphael Collet (OpenERP)

[FIX] fields: add api wrapper for selection function in function fields

5178. By Stephane Wirtel (OpenERP)

[MERGE] from trunk

5177. By Raphael Collet (OpenERP)

[MERGE] from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.