Billing Entity Management #66

Merged
rixx merged 32 commits from 54-billing-entity-management into main 2025-06-22 15:42:14 +00:00
Member

PR for #54

  • Odoo settings
  • Odoo API calls
  • Find contacts and companies in Odoo for user accounts
  • Show select-or-create form
    • Make sure we request the fields Odoo needs
  • Create org with existing billing account
    • Make sure all relevant accounts show up, including accounts the user has access to within Servala (?)
  • Create org with new billing account
  • Show billing address information (read-only) in org detail page
  • Map users to Odoo contacts (TODO: test after org creation works)
PR for #54 - [x] Odoo settings - [x] Odoo API calls - [x] Find contacts and companies in Odoo for user accounts - [x] Show select-or-create form - [x] Make sure we request the fields Odoo needs - [x] Create org with existing billing account - [ ] Make sure all relevant accounts show up, including accounts the user has access to within Servala (?) - [x] Create org with new billing account - [x] Show billing address information (read-only) in org detail page - [x] Map users to Odoo contacts (TODO: test after org creation works)
rixx force-pushed 54-billing-entity-management from cdd8838b3d to 4b3ddec4bb 2025-06-03 09:35:10 +00:00 Compare
rixx force-pushed 54-billing-entity-management from 3e6c598c96 to c7d079e9bf 2025-06-04 09:45:47 +00:00 Compare
rixx changed title from WIP: Billing Entity Management to Billing Entity Management 2025-06-04 09:46:40 +00:00
rixx added 1 commit 2025-06-05 07:25:12 +00:00
rixx force-pushed 54-billing-entity-management from b36c0233db to dae5e7153b 2025-06-05 07:29:51 +00:00 Compare
tobru reviewed 2025-06-05 08:52:57 +00:00
@ -0,0 +130,4 @@
email = user if isinstance(user, str) else user.email
odoo_users = CLIENT.search_read(
model="res.users",
domain=[("login", "=", email)],
Owner

Enhance the domain to include ('active','=',True) to make sure the user is active in Odoo.

Enhance the domain to include `('active','=',True)` to make sure the user is active in Odoo.
tobru marked this conversation as resolved
tobru reviewed 2025-06-05 08:56:57 +00:00
@ -0,0 +135,4 @@
limit=1,
)
if odoo_users and (uid := odoo_users[0].get("id")):
or_conditions.append(("create_uid", "=", uid))
Owner

A user in the Servala Portal which matches an internal user in Odoo should be able to see all invoice addresses, like they do when they log in to the Odoo backend. I figured out that the "Internal Users" filter in Odoo uses the domain ('share', '=', False) (L342) so let's use the same to decide if the user can see all invoice addresses. There are also "Portal Users" in Odoo, they should not see all invoice addresses and behave like a normal Servala Portal user.

A user in the Servala Portal which matches an internal user in Odoo should be able to see all invoice addresses, like they do when they log in to the Odoo backend. I figured out that the "Internal Users" filter in Odoo uses the domain `('share', '=', False)` ([L342](https://github.com/odoo/odoo/blob/16.0/odoo/addons/base/views/res_users_views.xml#L342)) so let's use the same to decide if the user can see all invoice addresses. There are also "Portal Users" in Odoo, they should not see all invoice addresses and behave like a normal Servala Portal user.
tobru marked this conversation as resolved
tobru reviewed 2025-06-05 09:08:34 +00:00
@ -11,0 +61,4 @@
if self.odoo_addresses:
address_choices = [("", _("---------"))]
for addr in self.odoo_addresses:
display_parts = [
Owner

We should also display the parent_id.name field to make these addresses more discoverable to which company they belong to. And order alphabetically, if not already the case.

We should also display the `parent_id.name` field to make these addresses more discoverable to which company they belong to. And order alphabetically, if not already the case.
tobru marked this conversation as resolved
rixx force-pushed 54-billing-entity-management from 9008833306 to adda59fe7f 2025-06-16 07:59:38 +00:00 Compare
tobru reviewed 2025-06-16 09:43:38 +00:00
tobru reviewed 2025-06-16 09:44:49 +00:00
@ -220,0 +223,4 @@
annotations = {
"servala.com/organization": organization.name,
"servala.com/billing": organization.origin.name,
"servala.com/origin": organization.billing_entity.name,
Owner

Billing and origin are interchanged

Billing and origin are interchanged
rixx marked this conversation as resolved
tobru reviewed 2025-06-16 09:46:09 +00:00
@ -220,0 +231,4 @@
labels[f"servala.com/erp_{field}"] = str(value)
if organization.odoo_sale_order_id:
annotations["servala.com/sales_order"] = str(
Owner

Let's make this a label as well and name the label servala.com/erp_sale_order_id

Let's make this a label as well and name the label `servala.com/erp_sale_order_id`
rixx marked this conversation as resolved
tobru reviewed 2025-06-16 09:51:14 +00:00
@ -78,0 +94,4 @@
"partner_invoice_id": instance.billing_entity.odoo_invoice_id,
"state": "sale",
"client_order_ref": f"Servala (Organization: {instance.name})",
"note": "auto-generated by Servala Portal",
Owner

The field in Odoo is called internal_note

The field in Odoo is called `internal_note`
rixx marked this conversation as resolved
Owner

The file src/saleorder_storage.go is probably not needed

The file `src/saleorder_storage.go` is probably not needed
rixx added 1 commit 2025-06-22 15:41:59 +00:00
Apply code review fixes
All checks were successful
Tests / test (push) Successful in 37s
6a1f554854
rixx merged commit 266b7fa508 into main 2025-06-22 15:42:14 +00:00
rixx deleted branch 54-billing-entity-management 2025-06-22 15:42:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: servala/servala-portal#66
No description provided.