diff --git a/easy_my_coop_api/__manifest__.py b/easy_my_coop_api/__manifest__.py
index f42c066..a7f8cd9 100644
--- a/easy_my_coop_api/__manifest__.py
+++ b/easy_my_coop_api/__manifest__.py
@@ -17,8 +17,8 @@
"summary": """
Open Easy My Coop to the world: RESTful API.
""",
- "data": [],
- "demo": [],
+ "data": ["data/sequences.xml"],
+ "demo": ["demo/demo.xml"],
"installable": True,
"application": False,
}
diff --git a/easy_my_coop_api/data/sequences.xml b/easy_my_coop_api/data/sequences.xml
new file mode 100644
index 0000000..4d03a8a
--- /dev/null
+++ b/easy_my_coop_api/data/sequences.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+ Subscritpion Request External ID sequence
+ subscription.request.external.id
+ 3
+
+
+ Subscritpion Request External ID sequence
+ account.invoice.external.id
+ 3
+
+
+
diff --git a/easy_my_coop_api/demo/demo.xml b/easy_my_coop_api/demo/demo.xml
new file mode 100644
index 0000000..a88981a
--- /dev/null
+++ b/easy_my_coop_api/demo/demo.xml
@@ -0,0 +1,10 @@
+
+
+
+
+ 1
+
+
diff --git a/easy_my_coop_api/models/__init__.py b/easy_my_coop_api/models/__init__.py
index 6dfe3f7..b951867 100644
--- a/easy_my_coop_api/models/__init__.py
+++ b/easy_my_coop_api/models/__init__.py
@@ -1 +1,3 @@
from . import auth_api_key
+from . import subscription_request
+from . import account_invoice
diff --git a/easy_my_coop_api/models/account_invoice.py b/easy_my_coop_api/models/account_invoice.py
new file mode 100644
index 0000000..ae3c520
--- /dev/null
+++ b/easy_my_coop_api/models/account_invoice.py
@@ -0,0 +1,22 @@
+# Copyright 2020 Coop IT Easy SCRL fs
+# Robin Keunen
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from odoo import api, fields, models
+
+
+class AccountInvoice(models.Model):
+ _inherit = "account.invoice"
+
+ external_id = fields.Integer(
+ string="External ID", index=True, required=False
+ )
+
+ @api.multi
+ def get_external_id(self):
+ self.ensure_one()
+ if not self.external_id:
+ self.external_id = self.env["ir.sequence"].next_by_code(
+ "account.invoice.external.id"
+ )
+ return self.external_id
diff --git a/easy_my_coop_api/models/subscription_request.py b/easy_my_coop_api/models/subscription_request.py
new file mode 100644
index 0000000..717c072
--- /dev/null
+++ b/easy_my_coop_api/models/subscription_request.py
@@ -0,0 +1,24 @@
+# Copyright 2020 Coop IT Easy SCRL fs
+# Robin Keunen
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from os.path import join
+
+from odoo import api, fields, models
+
+
+class SubscriptionRequest(models.Model):
+ _inherit = "subscription.request"
+
+ external_id = fields.Integer(
+ string="External ID", index=True, required=False
+ )
+
+ @api.multi
+ def get_external_id(self):
+ self.ensure_one()
+ if not self.external_id:
+ self.external_id = self.env["ir.sequence"].next_by_code(
+ "subscription.request.external.id"
+ )
+ return self.external_id
diff --git a/easy_my_coop_api/services/subscription_request_service.py b/easy_my_coop_api/services/subscription_request_service.py
index 4013739..b120a82 100644
--- a/easy_my_coop_api/services/subscription_request_service.py
+++ b/easy_my_coop_api/services/subscription_request_service.py
@@ -28,7 +28,9 @@ class SubscriptionRequestService(Component):
"""
def get(self, _id):
- sr = self.env["subscription.request"].browse(_id)
+ sr = self.env["subscription.request"].search(
+ [("external_id", "=", _id)]
+ )
if sr:
return self._to_dict(sr)
else:
@@ -63,7 +65,9 @@ class SubscriptionRequestService(Component):
def update(self, _id, **params):
params = self._prepare_update(params)
- sr = self.env["subscription.request"].browse(_id)
+ sr = self.env["subscription.request"].search(
+ [("external_id", "=", _id)]
+ )
if not sr:
raise wrapJsonException(
NotFound(_("No subscription request for id %s") % _id)
@@ -73,8 +77,9 @@ class SubscriptionRequestService(Component):
def _to_dict(self, sr):
sr.ensure_one()
+
return {
- "id": sr.id,
+ "id": sr.get_external_id(),
"name": sr.name,
"email": sr.email,
"state": sr.state,