diff --git a/auth_supplier/README.rst b/auth_supplier/README.rst new file mode 100644 index 000000000..35d8846d7 --- /dev/null +++ b/auth_supplier/README.rst @@ -0,0 +1,75 @@ +.. 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 + +============= +Auth Supplier +============= + +This module was written to extends the functionality of auth signup +and allows the user to create an account as a supplier. + +Configuration +============= + +* To enable users to create accounts: + +* Go to *Settings > Configuration > General settings*. +* Enable *Allow external users to sign up*. +* Enable *Activate the customer portal*. + +Usage +===== + +To use this module, you need to: + +* Log out. +* In home page, press *Sign in*. +* Press *Sign up*. +* Select *Supplier* in account type. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/149/8.0 + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + + +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 smashing it by providing a detailed and welcomed feedback +`here `_. + +Credits +======= + +Contributors +------------ + +* Rafael Blasco +* Pedro M. Baeza +* Carlos Dauden +* Sergio Teruel + +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 http://odoo-community.org. diff --git a/auth_supplier/__init__.py b/auth_supplier/__init__.py new file mode 100644 index 000000000..670c70c9c --- /dev/null +++ b/auth_supplier/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel +# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import models +from . import controllers diff --git a/auth_supplier/__openerp__.py b/auth_supplier/__openerp__.py new file mode 100644 index 000000000..9b7fd4bf1 --- /dev/null +++ b/auth_supplier/__openerp__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel +# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + 'name': "Auth Supplier", + 'category': 'Tools', + 'version': '8.0.1.0.0', + 'depends': [ + 'auth_signup', + ], + 'data': [ + 'security/auth_supplier_security.xml', + 'views/auth_supplier_view.xml', + ], + 'author': 'Incaser Informatica S.L., ' + 'Antiun Ingeniería S.L., ' + 'Odoo Community Association (OCA)', + 'website': 'http://www.incaser.es', + 'license': 'AGPL-3', + 'installable': True, +} diff --git a/auth_supplier/controllers/__init__.py b/auth_supplier/controllers/__init__.py new file mode 100644 index 000000000..49f5bc60d --- /dev/null +++ b/auth_supplier/controllers/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel +# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import main diff --git a/auth_supplier/controllers/main.py b/auth_supplier/controllers/main.py new file mode 100644 index 000000000..e1080fe26 --- /dev/null +++ b/auth_supplier/controllers/main.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel +# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp.addons.auth_signup.controllers.main import AuthSignupHome +from openerp.http import request + + +class AuthSignupHome(AuthSignupHome): + + def _signup_with_values(self, token, values): + qcontext = request.params.copy() + values.update(account_type=qcontext.get('account_type', False)) + return super(AuthSignupHome, self)._signup_with_values(token, values) diff --git a/auth_supplier/i18n/auth_supplier.pot b/auth_supplier/i18n/auth_supplier.pot new file mode 100644 index 000000000..de59ee022 --- /dev/null +++ b/auth_supplier/i18n/auth_supplier.pot @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_auth_supplier +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-10-20 08:34+0000\n" +"PO-Revision-Date: 2015-10-20 08:34+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: website_auth_supplier +#: view:website:auth_signup.fields +msgid "Account Type" +msgstr "" + +#. module: website_auth_supplier +#: view:website:auth_signup.fields +msgid "Customer" +msgstr "" + +#. module: website_auth_supplier +#: view:website:auth_signup.fields +msgid "Supplier" +msgstr "" + +#. module: website_auth_supplier +#: model:ir.model,name:website_auth_supplier.model_res_users +msgid "Users" +msgstr "" + diff --git a/auth_supplier/i18n/es.po b/auth_supplier/i18n/es.po new file mode 100644 index 000000000..eb07652a6 --- /dev/null +++ b/auth_supplier/i18n/es.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_auth_supplier +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-10-20 08:34+0000\n" +"PO-Revision-Date: 2015-10-20 10:36+0100\n" +"Last-Translator: Sergio Teruel \n" +"Language-Team: \n" +"Language: es-ES\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.5.4\n" + +#. module: website_auth_supplier +#: view:website:auth_signup.fields +msgid "Account Type" +msgstr "Tipo de cuenta" + +#. module: website_auth_supplier +#: view:website:auth_signup.fields +msgid "Customer" +msgstr "Cliente" + +#. module: website_auth_supplier +#: view:website:auth_signup.fields +msgid "Supplier" +msgstr "Proveedor" + +#. module: website_auth_supplier +#: model:ir.model,name:website_auth_supplier.model_res_users +msgid "Users" +msgstr "Usuarios" + +#~ msgid "Select Type..." +#~ msgstr "Seleccione el tipo..." diff --git a/auth_supplier/models/__init__.py b/auth_supplier/models/__init__.py new file mode 100644 index 000000000..592a4c752 --- /dev/null +++ b/auth_supplier/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel +# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import res_users diff --git a/auth_supplier/models/res_users.py b/auth_supplier/models/res_users.py new file mode 100644 index 000000000..9a1fe3404 --- /dev/null +++ b/auth_supplier/models/res_users.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel +# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import models, api + + +class ResUsers(models.Model): + _inherit = "res.users" + + @api.model + def _signup_create_user(self, values): + account_type = values.get('account_type', False) + if 'account_type' in values: + values.pop('account_type') + res = super(ResUsers, self)._signup_create_user(values) + if isinstance(res, int): + user = self.env['res.users'].browse(res) + if account_type == 'supplier': + user.partner_id.supplier = True + user.groups_id = user.groups_id | self.env.ref( + 'auth_supplier.group_auth_supplier') + return res diff --git a/auth_supplier/security/auth_supplier_security.xml b/auth_supplier/security/auth_supplier_security.xml new file mode 100644 index 000000000..5aa7de8fe --- /dev/null +++ b/auth_supplier/security/auth_supplier_security.xml @@ -0,0 +1,17 @@ + + + + + + Auth Supplier + 100 + + + + Portal Supplier + + + + + + diff --git a/auth_supplier/static/description/icon.png b/auth_supplier/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/auth_supplier/static/description/icon.png differ diff --git a/auth_supplier/tests/__init__.py b/auth_supplier/tests/__init__.py new file mode 100644 index 000000000..79276a68f --- /dev/null +++ b/auth_supplier/tests/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel +# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import test_auth_supplier diff --git a/auth_supplier/tests/test_auth_supplier.py b/auth_supplier/tests/test_auth_supplier.py new file mode 100644 index 000000000..f9e2fd71a --- /dev/null +++ b/auth_supplier/tests/test_auth_supplier.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel +# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp.tests.common import TransactionCase + + +class TestSAuthSupplier(TransactionCase): + + def setUp(self): + super(TestSAuthSupplier, self).setUp() + ir_config_parameter = self.env['ir.config_parameter'] + ir_config_parameter.set_param('auth_signup.allow_uninvited', 'True') + + def test_user_signup(self): + values = { + 'login': 'test@test.com', + 'name': 'test', + 'password': '1234', + 'account_type': 'supplier' + } + user_obj = self.env['res.users'] + user = user_obj.browse(user_obj._signup_create_user(values)) + self.assertTrue(user.partner_id.supplier) diff --git a/auth_supplier/views/auth_supplier_view.xml b/auth_supplier/views/auth_supplier_view.xml new file mode 100644 index 000000000..424b16258 --- /dev/null +++ b/auth_supplier/views/auth_supplier_view.xml @@ -0,0 +1,20 @@ + + + + + + + +