Skip to content

Commit

Permalink
Merge pull request odoo#11 from Jarsa-dev/10.0-vauxoo
Browse files Browse the repository at this point in the history
10.0 vauxoo
  • Loading branch information
Luis M. Triana committed Aug 10, 2017
2 parents 5d36c52 + a450486 commit eec53ff
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 32 deletions.
4 changes: 2 additions & 2 deletions addons/account/models/account_invoice.py
Expand Up @@ -762,7 +762,6 @@ def tax_line_move_line_get(self):
if tax.amount_type == "group":
for child_tax in tax.children_tax_ids:
done_taxes.append(child_tax.id)
done_taxes.append(tax.id)
res.append({
'invoice_tax_line_id': tax_line.id,
'tax_line_id': tax_line.tax_id.id,
Expand All @@ -774,8 +773,9 @@ def tax_line_move_line_get(self):
'account_id': tax_line.account_id.id,
'account_analytic_id': tax_line.account_analytic_id.id,
'invoice_id': self.id,
'tax_ids': [(6, 0, done_taxes)] if tax_line.tax_id.include_base_amount else []
'tax_ids': [(6, 0, list(done_taxes))] if tax_line.tax_id.include_base_amount else []
})
done_taxes.append(tax.id)
return res

def inv_line_characteristic_hashcode(self, invoice_line):
Expand Down
2 changes: 1 addition & 1 deletion addons/hr_expense/views/hr_expense_views.xml
Expand Up @@ -392,7 +392,7 @@
<field name="accounting_date"/>
<field name="employee_id"/>
<field name="currency_id" invisible="1"/>
<field name="total_amount" sum="Total Amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="total_amount" sum="Total Amount"/>
<field name="state"/>
<field name="message_unread" invisible="1"/>
</tree>
Expand Down
1 change: 1 addition & 0 deletions addons/mail/models/mail_template.py
Expand Up @@ -581,6 +581,7 @@ def send_mail(self, res_id, force_send=False, raise_exception=False, email_value
'name': attachment[0],
'datas_fname': attachment[0],
'datas': attachment[1],
'type': 'binary',
'res_model': 'mail.message',
'res_id': mail.mail_message_id.id,
}
Expand Down
1 change: 1 addition & 0 deletions addons/mail/models/mail_thread.py
Expand Up @@ -1721,6 +1721,7 @@ def _message_post_process_attachments(self, attachments, attachment_ids, message
data_attach = {
'name': name,
'datas': base64.b64encode(str(content)),
'type': 'binary',
'datas_fname': name,
'description': name,
'res_model': message_data['model'],
Expand Down
2 changes: 1 addition & 1 deletion addons/point_of_sale/models/pos_order.py
Expand Up @@ -823,7 +823,7 @@ def _order_line_fields(self, line):
def create(self, values):
if values.get('order_id') and not values.get('name'):
# set name based on the sequence specified on the config
config_id = self.env['pos.order'].browse(values['order_id']).session_id.config_id.id
config_id = self.order_id.browse(values['order_id']).session_id.config_id.id
# HACK: sequence created in the same transaction as the config
# cf TODO master is pos.config create
# remove me saas-15
Expand Down
3 changes: 1 addition & 2 deletions addons/product/models/product_pricelist.py
Expand Up @@ -111,8 +111,7 @@ def _compute_price_rule(self, products_qty_partner, date=False, uom_id=False):
uom_id = self._context['uom']
if uom_id:
# rebrowse with uom if given
product_ids = [item[0].id for item in products_qty_partner]
products = self.env['product.product'].with_context(uom=uom_id).browse(product_ids)
products = [item[0].with_context(uom=uom_id) for item in products_qty_partner]
products_qty_partner = [(products[index], data_struct[1], data_struct[2]) for index, data_struct in enumerate(products_qty_partner)]
else:
products = [item[0] for item in products_qty_partner]
Expand Down
4 changes: 3 additions & 1 deletion addons/product/models/product_template.py
Expand Up @@ -164,7 +164,9 @@ def _compute_template_price(self):

# Support context pricelists specified as display_name or ID for compatibility
if isinstance(pricelist_id_or_name, basestring):
pricelist = self.env['product.pricelist'].name_search(pricelist_id_or_name, operator='=', limit=1)
pricelist_data = self.env['product.pricelist'].name_search(pricelist_id_or_name, operator='=', limit=1)
if pricelist_data:
pricelist = self.env['product.pricelist'].browse(pricelist_data[0][0])
elif isinstance(pricelist_id_or_name, (int, long)):
pricelist = self.env['product.pricelist'].browse(pricelist_id_or_name)

Expand Down
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
12 changes: 6 additions & 6 deletions addons/web/controllers/main.py
Expand Up @@ -657,7 +657,7 @@ def create(self, master_pwd, name, lang, password, **post):
request.session.authenticate(name, post['login'], password)
return http.local_redirect('/web/')
except Exception, e:
error = "Database creation error: %s" % str(e) or repr(e)
error = "Database creation error: %s" % (str(e) or repr(e))
return self._render_template(error=error)

@http.route('/web/database/duplicate', type='http', auth="none", methods=['POST'], csrf=False)
Expand All @@ -668,7 +668,7 @@ def duplicate(self, master_pwd, name, new_name):
dispatch_rpc('db', 'duplicate_database', [master_pwd, name, new_name])
return http.local_redirect('/web/database/manager')
except Exception, e:
error = "Database duplication error: %s" % str(e) or repr(e)
error = "Database duplication error: %s" % (str(e) or repr(e))
return self._render_template(error=error)

@http.route('/web/database/drop', type='http', auth="none", methods=['POST'], csrf=False)
Expand All @@ -678,7 +678,7 @@ def drop(self, master_pwd, name):
request._cr = None # dropping a database leads to an unusable cursor
return http.local_redirect('/web/database/manager')
except Exception, e:
error = "Database deletion error: %s" % str(e) or repr(e)
error = "Database deletion error: %s" % (str(e) or repr(e))
return self._render_template(error=error)

@http.route('/web/database/backup', type='http', auth="none", methods=['POST'], csrf=False)
Expand All @@ -696,7 +696,7 @@ def backup(self, master_pwd, name, backup_format = 'zip'):
return response
except Exception, e:
_logger.exception('Database.backup')
error = "Database backup error: %s" % str(e) or repr(e)
error = "Database backup error: %s" % (str(e) or repr(e))
return self._render_template(error=error)

@http.route('/web/database/restore', type='http', auth="none", methods=['POST'], csrf=False)
Expand All @@ -706,7 +706,7 @@ def restore(self, master_pwd, backup_file, name, copy=False):
dispatch_rpc('db', 'restore', [master_pwd, name, data, str2bool(copy)])
return http.local_redirect('/web/database/manager')
except Exception, e:
error = "Database restore error: %s" % str(e) or repr(e)
error = "Database restore error: %s" % (str(e) or repr(e))
return self._render_template(error=error)

@http.route('/web/database/change_password', type='http', auth="none", methods=['POST'], csrf=False)
Expand All @@ -715,7 +715,7 @@ def change_password(self, master_pwd, master_pwd_new):
dispatch_rpc('db', 'change_admin_password', [master_pwd, master_pwd_new])
return http.local_redirect('/web/database/manager')
except Exception, e:
error = "Master password update error: %s" % str(e) or repr(e)
error = "Master password update error: %s" % (str(e) or repr(e))
return self._render_template(error=error)

@http.route('/web/database/list', type='json', auth='none')
Expand Down
3 changes: 2 additions & 1 deletion addons/website/static/src/js/website.snippets.animation.js
Expand Up @@ -125,8 +125,9 @@ animation.registry.media_video = animation.Class.extend({
if (!this.$target.has('> iframe').length) {
var editor = '<div class="css_editable_mode_display">&nbsp;</div>';
var size = '<div class="media_iframe_video_size">&nbsp;</div>';
this.$target.html(editor+size+'<iframe src="'+_.escape(this.$target.data("src"))+'" frameborder="0" allowfullscreen="allowfullscreen"></iframe>');
this.$target.html(editor+size);
}
this.$target.html(this.$target.html()+'<iframe src="'+_.escape(this.$target.data("src"))+'" frameborder="0" allowfullscreen="allowfullscreen"></iframe>');
},
});

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
Expand Up @@ -313,7 +313,7 @@
<t t-foreach="order.order_line" t-as="ol">
<div class="row orders_vertical_align">
<div class="col-md-1 text-center">
<img t-att-src="'/web/image/product.product/%s/image_small/48x48' % ol.product_id.id"/>
<img t-att-src="ol.product_id.image_small and ('data:image/png;base64,' + ol.product_id.image_small) or '/web/static/src/img/placeholder.png'"/>
</div>
<div id='product_name' class="col-md-5">
<span t-esc="ol.product_id.name"/>
Expand Down
3 changes: 2 additions & 1 deletion addons/website_sale/controllers/main.py
Expand Up @@ -357,7 +357,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'})

if post.get('code_not_available'):
values['code_not_available'] = post.get('code_not_available')
Expand Down
8 changes: 4 additions & 4 deletions addons/website_sale/views/templates.xml
Expand Up @@ -1192,11 +1192,11 @@
<div class="clearfix" />
<t t-if="mode == ('new', 'billing')">
<div t-attf-class="form-group #{error.get('company_name') and 'has-error' or ''} col-md-6">
<label class="control-label" for="company_name">Company Name</label>
<label class="control-label label-optional" for="company_name">Company Name</label>
<input type="text" name="company_name" class="form-control" t-att-value="'company_name' in checkout and checkout['company_name']" />
</div>
<div t-attf-class="form-group #{error.get('vat') and 'has-error' or ''} col-md-6 div_vat">
<label class="control-label" for="vat">TIN / VAT </label>
<label class="control-label label-optional" for="vat">TIN / VAT </label>
<input type="text" name="vat" class="form-control" t-att-value="'vat' in checkout and checkout['vat']" />
</div>
</t>
Expand All @@ -1209,7 +1209,7 @@
<t t-set='zip_city' t-value='country and [x for x in country.get_address_fields() if x in ["zip", "city"]] or ["city", "zip"]'/>
<t t-if="'zip' in zip_city and zip_city.index('zip') &lt; zip_city.index('city')">
<div t-attf-class="form-group #{error.get('zip') and 'has-error' or ''} col-sm-4 div_zip">
<label class="control-label" for="zip">Zip Code</label>
<label class="control-label label-optional" for="zip">Zip Code</label>
<input type="text" name="zip" class="form-control" t-att-value="'zip' in checkout and checkout['zip']" />
</div>
</t>
Expand All @@ -1219,7 +1219,7 @@
</div>
<t t-if="'zip' in zip_city and zip_city.index('zip') &gt; zip_city.index('city')">
<div t-attf-class="form-group #{error.get('zip') and 'has-error' or ''} col-sm-4 div_zip">
<label class="control-label" for="zip">Zip Code</label>
<label class="control-label label-optional" for="zip">Zip Code</label>
<input type="text" name="zip" class="form-control" t-att-value="'zip' in checkout and checkout['zip']" />
</div>
</t>
Expand Down
3 changes: 2 additions & 1 deletion odoo/fields.py
Expand Up @@ -565,7 +565,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 @@ -978,6 +978,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 @@ -3066,10 +3066,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 @@ -5240,13 +5236,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 eec53ff

Please sign in to comment.