summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2020-06-18 16:21:01 +0000
committerJeremy Kersten <jke@odoo.com>2020-07-14 15:52:59 +0000
commit76b2de42f47d6d3196e3b1ead6ff3fe85b357c17 (patch)
tree91638158da3cf67ec4e08360b12b1f2eb4c95263
parent92a7f8c13fa6bc84a66f973f9454971d346fd801 (diff)
[FIX] *: handle null value for boolean in sql queries
It has always been a best effort until the v13 to have false as default value for boolean field. Until v13: https://github.com/odoo/odoo/blob/12.0/odoo/models.py#L3645 During ORM refactoring in v13 it has been replaced by a default value in sql From v13: https://github.com/odoo/odoo/blob/13.0/odoo/tools/sql.py#L79 But with a typo since columntype for boolean is bool and not boolean. What's mean that in v13 we have a lot of null value for boolean (~=False) In all cases, we try to be aware and check Falsy boolean with 'null or False' (https://github.com/odoo/odoo/blob/13.0/odoo/osv/expression.py#L1230) So we should do the same when we write pure sql in method bypassing the ORM. closes odoo/odoo#53391 closes odoo/odoo#54458 Related: odoo/enterprise#11319 Related: odoo/enterprise#11838 X-original-commit: 118c9f6aafd423f415b2bbfcf8a9cfcd676d9b92 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
-rw-r--r--addons/account/models/partner.py2
-rw-r--r--addons/gamification/models/challenge.py2
-rw-r--r--addons/l10n_fr_fec/wizard/account_fr_fec.py2
-rw-r--r--addons/sale_timesheet/models/project.py5
-rw-r--r--addons/survey/models/survey_user.py2
5 files changed, 7 insertions, 6 deletions
diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py
index 86883ea36fd..0c7c5705b8e 100644
--- a/addons/account/models/partner.py
+++ b/addons/account/models/partner.py
@@ -248,7 +248,7 @@ class ResPartner(models.Model):
LEFT JOIN account_account_type act ON (a.user_type_id=act.id)
WHERE act.type IN ('receivable','payable')
AND account_move_line.partner_id IN %s
- AND account_move_line.reconciled IS FALSE
+ AND account_move_line.reconciled IS NOT TRUE
""" + where_clause + """
GROUP BY account_move_line.partner_id, act.type
""", where_params)
diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py
index 93efdef0d9b..b2f9289303e 100644
--- a/addons/gamification/models/challenge.py
+++ b/addons/gamification/models/challenge.py
@@ -251,7 +251,7 @@ class Challenge(models.Model):
AND gg.user_id = ru.id
AND ru.id = log.create_uid
AND gg.write_date < log.create_date
- AND gg.closed IS false
+ AND gg.closed IS NOT TRUE
AND gc.id IN %s
AND (gg.state = 'inprogress'
OR (gg.state = 'reached'
diff --git a/addons/l10n_fr_fec/wizard/account_fr_fec.py b/addons/l10n_fr_fec/wizard/account_fr_fec.py
index 0484c10ce1c..497a716109c 100644
--- a/addons/l10n_fr_fec/wizard/account_fr_fec.py
+++ b/addons/l10n_fr_fec/wizard/account_fr_fec.py
@@ -57,7 +57,7 @@ class AccountFrFec(models.TransientModel):
WHERE
am.date < %s
AND am.company_id = %s
- AND aat.include_initial_balance = 'f'
+ AND aat.include_initial_balance IS NOT TRUE
AND (aml.debit != 0 OR aml.credit != 0)
'''
# For official report: only use posted entries
diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py
index 87a56b3ecac..77af2fcb7be 100644
--- a/addons/sale_timesheet/models/project.py
+++ b/addons/sale_timesheet/models/project.py
@@ -50,11 +50,12 @@ class Project(models.Model):
('timesheet_product_required_if_billable_and_timesheets', """
CHECK(
(allow_billable = 't' AND allow_timesheets = 't' AND timesheet_product_id IS NOT NULL)
- OR (allow_billable = 'f')
- OR (allow_timesheets = 'f')
+ OR (allow_billable IS NOT TRUE)
+ OR (allow_timesheets IS NOT TRUE)
OR (allow_billable IS NULL)
OR (allow_timesheets IS NULL)
)""", 'The timesheet product is required when the task can be billed and timesheets are allowed.'),
+
]
@api.depends('billable_type', 'allow_billable', 'sale_order_id', 'partner_id')
diff --git a/addons/survey/models/survey_user.py b/addons/survey/models/survey_user.py
index bab1fd5165a..a9a8bc57b9f 100644
--- a/addons/survey/models/survey_user.py
+++ b/addons/survey/models/survey_user.py
@@ -126,7 +126,7 @@ class SurveyUserInput(models.Model):
LEFT OUTER JOIN survey_user_input previous_user_input
ON user_input.survey_id = previous_user_input.survey_id
AND previous_user_input.state = 'done'
- AND previous_user_input.test_entry = False
+ AND previous_user_input.test_entry IS NOT TRUE
AND previous_user_input.id < user_input.id
AND (user_input.invite_token IS NULL OR user_input.invite_token = previous_user_input.invite_token)
AND (user_input.partner_id = previous_user_input.partner_id OR user_input.email = previous_user_input.email)