Billing Entity Management via Odoo #54
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: servala/servala-portal#54
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stories
As a user, I want to connect my organization to a billing address
As the system, I want to sync billing entity data with Odoo so that this information stays consistent.
We need to sync billing entity data in the Portal with contact information in Odoo (called "VSHN Central"), where Odoo is the source of truth.
A classic two-way sync, where Odoo takes precedence.
Implementation Notes
The Odoo API
The Odoo API is accessible either via XMLRPC or JSONRPC. We can either work directly with one of these APIs, or reuse an existing library. Example of how to work with the Odoo API: https://servala.app.codey.ch/servala/website/src/branch/main/hub/services/odoo.py. This uses https://pypi.org/project/OdooRPC/ which is a bit outdated. It's probably better to either use https://pypi.org/project/odoo-client-lib/ or plain XMLRPC (Example: https://github.com/vshn/conferenceli/blob/main/contactform/odoo_client.py).
We will need to read and write more data from and to Odoo in the future, so it makes sense to have the Odoo connection implemented in a reusable way.
Make the Odoo connection configurable via environment variables:
Billing entity specific
A billing entity in Servala Portal represents two records in the Odoo model
res.partner
:company_type
set tocompany
company_type=person
type=invoice
parent_id=company_id
This means:
fd065b51ed/apiserver/billing/odoostorage/odoo/odoo16/odoo16.go (L311-L318)
to get an idea how this is done in APPUiO.User flow:
Access control:
company_type
set tocompany
. This means we have to query Odoo for the email address in theres.partner
model ([["email","=","email@example.com"]]
) and when a contact is returned check of theparent_id
of this contact matches the company of this billing entity. (To be discussed how to effectively do that - including caching)More notes:
BillingEntities via Odooto Billing Entity Management via Odoo