Skip to content
Snippets Groups Projects
  1. Oct 10, 2016
  2. Oct 09, 2016
  3. Oct 07, 2016
  4. Oct 06, 2016
    • Michael Brown's avatar
      [FIX] models: fix behaviour of 'defer_parent_store_computation' · d477dcc3
      Michael Brown authored
      
      If a model uses nested sets to maintain a hierarchical record
      ordering, then bulk inserts (e.g. via a CSV import) are likely to
      suffer from an O(n^2) performance penalty, since there is a high
      chance that each new record will require many of the existing records'
      parent_left and parent_right fields to be updated.
      
      The context parameter 'defer_parent_store_computation' may be passed
      to the load() method, in order to defer updating the parent_left and
      parent_right fields until after the bulk operation is complete.  This
      appears to have last been fully supported in version 7 (via the old
      import_data() method).
      
      It is still possible to specify 'defer_parent_store_computation',
      e.g. via an XML-RPC call such as
      
        m.execute_kw(dbname, uid, password, 'stock.location', 'load', [],
                     {'fields': fields, 'data': data,
                      'context': {'defer_parent_store_computation': True}})
      
      This will currently defer the recalculation of parent_left and
      parent_right, but does not correctly call _parent_store_compute()
      after the bulk operation is complete.
      
      Add the missing call to _parent_store_compute() to perform a one-time
      update of the parent_left and parent_right fields if needed after the
      import operation is complete.
      
      Also fix the child_of_domain() and parent_of_domain() expression
      methods, so that the 'child_of' and 'parent_of' operators give correct
      answers when updates to parent_left and parent_right have been
      deferred.
      
      Signed-off-by: default avatarMichael Brown <mbrown@fensystems.co.uk>
      
      Closes #13688 (part 2/2)
      d477dcc3
    • Michael Brown's avatar
      [FIX] expression: pass context to hierarchical domain operators · 22c4a0c1
      Michael Brown authored
      
      The expression context is currently passed to to_ids() but is missing
      from all calls to child_of_domain() or parent_of_domain().  These
      methods are effectively always passed a context of None.
      
      Signed-off-by: default avatarMichael Brown <mbrown@fensystems.co.uk>
      
      Closes #13688 (part 1/2)
      22c4a0c1
    • Michael Brown's avatar
      [FIX] product: speed up product.template bulk record creation · 1b3d60d9
      Michael Brown authored
      
      Bulk inserts of product definitions (e.g. via a CSV import) will
      suffer from an O(n^2) performance penalty due to an unfortunate cache
      invalidation bug.  The underlying cause is difficult to determine due
      to the labyrinthine nature of the relationship between product.product
      and product.template, but some key elements are:
      
      - The "product_variant_count" field is a non-stored computed field,
        and so gets invalidated by the call to recs.modified(upd_todo) in
        BaseModel.create()
      
      - Field.determine_value() will call _prefetch_field() to repopulate
        "product_variant_count" by refetching all records from the database,
        despite the fact that "product_variant_count" is not stored in the
        database.
      
      Using the length of "product_variant_ids" directly (instead of going
      via "product_variant_count") seems to avoid this problem, possibly
      because the definition of "product_variant_ids" conveys more
      information about the circumstances in which its value must be
      invalidated.
      
      An alternative solution of making product_variant_count a stored field
      (using the same trigger as for other variant-derived fields such as
      volume and weight) works but still results in some unnecessary fetches
      and invalidations.
      
      Signed-off-by: default avatarMichael Brown <mbrown@fensystems.co.uk>
      
      Closes #13689
      1b3d60d9
    • Martin Trigaux's avatar
      ef60b24c
    • Christophe Simonis's avatar
  5. Oct 05, 2016
  6. Oct 04, 2016
Loading