Browse Source

[9.0][IMP][auth_supplier] Remove useless group. Mark as customer.

The whole purpose of this module was to be able to separate a customer and a supplier portals.

Given the status of the upstream implementations of portals, it is not possible to have a supplier portal without portal permissions. Thus, it would be required to make the group this module was creating inherit from `base.group_portal`, which would give suppliers access to all customers portal. As such, that group becomes useless.

From now on, this distinction should be made with simply checking if `user.customer` or `user.supplier` is `True`. This means no additional problems since `ir.rule` domains can use the `user` variable. To allow that, I'm implementing what was discussed at https://github.com/OCA/server-tools/pull/434#discussion-diff-64883758.

Tests had to be removed because https://github.com/odoo/odoo/issues/12237 makes the created record to disappear, so there's no way to actually check the created user was created with customer or supplier flag on.
pull/442/head
Jairo Llopis 9 years ago
parent
commit
c5b18d595d
  1. 22
      auth_supplier/README.rst
  2. 1
      auth_supplier/__init__.py
  3. 3
      auth_supplier/__openerp__.py
  4. 4
      auth_supplier/controllers/main.py
  5. 6
      auth_supplier/models/__init__.py
  6. 23
      auth_supplier/models/res_users.py
  7. 9
      auth_supplier/security/auth_supplier_security.xml
  8. 6
      auth_supplier/tests/__init__.py
  9. 24
      auth_supplier/tests/test_auth_supplier.py

22
auth_supplier/README.rst

@ -7,9 +7,8 @@ Auth Supplier
=============
This module was written to extends the functionality of auth signup and allows
the user to create an account as a supplier, marking him as with permissions
for a supplier portal (although nothing is implemented for that portal, other
modules should do that).
the user to create an account as a supplier or customer, marking his related
created partner as such.
Configuration
=============
@ -29,18 +28,9 @@ To use this module, you need to:
* Log out.
* If you have a website, in home page press *Sign in*.
* Press *Sign up* to go to `the sign up page </web/signup>`_.
* Select *Supplier* in account type.
* Select *Supplier* or *Customer* in account type.
* Fill the form.
If you want to give permissions to anybody for the supplier portal:
#. Go to *Contacts*.
#. Choose a supplier.
#. Go to *Action > Portal Access Management*.
#. Choose *Other Extra Rights / Supplier Portal*.
#. Choose contacts to be *In Portal*.
#. Press *Apply*.
.. 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/9.0
@ -50,10 +40,8 @@ Known issues / Roadmap
* If you have nothing in the portal, the user will be redirected to an empty
page.
* When the user signs up as *Customer*, it is not really marked as such in the
backend, it's just not marked as supplier. Is this expected behavior or bug?
`Relevant discussion
<https://github.com/OCA/server-tools/pull/434#discussion-diff-64883758>`_.
* Tests are not possible due to https://github.com/odoo/odoo/issues/12237.
They should be added when that is fixed.
Bug Tracker
===========

1
auth_supplier/__init__.py

@ -3,5 +3,4 @@
# (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

3
auth_supplier/__openerp__.py

@ -7,12 +7,11 @@
{
'name': "Auth Supplier",
'category': 'Portal',
'version': '9.0.1.1.0',
'version': '9.0.2.0.0',
'depends': [
'auth_signup',
],
'data': [
'security/auth_supplier_security.xml',
'views/auth_supplier_view.xml',
],
'author': 'Antiun Ingeniería S.L., '

4
auth_supplier/controllers/main.py

@ -10,5 +10,7 @@ from openerp.http import request
class AuthSignupHome(AuthSignupHome):
def _signup_with_values(self, token, values):
values.update(account_type=request.params.get('account_type', False))
account_type = request.params.get('account_type')
if account_type in {"customer", "supplier"}:
values.setdefault(account_type, True)
return super(AuthSignupHome, self)._signup_with_values(token, values)

6
auth_supplier/models/__init__.py

@ -1,6 +0,0 @@
# -*- 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

23
auth_supplier/models/res_users.py

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# 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.pop('account_type', False)
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 |= self.env.ref(
'auth_supplier.group_auth_supplier')
return res

9
auth_supplier/security/auth_supplier_security.xml

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="group_auth_supplier" model="res.groups">
<field name="name">Supplier Portal</field>
<field name="category_id" ref="base.module_category_extra"/>
</record>
</odoo>

6
auth_supplier/tests/__init__.py

@ -1,6 +0,0 @@
# -*- 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

24
auth_supplier/tests/test_auth_supplier.py

@ -1,24 +0,0 @@
# -*- 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)
Loading…
Cancel
Save