Browse Source

[ADD] auth_supplier: New Module.

pull/291/head
sergio-incaser 9 years ago
committed by Carlos Incaser
parent
commit
0b98d8bc54
  1. 75
      auth_supplier/README.rst
  2. 7
      auth_supplier/__init__.py
  3. 23
      auth_supplier/__openerp__.py
  4. 6
      auth_supplier/controllers/__init__.py
  5. 15
      auth_supplier/controllers/main.py
  6. 37
      auth_supplier/i18n/auth_supplier.pot
  7. 40
      auth_supplier/i18n/es.po
  8. 6
      auth_supplier/models/__init__.py
  9. 24
      auth_supplier/models/res_users.py
  10. 17
      auth_supplier/security/auth_supplier_security.xml
  11. BIN
      auth_supplier/static/description/icon.png
  12. 6
      auth_supplier/tests/__init__.py
  13. 25
      auth_supplier/tests/test_auth_supplier.py
  14. 20
      auth_supplier/views/auth_supplier_view.xml

75
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 <https://github.com/OCA/server-tools/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 <https://github.com/OCA/server-tools/issues/new?body=module:%20auth_supplier%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Rafael Blasco <rafabn@antiun.com>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Carlos Dauden <carlos@incaser.es>
* Sergio Teruel <sergio@incaser.es>
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.

7
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

23
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,
}

6
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

15
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)

37
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 ""

40
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 <sergio@incaser.es>\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..."

6
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

24
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

17
auth_supplier/security/auth_supplier_security.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.module.category" id="module_auth_supplier">
<field name="name">Auth Supplier</field>
<field name="sequence">100</field>
</record>
<record id="group_auth_supplier" model="res.groups">
<field name="name">Portal Supplier</field>
<field name="category_id" ref="module_auth_supplier"/>
</record>
</data>
</openerp>

BIN
auth_supplier/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

6
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

25
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)

20
auth_supplier/views/auth_supplier_view.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="auth_supplier.fields"
inherit_id="auth_signup.fields"
name="Auth Signup/ResetPassword form fields">
<xpath expr="//div[@class='form-group field-login']" position="before">
<div class="form-group field-type">
<label for="account_type" class="control-label">Account Type</label>
<select class="form-control" name="account_type">
<option value="customer" selected="selected">Customer</option>
<option value="supplier">Supplier</option>
</select>
</div>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save