[change] Delivery address#12056
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR extends the company address model to support internal organization addresses and updates order address behavior so PO/RO/TO use internal addresses while SO remains customer-address based.
Changes:
- Allows
Address.companyto be nullable and adds internal-address filtering. - Updates order validation/fallback behavior and frontend address pickers for PO/RO/TO.
- Adds tests, migrations, changelog entries, and documentation for internal addresses.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/backend/InvenTree/company/models.py |
Makes address company optional for internal addresses. |
src/backend/InvenTree/company/api.py |
Adds the internal address list filter. |
src/backend/InvenTree/company/migrations/0080_alter_address_company.py |
Migrates address company FK to nullable. |
src/backend/InvenTree/order/models.py |
Adds internal/external order address validation and fallback behavior. |
src/backend/InvenTree/order/migrations/0120_alter_purchaseorder_address_and_more.py |
Updates order address field help text. |
src/backend/InvenTree/order/tests.py |
Tests internal address fallback behavior. |
src/backend/InvenTree/order/test_sales_order.py |
Extends Sales Order address validation tests. |
src/backend/InvenTree/order/test_api.py |
Adds API validation tests for order address fields. |
src/frontend/src/tables/company/AddressTable.tsx |
Supports internal address table mode. |
src/frontend/src/pages/Index/Settings/AdminCenter/Index.tsx |
Adds Admin Center address management panel. |
src/frontend/src/pages/company/CompanyDetail.tsx |
Updates the company address panel icon. |
src/frontend/src/forms/PurchaseOrderForms.tsx |
Filters purchase order address choices to internal addresses. |
src/frontend/src/forms/ReturnOrderForms.tsx |
Filters return order address choices to internal addresses. |
src/frontend/src/forms/TransferOrderForms.tsx |
Adds transfer order address field filtered to internal addresses. |
docs/docs/concepts/company.md |
Documents internal addresses and order address fallback behavior. |
CHANGELOG.md |
Records the internal address feature and breaking behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #12056 +/- ##
==========================================
+ Coverage 91.43% 91.45% +0.02%
==========================================
Files 975 977 +2
Lines 52154 52346 +192
==========================================
+ Hits 47685 47873 +188
- Misses 4469 4473 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
this will probably break a few plugins; can we move the change in the company link to 2.0? |
| def _require_staff_for_internal_address(request, address_company) -> None: | ||
| """Raise PermissionDenied if the address is internal and the user is not staff.""" | ||
| if address_company is None and not request.user.is_staff: | ||
| raise PermissionDenied(_('Only staff users can modify internal addresses')) |
There was a problem hiding this comment.
this forces ppl to use staff accounts - which are well-known sources for security issues; imo this should be a seperate permissions
|
Having looked deeper at it: this is a huge breaking change; I do not really understand why we are breaking every existing PO, RO, TO effectively - the value-add of this feature is blurry to me at best. |
|
So currently, PO / RO / TO - all specify addresses incorrectly (IMO): Purchase Order
Return Order
Transfer Order
I think that in each of these cases having an "internal" address (not linked to any Company) would make more sense, right? |
|
Sorry I have no real opinion on this, since I am not really using the addresses, but this may be a big breaking change for some other plugin developers. Just an idea, why cant we create an "Internal Company" and add adresses there? Then instead of company name in system settings we can select the internal company? |
…ee into delivery-address
|
I think this solution with an IMO a suggestion to solve the stated problems should not change the meaning of existing data fields without even warning the users. For TOs either limit it to addresses that are additionally flagged as Additionally, I think it would make sense to add a way to have one or more "internal" companies (marked with a flag or setting) - packaging/shipping slips still need company information and this would keep the python API interfaces stable |
|
Clearly we will need to think carefully about how this is implemented. I'm happy to support "internal" companies (and thus linked addresses) if we all feel that's a cleaner approach |

This PR expands the functionality of the "Address" model, allowing it to be used to represent internal addresses (not just addresses associated with external companies).
This is an alternative approach to the one suggested in #9768
Relates Issues
Breaking Change
This is a "slightly" breaking change - in that the Address model no longer is definitely linked to a Company instance. Any external code which expects an Address to always link to a Company model will need to be updated
Changes