@ -1,6 +1,6 @@
# Copyright 2016 Yannick Vaucher (Camptocamp SA)
# Copyright 2016 Yannick Vaucher (Camptocamp SA)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) .
# Copyright 2020 Therp BV - https://therp.nl .
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests.common import Form , TransactionCase
from odoo.tests.common import Form , TransactionCase
@ -9,9 +9,7 @@ class UserOnchangeCase(TransactionCase):
""" In a new users form, a user set only the firstname. """
""" In a new users form, a user set only the firstname. """
login = " Zoë "
login = " Zoë "
firstname = " Zoë "
firstname = " Zoë "
with Form (
self . env [ " res.users " ] , view = " partner_firstname.view_users_form "
) as user_form :
with self . get_clean_user_form ( ) as user_form :
user_form . login = login
user_form . login = login
# Changes firstname, which triggers onchanges
# Changes firstname, which triggers onchanges
user_form . firstname = firstname
user_form . firstname = firstname
@ -24,9 +22,7 @@ class UserOnchangeCase(TransactionCase):
""" In a new user form, a user set only the lastname. """
""" In a new user form, a user set only the lastname. """
login = " Żywioł "
login = " Żywioł "
lastname = " Żywioł "
lastname = " Żywioł "
with Form (
self . env [ " res.users " ] , view = " partner_firstname.view_users_form "
) as user_form :
with self . get_clean_user_form ( ) as user_form :
user_form . login = login
user_form . login = login
# Changes lastname, which triggers onchanges
# Changes lastname, which triggers onchanges
user_form . lastname = lastname
user_form . lastname = lastname
@ -40,16 +36,29 @@ class UserOnchangeCase(TransactionCase):
login = " Zoë.Żywioł "
login = " Zoë.Żywioł "
firstname = " Zoë "
firstname = " Zoë "
lastname = " Żywioł "
lastname = " Żywioł "
with Form (
self . env [ " res.users " ] , view = " partner_firstname.view_users_form "
) as user_form :
with self . get_clean_user_form ( ) as user_form :
user_form . login = login
user_form . login = login
# Changes firstname, which triggers onchanges
# Changes firstname, which triggers onchanges
user_form . firstname = firstname
user_form . firstname = firstname
# Changes lastname, which triggers onchanges
# Changes lastname, which triggers onchanges
user_form . lastname = lastname
user_form . lastname = lastname
self . assertEqual ( user_form . lastname , lastname )
self . assertEqual ( user_form . lastname , lastname )
self . assertEqual ( user_form . firstname , firstname )
self . assertEqual ( user_form . firstname , firstname )
self . assertEqual ( user_form . name , " " . join ( ( firstname , lastname ) ) )
self . assertEqual ( user_form . name , " " . join ( ( firstname , lastname ) ) )
def get_clean_user_form ( self ) :
""" Get form without pseudo_fields.
This will be needed until Odoo Form does weed out these fields by itself .
"""
form = Form ( self . env [ " res.users " ] , view = " partner_firstname.view_users_form " )
pseudo_fields = [
fieldname
for fieldname in form . _view [ " fields " ] . keys ( )
if fieldname [ : 11 ] == " sel_groups_ " or fieldname [ : 9 ] == " in_group_ "
]
for fieldname in pseudo_fields :
del form . _view [ " fields " ] [ fieldname ]
del form . _values [ fieldname ]
return form