forked from mozaik-association/mozaik
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PORT] Port partner_rest_api from OCA to mozaik
- Loading branch information
Showing
13 changed files
with
163 additions
and
16 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import country_info | ||
from . import country_search_filter | ||
from . import country_state_info |
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,24 @@ | ||
# Copyright 2022 ACSONE SA/NV | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from datetime import datetime | ||
|
||
import pydantic | ||
from extendable_pydantic import ExtendableModelMeta | ||
from pydantic import BaseModel | ||
|
||
from odoo.addons.pydantic import utils | ||
|
||
from .country_info import CountryInfo | ||
|
||
|
||
class CountryStateInfo(BaseModel, metaclass=ExtendableModelMeta): | ||
id: int | ||
name: str | ||
code: str | ||
country: CountryInfo = pydantic.Field(..., alias="country_id") | ||
write_date: datetime | ||
|
||
class Config: | ||
orm_mode = True | ||
getter_dict = utils.GenericOdooGetter |
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
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
12 changes: 12 additions & 0 deletions
12
mozaik_partner_rest/pydantic_models/partner_search_filter.py
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,12 @@ | ||
# Copyright 2022 ACSONE SA/NV | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from extendable_pydantic import ExtendableModelMeta | ||
from pydantic import BaseModel | ||
|
||
|
||
class PartnerSearchFilter(BaseModel, metaclass=ExtendableModelMeta): | ||
|
||
id: int = None | ||
name: str = None | ||
ref: str = None |
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,2 @@ | ||
from . import service | ||
from . import partner |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2022 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import _ | ||
from odoo.exceptions import MissingError | ||
|
||
from odoo.addons.component.core import AbstractComponent | ||
|
||
|
||
class BasePartnerService(AbstractComponent): | ||
_inherit = "base.rest.service" | ||
_name = "base.partner.rest.service" | ||
_collection = "partner.rest.services" | ||
_expose_model = None | ||
|
||
def _get(self, _id): | ||
domain = [("id", "=", _id)] | ||
record = self.env[self._expose_model].search(domain) | ||
if not record: | ||
raise MissingError( | ||
_("The record %s %s does not exist") % (self._expose_model, _id) | ||
) | ||
else: | ||
return record |
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