[IMP]pms_api_rest: added services and datamodels for get and patch checkin_partners

This commit is contained in:
braisab
2022-06-23 21:39:28 +02:00
committed by Darío Lodeiros
parent 18428a46cf
commit b30e2b6e5e
15 changed files with 502 additions and 18 deletions

View File

@@ -0,0 +1,60 @@
from odoo.addons.base_rest import restapi
from odoo.addons.base_rest_datamodel.restapi import Datamodel
from odoo.addons.component.core import Component
class ResCountryService(Component):
_inherit = "base.rest.service"
_name = "res.country.services"
_usage = "countries"
_collection = "pms.services"
@restapi.method(
[
(
[
"/",
],
"GET",
)
],
output_param=Datamodel("res.country.info", is_list=True),
auth="jwt_api_pms",
)
def get_countries(self):
result_countries = []
ResCountriesInfo = self.env.datamodels["res.country.info"]
for country in self.env["res.country"].search([]):
result_countries.append(
ResCountriesInfo(
id=country.id,
name=country.name,
)
)
return result_countries
@restapi.method(
[
(
[
"/<int:country_id>/country_states",
],
"GET",
)
],
output_param=Datamodel("res.country_state.info", is_list=True),
auth="jwt_api_pms",
)
def get_states(self, country_id):
result_country_states = []
ResCountryStatesInfo = self.env.datamodels["res.country_state.info"]
for country_states in self.env["res.country.state"].search(
[("country_id", "=", country_id)]
):
result_country_states.append(
ResCountryStatesInfo(
id=country_states.id,
name=country_states.name,
)
)
return result_country_states