-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from Comunitea/14.0_custom_pos_pms_link
[ADD] custom_pos_pms_link && purchase_portal
- Loading branch information
Showing
67 changed files
with
5,774 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
############################################################################## | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
# Copyright (C) 2023 Comunitea Servicios Tecnológicos S.L. All Rights Reserved | ||
# Vicente Ángel Gutiérrez <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
############################################################################## | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
# Copyright (C) 2023 Comunitea Servicios Tecnológicos S.L. All Rights Reserved | ||
# Vicente Ángel Gutiérrez <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
{ | ||
"name": "Custom login by token", | ||
"summary": "Allows login using signup token", | ||
"version": "14.0.1.0.0", | ||
"author": "Comunitea Servicios Tecnológicos S.L.", | ||
"website": "www.comunitea.com", | ||
"license": "AGPL-3", | ||
"category": "Custom", | ||
"depends": [ | ||
"auth_signup", | ||
], | ||
"data": [], | ||
"assets": { | ||
"web.assets_frontend": [], | ||
}, | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
############################################################################## | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
# Copyright (C) 2023 Comunitea Servicios Tecnológicos S.L. All Rights Reserved | ||
# Vicente Ángel Gutiérrez <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
from . import res_users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
############################################################################## | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
# Copyright (C) 2023 Comunitea Servicios Tecnológicos S.L. All Rights Reserved | ||
# Vicente Ángel Gutiérrez <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
import uuid | ||
from datetime import date, datetime, timedelta | ||
from odoo import SUPERUSER_ID, _, api, exceptions, models, fields | ||
|
||
|
||
class ResUsers(models.Model): | ||
|
||
_inherit = "res.users" | ||
|
||
def _check_credentials(self, password, env): | ||
try: | ||
return super(ResUsers, self)._check_credentials(password, env) | ||
|
||
except exceptions.AccessDenied: | ||
# Just be sure that parent methods aren't wrong | ||
users = self.with_user(SUPERUSER_ID).search([("id", "=", self._uid)]) | ||
if not users: | ||
raise | ||
|
||
if not self.signup_token \ | ||
or not self.signup_valid \ | ||
or self.signup_token != password: | ||
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
############################################################################## | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
# Copyright (C) 2023 Comunitea Servicios Tecnológicos S.L. All Rights Reserved | ||
# Vicente Ángel Gutiérrez <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
from . import models | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
############################################################################## | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
# Copyright (C) 2023 Comunitea Servicios Tecnológicos S.L. All Rights Reserved | ||
# Vicente Ángel Gutiérrez <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
{ | ||
"name": "Custom POS PMS Link", | ||
"summary": "Allows to access directly to the POS", | ||
"version": "14.0.1.0.0", | ||
"author": "Comunitea Servicios Tecnológicos S.L.", | ||
"website": "www.comunitea.com", | ||
"license": "AGPL-3", | ||
"category": "Custom", | ||
"depends": [ | ||
"portal", | ||
"point_of_sale", | ||
"auth_signup", | ||
"custom_login_by_token", | ||
], | ||
"data": [ | ||
"data/ir_module_category_data.xml", | ||
], | ||
"assets": { | ||
"web.assets_frontend": [], | ||
}, | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
############################################################################## | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
# Copyright (C) 2023 Comunitea Servicios Tecnológicos S.L. All Rights Reserved | ||
# Vicente Ángel Gutiérrez <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
############################################################################## | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
# Copyright (C) 2023 Comunitea Servicios Tecnológicos S.L. All Rights Reserved | ||
# Vicente Ángel Gutiérrez <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
import json | ||
import werkzeug | ||
from odoo import http, _ | ||
from odoo.http import request | ||
from werkzeug.exceptions import BadRequest, Unauthorized | ||
|
||
from odoo.addons.portal.controllers import portal | ||
from odoo.addons.web.controllers.main import Home | ||
from odoo.addons.web.controllers.main import ensure_db | ||
|
||
class BlockHome(Home): | ||
@http.route('/web', type='http', auth="none") | ||
def web_client(self, s_action=None, **kw): | ||
if request.session.uid and request.env['res.users'].sudo().browse(request.session.uid).has_group('custom_pos_pms_link.group_user_no_backend'): | ||
return http.local_redirect('/my', query=request.params, keep_hash=True) | ||
return super(BlockHome, self).web_client(s_action, **kw) | ||
|
||
class CustomerPortal(portal.CustomerPortal): | ||
@http.route(['/pos_login_by_token/<int:user_id>'], type='http', auth="public", website=True) | ||
def portal_pos_login_by_token(self, user_id=None, access_token=None, **kw): | ||
#localhost:14069/pos_login_by_token/381?signup_token=1LCzJ80sGoNu4ODEBl5C&config_id=1 | ||
ensure_db() | ||
signup_token = kw.get('signup_token', False) | ||
config_id = kw.get('config_id', False) | ||
|
||
if not user_id or not signup_token: | ||
raise Unauthorized("Wrong authentication") | ||
|
||
portal_user = request.env['res.users'].sudo().browse(user_id) | ||
|
||
if portal_user: | ||
cur_user = request.env['res.users'].browse(request.env.uid) | ||
is_public = cur_user._is_public() | ||
if (is_public or cur_user.id != portal_user.id) and signup_token == portal_user.signup_token: | ||
request.session.logout(keep_db=True) | ||
request.session.authenticate(request.db, portal_user.login, signup_token) | ||
url = "/pos/ui?config_id={}".format(config_id) | ||
return werkzeug.utils.redirect(url) | ||
|
||
class SessionController(http.Controller): | ||
@http.route( | ||
"/open_pos_session/<int:config_id>", type="json", auth="public", csrf=False, | ||
) | ||
def portal_open_pos_session(self, config_id="", access_token=None, **kw): | ||
try: | ||
config_id = request.env["pos.config"].sudo().browse(config_id) | ||
if not config_id: | ||
raise BadRequest("Configuration not found") | ||
if config_id.current_session_id: | ||
raise BadRequest("There is already an open session") | ||
cash_register_id = http.request.jsonrequest.get('cash_register_id', False) | ||
ctx = dict(request.context) | ||
ctx.update({"cash_register_id": cash_register_id}) | ||
session = config_id.with_context(ctx).get_pos_session() | ||
return json.dumps( | ||
{ | ||
"result": True, | ||
"session": session, | ||
"message": _("Session opened successfully."), | ||
} | ||
) | ||
except Exception as e: | ||
return json.dumps({"result": False, "message": str(e)}) | ||
|
||
@http.route( | ||
"/close_pos_session/<int:config_id>", type="json", auth="public", csrf=False, | ||
) | ||
def portal_close_pos_session(self, config_id="", access_token=None, **kw): | ||
try: | ||
config_id = request.env["pos.config"].sudo().browse(config_id) | ||
if not config_id: | ||
raise BadRequest("Configuration not found") | ||
if not config_id.current_session_id: | ||
raise BadRequest("There is no open session") | ||
config_id.current_session_id.action_pos_session_closing_control() | ||
return json.dumps( | ||
{ | ||
"result": True, | ||
"message": _("Session closed successfully."), | ||
} | ||
) | ||
except Exception as e: | ||
return json.dumps({"result": False, "message": str(e)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data> | ||
<record model="ir.module.category" id="module_category_no_backend"> | ||
<field name="name">Backend access</field> | ||
<field name="sequence">60</field> | ||
<field name="visible" eval="0" /> | ||
</record> | ||
|
||
<!-- add applications to base groups --> | ||
|
||
<record model="res.groups" id="group_user_no_backend"> | ||
<field name="name">No backend access</field> | ||
<field name="category_id" ref="module_category_no_backend"/> | ||
</record> | ||
|
||
</data> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
############################################################################## | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
# Copyright (C) 2023 Comunitea Servicios Tecnológicos S.L. All Rights Reserved | ||
# Vicente Ángel Gutiérrez <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
from . import pos_config | ||
from . import pos_session | ||
from . import pos_order |
Oops, something went wrong.