Skip to content
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

[14.0][WIP] add fleet_rest_api #74

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions fleet_rest_api/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
==============
Fleet Rest Api
==============

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ffleet-lightgray.png?logo=github
:target: https://github.com/OCA/fleet/tree/14.0/fleet_rest_api
:alt: OCA/fleet
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/fleet-14-0/fleet-14-0-fleet_rest_api
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/291/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

TODO

**Table of contents**

.. contents::
:local:

Usage
=====

TODO

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/fleet/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/fleet/issues/new?body=module:%20fleet_rest_api%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Escodoo

Contributors
~~~~~~~~~~~~

* Marcel Savegnago <[email protected]>

Other credits
~~~~~~~~~~~~~

The development of this module has been financially supported by:

* Escodoo - `https://www.escodoo.com.br <https://www.escodoo.com.br>`_

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px
:target: https://github.com/marcelsavegnago
:alt: marcelsavegnago

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-marcelsavegnago|

This module is part of the `OCA/fleet <https://github.com/OCA/fleet/tree/14.0/fleet_rest_api>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions fleet_rest_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import controllers
from . import pydantic_models
from . import services
20 changes: 20 additions & 0 deletions fleet_rest_api/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2021 - TODAY, Escodoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Fleet Rest Api",
"summary": """Add a REST API to manage events""",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Escodoo,Odoo Community Association (OCA)",
"maintainers": ["marcelsavegnago"],
"website": "https://github.com/OCA/fleet",
"depends": ["base_rest", "base_rest_pydantic", "fleet"],
"data": [],
"demo": [],
"external_dependencies": {
"python": [
"pydantic",
]
},
}
1 change: 1 addition & 0 deletions fleet_rest_api/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
32 changes: 32 additions & 0 deletions fleet_rest_api/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2021 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.base_rest.controllers import main


class BaseFleetPublicApiController(main.RestController):
_root_path = "/fleet_rest_api/"
_collection_name = "fleet.rest.services"
_default_auth = "public"


# class BaseRestDemoPrivateApiController(main.RestController):
# _root_path = "/base_rest_demo_api/private/"
# _collection_name = "base.rest.demo.private.services"
# _default_auth = "user"
#
#
# class BaseRestDemoNewApiController(main.RestController):
# _root_path = "/base_rest_demo_api/new_api/"
# _collection_name = "base.rest.demo.new_api.services"
# _default_auth = "public"


# class BaseRestDemoJwtApiController(main.RestController):
# # JWT Demo Controller, to be used with auth_jwt_demo
# # https://github.com/OCA/server-auth/tree/14.0/auth_jwt_demo
# _root_path = "/base_rest_demo_api/jwt/"
# _collection_name = "base.rest.demo.jwt.services"
# _default_auth = "jwt_demo_keycloak"
# _component_context_provider = "auth_jwt_component_context_provider"
# _default_cors = "*"
16 changes: 16 additions & 0 deletions fleet_rest_api/pydantic_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from . import fleet_service_type_info
from . import fleet_service_type_search_filter
from . import fleet_vehicle_info
from . import fleet_vehicle_search_filter
from . import fleet_vehicle_state_info
from . import fleet_vehicle_state_search_filter
from . import fleet_vehicle_tag_info
from . import fleet_vehicle_tag_search_filter
from . import fleet_vehicle_odometer_info
from . import fleet_vehicle_odometer_search_filter
from . import fleet_vehicle_log_contract_info
from . import fleet_vehicle_log_contract_search_filter
from . import fleet_vehicle_log_services_info
from . import fleet_vehicle_log_services_search_filter
from . import fleet_vehicle_assignation_log_info
from . import fleet_vehicle_assignation_log_search_filter
17 changes: 17 additions & 0 deletions fleet_rest_api/pydantic_models/fleet_service_type_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import datetime

from odoo.addons.pydantic import models, utils


class FleetServiceTypeInfo(models.BaseModel):
id: int
name: str
category: str
write_date: datetime

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter
11 changes: 11 additions & 0 deletions fleet_rest_api/pydantic_models/fleet_service_type_search_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2021 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.pydantic import models


class FleetServiceTypeSearchFilter(models.BaseModel):

id: int = None
name: str = None
category: str = None
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import date, datetime

from odoo.addons.pydantic import models, utils


class FleetVehicleAssignationLogInfo(models.BaseModel):
id: int
vehicle_id: int
driver_id: int
date_start: date
date_end: date
write_date: datetime

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2021 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo.addons.pydantic import models


class FleetVehicleAssignationLogSearchFilter(models.BaseModel):

id: int = None
vehicle_id: int = None
driver_id: int = None
75 changes: 75 additions & 0 deletions fleet_rest_api/pydantic_models/fleet_vehicle_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2021 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import date, datetime
from typing import List

import pydantic

from odoo.addons.pydantic import models, utils

from .fleet_vehicle_assignation_log_info import FleetVehicleAssignationLogInfo
from .fleet_vehicle_log_contract_info import FleetVehicleLogContractInfo
from .fleet_vehicle_log_services_info import FleetVehicleLogServicesInfo
from .fleet_vehicle_state_info import FleetVehicleStateInfo
from .fleet_vehicle_tag_info import FleetVehicleTagInfo


class FleetVehicleInfo(models.BaseModel):
id: int
name: str
description: str
active: bool
company_id: int
currency_id: int
license_plate: str
vin_sn: str
driver_id: int
future_driver_id: int
model_id: int
manager_id: int
brand_id: int
log_drivers: List[FleetVehicleAssignationLogInfo] = pydantic.Field(
[], alias="log_drivers"
)
log_services: List[FleetVehicleLogServicesInfo] = pydantic.Field(
[], alias="log_services"
)
log_contracts: List[FleetVehicleLogContractInfo] = pydantic.Field(
[], alias="log_contracts"
)
contract_count: int
service_count: int
odometer_count: int
history_count: int
next_assignation_date: date
acquisition_date: date
first_contract_date: date
color: str
state: FleetVehicleStateInfo = pydantic.Field(None, alias="state_id")
location: str
seats: int
model_year: str
tag_ids: List[FleetVehicleTagInfo] = pydantic.Field([], alias="tag_ids")
odometer: float
odometer_unit: str
transmission: str
fuel_type: str
horsepower: int
horsepower_tax: float
power: int
co2: float
contract_renewal_due_soon: bool
contract_renewal_overdue: bool
contract_renewal_name: str
contract_renewal_total: str
car_value: float
net_car_value: float
residual_value: float
plan_to_change_car: bool
vehicle_type: str
write_date: datetime

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter
40 changes: 40 additions & 0 deletions fleet_rest_api/pydantic_models/fleet_vehicle_log_contract_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2021 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import date, datetime
from typing import List

import pydantic

from odoo.addons.pydantic import models, utils

from .fleet_service_type_info import FleetServiceTypeInfo


class FleetVehicleLogContractInfo(models.BaseModel):
id: int
name: str
active: bool
vehicle_id: int
cost_subtype_id: int
amount: float
date: date
company_id: int
currency_id: int
user_id: int
start_date: date
expiration_date: date
days_left: int
insurer_id: int
purchaser_id: int
ins_ref: str
state: str
notes: str
cost_generated: float
cost_frequency: str
services_ids: List[FleetServiceTypeInfo] = pydantic.Field([], alias="service_ids")
write_date: datetime

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2021 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.pydantic import models


class FleetVehicleLogContractSearchFilter(models.BaseModel):

id: int = None
name: str = None
vehicle_id: int = None
user_id: int = None
31 changes: 31 additions & 0 deletions fleet_rest_api/pydantic_models/fleet_vehicle_log_services_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2021 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import date, datetime

from odoo.addons.pydantic import models, utils


class FleetVehicleLogServicesInfo(models.BaseModel):
id: int
active: bool
vehicle_id: int
amount: float
description: str
odometer_id: int
odometer: float
odometer_unit: str
date: date
company_id: int
currency_id: int
purchaser_id: int
inv_ref: str
vendor_id: int
notes: str
service_type_id: int
state: str
write_date: datetime

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter
Loading