From 6785be2913f96fc551cbb18c22d5bc94b5f07980 Mon Sep 17 00:00:00 2001 From: Ted Salmon Date: Wed, 11 Jan 2017 12:45:47 -0800 Subject: [PATCH] [ADD] partner_password_reset: Create module * Create module that allows you to send the password reset emails from the Partner view to any associated `res.users` --- partner_password_reset/README.rst | 58 +++++++++++++++++++ partner_password_reset/__init__.py | 5 ++ partner_password_reset/__openerp__.py | 22 +++++++ partner_password_reset/models/__init__.py | 5 ++ partner_password_reset/models/res_partner.py | 13 +++++ partner_password_reset/tests/__init__.py | 5 ++ .../tests/test_res_partner.py | 23 ++++++++ .../views/res_partner_view.xml | 20 +++++++ 8 files changed, 151 insertions(+) create mode 100755 partner_password_reset/README.rst create mode 100755 partner_password_reset/__init__.py create mode 100755 partner_password_reset/__openerp__.py create mode 100644 partner_password_reset/models/__init__.py create mode 100644 partner_password_reset/models/res_partner.py create mode 100644 partner_password_reset/tests/__init__.py create mode 100644 partner_password_reset/tests/test_res_partner.py create mode 100644 partner_password_reset/views/res_partner_view.xml diff --git a/partner_password_reset/README.rst b/partner_password_reset/README.rst new file mode 100755 index 000000000..105cdedf5 --- /dev/null +++ b/partner_password_reset/README.rst @@ -0,0 +1,58 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +===================== +Parner Password Reset +===================== + +This module provides an action that allows users to send a password reset +email from the Partner view. + +Configuration +============= + +None required + +Usage +===== + +To use this module, simply select "Send password reset email" under the partner +view. + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Ted Salmon + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/partner_password_reset/__init__.py b/partner_password_reset/__init__.py new file mode 100755 index 000000000..44db863b6 --- /dev/null +++ b/partner_password_reset/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/partner_password_reset/__openerp__.py b/partner_password_reset/__openerp__.py new file mode 100755 index 000000000..1e99450c3 --- /dev/null +++ b/partner_password_reset/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Partner User Password Reset", + "summary": "Add Action to allow resetting of a Partner's associated user " + "password from within the partner view.", + "version": "9.0.1.0.0", + "category": "Customer Relationship Management", + "website": "https://laslabs.com/", + "author": "LasLabs, " + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + 'depends': [ + 'auth_signup', + ], + 'data': [ + 'views/res_partner_view.xml', + ], +} diff --git a/partner_password_reset/models/__init__.py b/partner_password_reset/models/__init__.py new file mode 100644 index 000000000..6cc445b5a --- /dev/null +++ b/partner_password_reset/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import res_partner diff --git a/partner_password_reset/models/res_partner.py b/partner_password_reset/models/res_partner.py new file mode 100644 index 000000000..a0d378694 --- /dev/null +++ b/partner_password_reset/models/res_partner.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import api, models + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + @api.multi + def action_reset_user_password(self): + self.mapped('user_ids').action_reset_password() diff --git a/partner_password_reset/tests/__init__.py b/partner_password_reset/tests/__init__.py new file mode 100644 index 000000000..5e00c31a7 --- /dev/null +++ b/partner_password_reset/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_res_partner diff --git a/partner_password_reset/tests/test_res_partner.py b/partner_password_reset/tests/test_res_partner.py new file mode 100644 index 000000000..a2dfa23b8 --- /dev/null +++ b/partner_password_reset/tests/test_res_partner.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from mock import MagicMock +from openerp.tests.common import TransactionCase + + +class TestResPartner(TransactionCase): + + def setUp(self): + super(TestResPartner, self).setUp() + self.partner = self.env['res.partner'].search([ + ('user_ids', '!=', ''), + ], limit=1) + + def test_action_reset_user_password(self): + """ It should call user_ids.action_reset_password """ + self.env['res.users']._patch_method( + 'action_reset_password', MagicMock() + ) + self.partner.action_reset_user_password() + self.env['res.users'].action_reset_password.assert_called_once() diff --git a/partner_password_reset/views/res_partner_view.xml b/partner_password_reset/views/res_partner_view.xml new file mode 100644 index 000000000..700a70b6c --- /dev/null +++ b/partner_password_reset/views/res_partner_view.xml @@ -0,0 +1,20 @@ + + + + + Partner Reset User Password + res.partner + + + +
+
+
+
+
+ +