Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.0][MIG] auth_admin_passkey #776

Merged
merged 10 commits into from
Jul 31, 2017

Conversation

Fenkiou
Copy link

@Fenkiou Fenkiou commented Mar 13, 2017

This is a port of auth_admin_passkey from 8.0.

I changed the way the verification is done, but it works same as before.

@eugen-don
Copy link
Member

@Fenkiou thanks as well, i was trying to get this module working on V.10 and discovered your pull.

You forgot to change openerp to odoo in auth_admin_passkey/view/res_config_view.xml

@Fenkiou Fenkiou force-pushed the 10-mig-auth_admin_passkey branch from 6b6092e to 62d4a00 Compare March 15, 2017 18:21
@Fenkiou
Copy link
Author

Fenkiou commented Mar 15, 2017

@eugen-don Good spot, thanks

@Fenkiou Fenkiou force-pushed the 10-mig-auth_admin_passkey branch from 62d4a00 to 1cac349 Compare March 15, 2017 19:45
@Fenkiou Fenkiou force-pushed the 10-mig-auth_admin_passkey branch 2 times, most recently from 470f921 to 659a354 Compare March 22, 2017 23:06
<group>
<label for="id" string="Passkey"/>
<div>
<div>
<field name="auth_admin_passkey_send_to_admin" class="oe_inline"/>
<field name="" class="oe_inline"/>
Copy link
Member

@eugen-don eugen-don Mar 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace this line with: <field name="auth_admin_passkey_send_to_admin" class="oe_inline"/>

Copy link
Author

@Fenkiou Fenkiou Mar 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, I don't understand why this change is in the PR as not in my own branch..

EDIT: Nevermind, this is present in my branch but I still don't understand why I removed this..

Copy link
Member

@eugen-don eugen-don left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to call get_default_auth_admin_passkey_send_to_admin method with one more argument fields

edit: applies to the other methods as well

@Fenkiou
Copy link
Author

Fenkiou commented Mar 28, 2017

@eugen-don You're right about the missing argument, I'll fix that.

@Fenkiou Fenkiou force-pushed the 10-mig-auth_admin_passkey branch from 659a354 to 586f0d2 Compare March 28, 2017 17:43
@eugen-don
Copy link
Member

@Fenkiou I also was trying to get it to work with the adittional fields argument. But if i add fields as argument, like some other modules inheriting res.config do i get this error:

Traceback (most recent call last):
File "/opt/odoo/10/srv/odoo/http.py", line 638, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/10/srv/odoo/http.py", line 675, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/10/srv/odoo/http.py", line 331, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/10/srv/odoo/service/model.py", line 119, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/10/srv/odoo/http.py", line 324, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/10/srv/odoo/http.py", line 933, in call
return self.method(*args, **kw)
File "/opt/odoo/10/srv/odoo/http.py", line 504, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/10/srv/addons/web/controllers/main.py", line 878, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/10/srv/addons/web/controllers/main.py", line 870, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/10/srv/odoo/api.py", line 679, in call_kw
return call_kw_model(method, model, args, kwargs)
File "/opt/odoo/10/srv/odoo/api.py", line 664, in call_kw_model
result = method(recs, *args, **kwargs)
File "/opt/odoo/10/srv/odoo/addons/base/res/res_config.py", line 508, in default_get
res.update(getattr(self, method)(fields))
File "/opt/odoo/10/custom/testing/auth_admin_passkey/model/res_config.py", line 45, in get_default_auth_admin_passkey_send_to_admin
'auth_admin_passkey.send_to_admin', 'True')),
TypeError: 'module' object is not callable

Any idea?

@JonathanNEMRY
Copy link

Hello I think is should be more easier to migrate this module from 9.0 to 10.0 as api didn't change so much from there instead of 8.0 to 10.0
Moreover a work has been done by @rvalyi here #522 and should be merged soon (I hope...)

@eugen-don
Copy link
Member

Thanks for the info @JonathanNEMRY

@Fenkiou what do you think? Any way to join efforts?

@Fenkiou
Copy link
Author

Fenkiou commented Mar 29, 2017

@eugen-don, @JonathanNEMRY I saw this PR but as not merged didn't start from it.

But it's still overriding authenticate method as in 8.0 version and IMHO is not the right way to do it as odoo provide check_credentials method to use custom auth mechanism. I should have told that in PR.

@eugen-don, about your error, I couldn't reproduce it. Are you using my code or your own ? If it's your own, you should post it here :)

@eugen-don
Copy link
Member

@Fenkiou
was my own code, since your method was called with one arg short...
I gues you corrected it? If so ill test your code tomorrow

@pedrobaeza pedrobaeza mentioned this pull request Mar 30, 2017
63 tasks
@eugen-don
Copy link
Member

eugen-don commented Mar 30, 2017

@Fenkiou looks like theres still some work to do.
Its your code i used this time...

Any idea?

Traceback (most recent call last):
File "/opt/odoo/10/srv/odoo/http.py", line 638, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/10/srv/odoo/http.py", line 675, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/10/srv/odoo/http.py", line 331, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/10/srv/odoo/service/model.py", line 119, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/10/srv/odoo/http.py", line 324, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/10/srv/odoo/http.py", line 933, in call
return self.method(*args, **kw)
File "/opt/odoo/10/srv/odoo/http.py", line 504, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/10/srv/addons/web/controllers/main.py", line 878, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/10/srv/addons/web/controllers/main.py", line 870, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/10/srv/odoo/api.py", line 679, in call_kw
return call_kw_model(method, model, args, kwargs)
File "/opt/odoo/10/srv/odoo/api.py", line 664, in call_kw_model
result = method(recs, *args, **kwargs)
File "/opt/odoo/10/srv/odoo/addons/base/res/res_config.py", line 508, in default_get
res.update(getattr(self, method)(fields))
File "/opt/odoo/10/custom/testing/auth_admin_passkey/model/res_config.py", line 35, in get_default_auth_admin_passkey_send_to_admin
'auth_admin_passkey.send_to_admin', 'True')),
TypeError: 'module' object is not callable

code res_config:
`from odoo import api, fields, models
from odoo.tools import safe_eval

class BaseConfigSettings(models.TransientModel):
_inherit = 'base.config.settings'

@api.model
def get_default_auth_admin_passkey_send_to_admin(self, _):
    icp = self.env['ir.config_parameter']
    return {
        'auth_admin_passkey_send_to_admin': safe_eval(icp.get_param(
            'auth_admin_passkey.send_to_admin', 'True')),
    }

@api.model
def get_default_auth_admin_passkey_send_to_user(self, _):
    icp = self.env['ir.config_parameter']
    return {
        'auth_admin_passkey_send_to_user': safe_eval(icp.get_param(
            'auth_admin_passkey.send_to_user', 'True')),
    }

auth_admin_passkey_send_to_admin = fields.Boolean(
    'Send email to admin user.',
    help=('When the administrator use his password to login in '
          'with a different account, OpenERP will send an email '
          'to the admin user.'),
)
auth_admin_passkey_send_to_user = fields.Boolean(
    string='Send email to user.',
    help=('When the administrator use his password to login in '
          'with a different account, OpenERP will send an email '
          'to the account user.'),
)

@api.multi
def set_auth_admin_passkey_send_to_admin(self):
    self.ensure_one()

    icp = self.env['ir.config_parameter']
    icp.set_param(
        'auth_admin_passkey.send_to_admin',
        repr(self.auth_admin_passkey_send_to_admin))

@api.multi
def set_auth_admin_passkey_send_to_user(self):
    self.ensure_one()

    icp = self.env['ir.config_parameter']
    icp.set_param(
        'auth_admin_passkey.send_to_user',
        repr(self.auth_admin_passkey_send_to_user))

`

@Fenkiou
Copy link
Author

Fenkiou commented Mar 30, 2017

@eugen-don Hum.. I still cannot reproduce your issue..

When the error is raised ? When you install the module ? When you go to General Settings ? Did you try to uninstall and reinstall the module ? Is your odoo up to date ? :)

@eugen-don
Copy link
Member

eugen-don commented Mar 31, 2017

@Fenkiou
Seems like OCA runbot does not reproduce the issue?

But i just did a fresh pull from odoo repo and still get the error...

@eugen-don
Copy link
Member

@Fenkiou
I just added some commits in your repo... they dont solve the above error... only some small fixes and readme update

@Fenkiou Fenkiou force-pushed the 10-mig-auth_admin_passkey branch from 5d5b13d to ff10208 Compare April 1, 2017 11:14
@Fenkiou
Copy link
Author

Fenkiou commented Apr 1, 2017

@legalsylvain, @pedrobaeza Hi guys, sorry to ping you but we have an issue with this addon with @eugen-don and don't understand why.

We get 3 different behaviours.

  1. Mine: I can change parameters from General Settings menu
  2. @eugen-don: The above error is raised when accessing General Settings menu
  3. Runbot instance of this PR: We cannot access General Settings menu at all

Any idea ?

I'll recheck the runbot instance when build is done

@eugen-don
Copy link
Member

Hi @Fenkiou
I found the faulty module causing this error.

I made a PR #803

Copy link
Member

@eugen-don eugen-don left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on runbot.
Works on V. 10.0

@Fenkiou
Copy link
Author

Fenkiou commented Apr 1, 2017

@eugen-don So you had this module installed too ? Otherwise I don't understand why this module is causing your error without being installed.

@eugen-don
Copy link
Member

eugen-don commented Apr 1, 2017

@Fenkiou Hi, yes it was installed on my local system and on the runbot instance of this pr, i uninstalled it on runbot and see there the general settings menu was accessible. On my local system the module version was a little bit older so it was causing a severe error. Notice base_exception was migrated recently.

@Fenkiou Fenkiou force-pushed the 10-mig-auth_admin_passkey branch from ff10208 to 237bff3 Compare April 1, 2017 14:50
@eugen-don
Copy link
Member

@Fenkiou
Im actually confused myself, i just uninstalled the module and all works fine... i reinstall it and it causes errors... on runbot it didnt cause any errors only disabled the general settings menu... I see my base_exceptions was outdated. I did a fresh pull and now only the general settings menu is not clickable...

@Fenkiou
Copy link
Author

Fenkiou commented Apr 1, 2017

@eugen-don I don't understand. Could you assure me that on a new odoo database with no other module installed than auth_admin_passkey, this is working correctly ?

Otherwise please describe all your steps to help me reproduce.

@Fenkiou
Copy link
Author

Fenkiou commented May 5, 2017

Well, thanks to Travis, I learned how to use coverage on my machine.

res_users.py is 98% covered now, should increase global coverage.

Nothing to do with the PR
I'd like to know if it would possible to have Selenium installed on Travis ? As PhantomJS is installed, it could use it.

Writing UI test by writing steps in JS to call them from python test is completely absurd (IMO). I took inspiration in auth_signup_verify_email to write tests using python only but still, this is ugly and I couldn't write my tests as I wanted to.

EDIT: For the multiple database problem, a --db-filter should fix the issue.

@Fenkiou Fenkiou force-pushed the 10-mig-auth_admin_passkey branch from b2745d6 to 4431b82 Compare May 5, 2017 20:10
@Fenkiou
Copy link
Author

Fenkiou commented Jun 6, 2017

@pedrobaeza, @legalsylvain do you think a --db-filter could solve my problem with Travis ?

@Garamotte
Copy link

@Fenkiou Maybe you can start by calling the /web URL with the db argument, to define the database name in the session.
This is done here: https://github.com/OCA/server-tools/blob/9.0/oauth_provider/tests/common_test_controller.py#L66-L70

@Fenkiou
Copy link
Author

Fenkiou commented Jun 7, 2017

Thanks @sylvain-garancher, this is an interesting one !

Is it intentional to not use HttpCase ?

@Garamotte
Copy link

I don't remember exactly, but I didn't achieve to do some tests with it, so I used werkzeug's test client instead of Odoo's HttpCase.

@Fenkiou Fenkiou force-pushed the 10-mig-auth_admin_passkey branch 5 times, most recently from ba196d4 to 72254ae Compare June 25, 2017 11:55
Remove authenticate as check_credentials is dedicated for this
purpose.

Removed mail translations maybe possible in some way ?
Give some space to the code

Make the addon compliant to OCA guidelines
Adapt readme to new template and compress header in tests
Make the addon a python package

NOTE: authenticate() method cannot be used in tests because a new cr
is created in _login method that does not contains our user.

Signed-off-by: Eugen Don <[email protected]>
@Fenkiou Fenkiou force-pushed the 10-mig-auth_admin_passkey branch from 72254ae to e16b37a Compare June 25, 2017 12:24
@Fenkiou
Copy link
Author

Fenkiou commented Jun 25, 2017

It's working, finally !

You can merge when you'll have the time, thanks for the help.

@yajo yajo added this to the 10.0 milestone Jun 26, 2017
@hmrodrigues
Copy link
Member

How is this going? Will it be merged?

@legalsylvain legalsylvain merged commit 3b6b453 into OCA:10.0 Jul 31, 2017
@Fenkiou Fenkiou deleted the 10-mig-auth_admin_passkey branch July 31, 2017 10:19
SiesslPhillip pushed a commit to grueneerde/OCA-server-tools that referenced this pull request Nov 20, 2024
Syncing from upstream OCA/server-tools (11.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.