-
-
Notifications
You must be signed in to change notification settings - Fork 57
[18.0] Add edi_party_helper_oca, deprecate edi_party_data_oca #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simahawk
wants to merge
3
commits into
OCA:18.0
Choose a base branch
from
camptocamp:18-edi-party-ref
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,2 @@ | ||
| from . import models | ||
| from .hooks import post_load_hook |
This file contains hidden or 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 hidden or 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,13 @@ | ||
| import logging | ||
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def post_load_hook(): | ||
| _logger.info( | ||
| "`edi_exchange_template_party_data` is deprecated and will be removed. " | ||
| "`edi_party_data_oca` (and this glue module) are superseded by " | ||
| "`edi_party_helper_oca`: use its `edi.party.helper` model (or the " | ||
| "`EDIParty` class directly) instead of the `get_party_data` render " | ||
| "context shortcut." | ||
| ) | ||
This file contains hidden or 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 hidden or 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 hidden or 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,2 +1,2 @@ | ||
| from . import components | ||
| from . import models | ||
| from .hooks import post_load_hook |
This file contains hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
| import logging | ||
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def post_load_hook(): | ||
| _logger.info( | ||
|
simahawk marked this conversation as resolved.
|
||
| "`edi_party_data_oca` is deprecated and will be removed. Its " | ||
| "`edi.party.data.mixin` component is superseded by " | ||
| "`edi_party_helper_oca`: use its `edi.party.helper` model (or the " | ||
| "`EDIParty` class directly) instead, they don't require any " | ||
| "component lookup." | ||
| ) | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,84 @@ | ||
| # Copyright 2022 Camptocamp SA | ||
| # @author: Simone Orsi <simahawk@gmail.com> | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo.addons.edi_component_oca.tests.common import EDIBackendCommonComponentTestCase | ||
|
|
||
|
|
||
| class PartyDataCommonTestCase(EDIBackendCommonComponentTestCase): | ||
| @classmethod | ||
| def setUpClass(cls): | ||
| super().setUpClass() | ||
| cls.backend = cls.env.ref("edi_core_oca.demo_edi_backend") | ||
| cls.cat_model = cls.env["res.partner.id_category"] | ||
| cls.all_cat = cls.cat_model.browse() | ||
| for i in range(1, 4): | ||
| rec = cls.cat_model.create({"code": f"cat{i}", "name": f"Cat {i}"}) | ||
| cls.all_cat += rec | ||
| setattr(cls, f"category{i}", rec) | ||
|
|
||
| parent = cls.env["res.partner"].create( | ||
| { | ||
| "name": "ACME inc", | ||
| "is_company": True, | ||
| } | ||
| ) | ||
|
|
||
| for i in range(1, 4): | ||
| rec = cls.env["res.partner"].create( | ||
| { | ||
| "name": f"Test Partner {i}", | ||
| "parent_id": parent.id, | ||
| "id_numbers": [ | ||
| ( | ||
| 0, | ||
| 0, | ||
| { | ||
| "name": f"{cat.code}-p{i}", | ||
| "category_id": cat.id, | ||
| }, | ||
| ) | ||
| for cat in cls.all_cat[i - 1 :] | ||
| ], | ||
| } | ||
| ) | ||
| setattr(cls, f"partner{i}", rec) | ||
|
|
||
| # No need for special file name gen | ||
| cls.exc_type = cls._create_exchange_type( | ||
| name="ID output test", | ||
| code="id_out_test", | ||
| direction="output", | ||
| ) | ||
| cls.exc_record = cls.backend.create_record("id_out_test", {}) | ||
|
|
||
| def _expected_lang(self, partner): | ||
| if not partner.lang: | ||
| return False | ||
| lang = self.env["res.lang"]._get_data(code=partner.lang) | ||
| if not lang: | ||
| return False | ||
| return {"name": lang.name, "code": lang.code, "short": lang.code.split("_")[0]} | ||
|
|
||
| def _make_expected_data( | ||
| self, partner, number, allowed_codes=None, name_field="name", **kw | ||
| ): | ||
| data = { | ||
| "name": partner[name_field], | ||
| "identifiers": [ | ||
| {"attrs": {"schemeID": "cat1"}, "value": f"cat1-p{number}"}, | ||
| {"attrs": {"schemeID": "cat2"}, "value": f"cat2-p{number}"}, | ||
| {"attrs": {"schemeID": "cat3"}, "value": f"cat3-p{number}"}, | ||
| ], | ||
| "endpoint": {}, | ||
| "lang": self._expected_lang(partner), | ||
| "partner": partner, | ||
| } | ||
| data.update(kw) | ||
| if allowed_codes: | ||
| data["identifiers"] = [ | ||
| x | ||
| for x in data["identifiers"] | ||
| if x["attrs"]["schemeID"] in allowed_codes | ||
| ] | ||
| return data |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.