Skip to content

Commit

Permalink
Merge remote-tracking branch 'odoo/13.0' into 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OCA-git-bot committed Jan 20, 2021
2 parents b195396 + 224b421 commit 3acb265
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
9 changes: 0 additions & 9 deletions addons/l10n_ch/views/res_config_settings_views.xml
Expand Up @@ -8,15 +8,6 @@
<field name="arch" type="xml">
<xpath expr="//div[@id='invoicing_settings']" position="inside">
<div class="col-12 col-lg-6 o_setting_box" id="l10n_ch-isr_print_bank">
<div class="o_setting_left_pane">
<field name="l10n_ch_print_qrcode"/>
</div>
<div class="o_setting_right_pane">
<label for="l10n_ch_print_qrcode"/>
<div class="text-muted">
Append the QR Code ISR at the end of customer invoices for Swiss customers
</div>
</div>
<div class="o_setting_left_pane">
<field name="l10n_ch_isr_print_bank_location"/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions addons/website_event_questions/models/event.py
Expand Up @@ -84,8 +84,8 @@ def create(self, vals):
event_id = vals.get('event_id', False)
if event_id:
event = self.env['event.event'].browse([event_id])
if event.event_type_id.use_questions and event.event_type_id.question_ids:
vals['answer_ids'] = vals.get('answer_ids', []) + [(0, 0, {
if event.event_type_id.use_questions and event.event_type_id.question_ids and not vals.get('answer_ids'):
vals['answer_ids'] = [(0, 0, {
'name': answer.name,
'sequence': answer.sequence,
}) for answer in event.event_type_id.question_ids.filtered(lambda question: question.title == vals.get('title')).mapped('answer_ids')]
Expand Down
12 changes: 12 additions & 0 deletions odoo/addons/base/tests/test_orm.py
Expand Up @@ -3,6 +3,8 @@

from collections import defaultdict

import psycopg2

from odoo.exceptions import AccessError, MissingError
from odoo.tests.common import TransactionCase
from odoo.tools import mute_logger
Expand Down Expand Up @@ -136,6 +138,7 @@ def test_search_read(self):
self.assertEqual(len(found), 1)
self.assertTrue(field in list(found[0]) for field in ['id', 'name', 'display_name', 'email'])

@mute_logger('odoo.sql_db')
def test_exists(self):
partner = self.env['res.partner']

Expand All @@ -144,10 +147,19 @@ def test_exists(self):
self.assertTrue(recs)
self.assertEqual(recs.exists(), recs)

# check that new records exist by convention
recs = partner.new({})
self.assertTrue(recs.exists())

# check that there is no record with id 0
recs = partner.browse([0])
self.assertFalse(recs.exists())

# check that there is no record with string id
recs = partner.browse('xxx')
with self.assertRaises(psycopg2.DataError):
recs.exists()

def test_groupby_date(self):
partners_data = dict(
A='2012-11-19',
Expand Down
2 changes: 1 addition & 1 deletion odoo/models.py
Expand Up @@ -4679,7 +4679,7 @@ def exists(self):
"""
ids, new_ids = [], []
for i in self._ids:
(ids if isinstance(i, int) else new_ids).append(i)
(new_ids if isinstance(i, NewId) else ids).append(i)
if not ids:
return self
query = """SELECT id FROM "%s" WHERE id IN %%s""" % self._table
Expand Down

0 comments on commit 3acb265

Please sign in to comment.