Navigation Menu

Skip to content

Commit

Permalink
[MERGE] forward port branch 10.0 up to 544aa9b
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Aug 10, 2017
2 parents 08b75b7 + 544aa9b commit a2361e2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion addons/stock/models/stock_location.py
Expand Up @@ -69,7 +69,7 @@ def default_get(self, fields):
_sql_constraints = [('barcode_company_uniq', 'unique (barcode,company_id)', 'The barcode for a location must be unique per company !')]

@api.one
@api.depends('name', 'location_id')
@api.depends('name', 'location_id.name')
def _compute_complete_name(self):
""" Forms complete name of location from parent location to child location. """
name = self.name
Expand Down
2 changes: 1 addition & 1 deletion addons/website_event/controllers/main.py
Expand Up @@ -226,7 +226,7 @@ def _process_tickets_details(self, data):
def registration_new(self, event, **post):
tickets = self._process_tickets_details(post)
if not tickets:
return request.redirect("/event/%s" % slug(event))
return False
return request.env['ir.ui.view'].render_template("website_event.registration_attendee_details", {'tickets': tickets, 'event': event})

def _process_registration_details(self, details):
Expand Down
3 changes: 2 additions & 1 deletion addons/website_sale/controllers/main.py
Expand Up @@ -358,7 +358,8 @@ def cart(self, **post):
values['suggested_products'] = _order._cart_accessories()

if post.get('type') == 'popover':
return request.render("website_sale.cart_popover", values)
# force no-cache so IE11 doesn't cache this XHR
return request.render("website_sale.cart_popover", values, headers={'Cache-Control': 'no-cache'})

return request.render("website_sale.cart", values)

Expand Down
3 changes: 2 additions & 1 deletion odoo/fields.py
Expand Up @@ -568,7 +568,7 @@ def traverse_related(self, record):
""" Traverse the fields of the related field `self` except for the last
one, and return it as a pair `(last_record, last_field)`. """
for name in self.related[:-1]:
record = record[name][:1]
record = record[name][:1].with_prefetch(record._prefetch)
return record, self.related_field

def _compute_related(self, records):
Expand Down Expand Up @@ -981,6 +981,7 @@ def determine_value(self, record):
self.compute_value(record)
else:
recs = record._in_cache_without(self)
recs = recs.with_prefetch(record._prefetch)
self.compute_value(recs)

else:
Expand Down
17 changes: 8 additions & 9 deletions odoo/models.py
Expand Up @@ -3070,10 +3070,6 @@ def _prefetch_field(self, field):
else:
records &= self._in_cache_without(f)

# prefetch at most PREFETCH_MAX records
if len(records) > PREFETCH_MAX:
records = records[:PREFETCH_MAX] | self

# fetch records with read()
assert self in records and field in fs
records = records.with_prefetch(self._prefetch)
Expand Down Expand Up @@ -5195,13 +5191,16 @@ def _cache(self):
return RecordCache(self)

@api.model
def _in_cache_without(self, field):
""" Make sure ``self`` is present in cache (for prefetching), and return
the records of model ``self`` in cache that have no value for ``field``
(:class:`Field` instance).
def _in_cache_without(self, field, limit=PREFETCH_MAX):
""" Return records to prefetch that have no value in cache for ``field``
(:class:`Field` instance), including ``self``.
Return at most ``limit`` records.
"""
ids = filter(None, self._prefetch[self._name] - set(self.env.cache[field]))
return self.browse(ids)
recs = self.browse(ids)
if limit and len(recs) > limit:
recs = self + (recs - self)[:(limit - len(self))]
return recs

@api.model
def refresh(self):
Expand Down

0 comments on commit a2361e2

Please sign in to comment.