-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] global: refactor wallet data retrieval processes
Refactors wallet data retrieval processes so that the data normalization for the API is not managed by wallet and partner models anymore.
- Loading branch information
Stéphan Sainléger
committed
Feb 12, 2024
1 parent
df8bedb
commit 2c34ca5
Showing
13 changed files
with
135 additions
and
91 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
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
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
from . import comchain_services | ||
from . import auth_services | ||
from . import partner_services |
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,19 @@ | ||
import logging | ||
|
||
from odoo.addons.component.core import Component | ||
from odoo.addons.lcc_lokavaluto_app_connection.services.auth_services import AuthService | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class AuthService(Component): | ||
_inherit = "auth.service" | ||
|
||
def _update_auth_data(self, partner, password): | ||
data = super(AuthService, self)._update_auth_data(partner, password) | ||
wallets = partner.get_wallets("comchain") | ||
if len(wallets) == 0: | ||
data.extend(self.env["res.partner.backend"].comchain_backend_accounts_data) | ||
for wallet in wallets: | ||
data.extend(wallet.comchain_backend_accounts_data) | ||
return data |
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,33 @@ | ||
import logging | ||
|
||
from odoo.addons.component.core import Component | ||
from odoo.addons.lcc_lokavaluto_app_connection.services.partner_services import ( | ||
PartnerService, | ||
) | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class PartnerService(Component): | ||
_inherit = "partner.service" | ||
|
||
def _update_search_data(self, partner, backend_keys): | ||
_logger.debug("SEARCH: backend_keys = %s" % backend_keys) | ||
data = super(PartnerService, self)._update_search_data(partner, backend_keys) | ||
wallets = partner.get_wallets("comchain") | ||
for wallet in wallets: | ||
if wallet.comchain_id: | ||
for backend_key in backend_keys: | ||
if backend_key.startswith("comchain:"): | ||
data[backend_key] = [wallet.comchain_id] | ||
_logger.debug("SEARCH: data %s" % data) | ||
return data | ||
|
||
def _get_backend_credentials(self, partner): | ||
data = super(PartnerService, self)._get_backend_credentials(partner) | ||
wallets = partner.get_wallets("comchain") | ||
if len(wallets) == 0: | ||
data.extend(self.env["res.partner.backend"].comchain_backend_accounts_data) | ||
for wallet in wallets: | ||
data.extend(wallet.comchain_backend_accounts_data) | ||
return data |
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
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
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
from . import cyclos_services | ||
from . import auth_services | ||
from . import partner_services |
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,27 @@ | ||
import logging | ||
|
||
from odoo.addons.component.core import Component | ||
from odoo.addons.lcc_lokavaluto_app_connection.services.auth_services import AuthService | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class AuthService(Component): | ||
_inherit = "auth.service" | ||
|
||
def _update_auth_data(self, partner, password): | ||
data = super(AuthService, self)._update_auth_data(partner, password) | ||
# Update cyclos password with odoo one from authenticate session | ||
wallets = partner.get_wallets("cyclos") | ||
if len(wallets) == 0: | ||
data.extend(self.env["res.partner.backend"].cyclos_backend_json_data) | ||
for wallet in wallets: | ||
wallet_json_data = wallet.cyclos_backend_json_data | ||
if wallet and wallet_json_data: | ||
wallet.force_cyclos_password(password) | ||
new_token = wallet.cyclos_create_user_token(partner.id, password) | ||
if new_token: | ||
for ua in wallet_json_data[0]["accounts"]: | ||
ua["token"] = new_token | ||
data.extend(wallet_json_data) | ||
return data |
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,30 @@ | ||
import logging | ||
|
||
from odoo.addons.component.core import Component | ||
from odoo.addons.lcc_lokavaluto_app_connection.services.partner_services import ( | ||
PartnerService, | ||
) | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class PartnerService(Component): | ||
_inherit = "partner.service" | ||
|
||
def _update_search_data(self, partner, backend_keys): | ||
data = super(PartnerService, self)._update_search_data(partner, backend_keys) | ||
wallets = partner.get_wallets("cyclos") | ||
for wallet in wallets: | ||
for backend_key in backend_keys: | ||
if backend_key.startswith("cyclos:") and wallets.cyclos_id: | ||
data[backend_key] = [wallet.cyclos_id] | ||
return data | ||
|
||
def _get_backend_credentials(self, partner): | ||
data = super(PartnerService, self)._get_backend_credentials(partner) | ||
wallets = partner.get_wallets("cyclos") | ||
if len(wallets) == 0: | ||
data.extend(self.env["res.partner.backend"].cyclos_backend_json_data) | ||
for wallet in wallets: | ||
data.extend(wallet.cyclos_backend_json_data) | ||
return data |
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
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
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