InvenTree icon indicating copy to clipboard operation
InvenTree copied to clipboard

feat: Add Delivery Address field to Purchase Orders

Open Reza98Sh opened this issue 6 months ago • 11 comments

This pull request implements the feature requested in #9303 by adding a dedicated delivery_address field to Purchase Orders.

Changes Implemented

Backend:

  • [x] Created a new database migration (0110_purchaseorder_delivery_address.py) to apply the schema change.
  • [x] Added a delivery_address ForeignKey field to the PurchaseOrder model, linking to company.Address.
  • [x] Exposed the delivery_address field in the PurchaseOrderSerializer to make it available via the API.
  • [x] Included delivery_address in the autocomplete_fields in PurchaseOrderAdmin for a better user experience in the admin panel.

Frontend:

  • [x] Added the delivery_address field to the usePurchaseOrderFields hook, making it visible and editable in the Purchase Order forms.

Closes #9303

Reza98Sh avatar Jun 12 '25 18:06 Reza98Sh

Deploy Preview for inventree-web-pui-preview ready!

Name Link
Latest commit eba545e67d54540b99eee5f041f0509fb0a6483f
Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/68e10bd30e3e580008bc1539
Deploy Preview https://deploy-preview-9768--inventree-web-pui-preview.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

Lighthouse
1 paths audited
Performance: 94 (🔴 down 1 from production)
Accessibility: 81 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Jun 12 '25 18:06 netlify[bot]

If this method is not considered best practice, please let me know. I am doing my best to improve it.

Reza98Sh avatar Jun 12 '25 18:06 Reza98Sh

@Reza98Sh there is a conflict in the migrations; please delete the ones you added and regenerate them

matmair avatar Jun 12 '25 19:06 matmair

An implementation question: where / how do the users define an address for "themself" which can be used here?

One approach might be to create a "company" object which is the "internal" company, which can then have one or more addresses associated with it?

Any other ideas?

SchrodingersGat avatar Jun 12 '25 23:06 SchrodingersGat

An implementation question: where / how do the users define an address for "themself" which can be used here?

One approach might be to create a "company" object which is the "internal" company, which can then have one or more addresses associated with it?

Any other ideas?

Sorry I haven't any serious experience with InvenTree but I think It's good if there is option to create address without define company

Reza98Sh avatar Jun 13 '25 10:06 Reza98Sh

@matmair thoughts on this? Does a set of "internal addresses" for "me" (which are not linked to a company object) make the most sense?

SchrodingersGat avatar Jun 13 '25 13:06 SchrodingersGat

There is no real inherent connection between Addresses and Companies but the way the current data model works there are a few functions that would need rethinking.

Mainly:

  • shipping notes
  • primary addresses

Having (1 or more) internal companies as references would be nice for a few of the open EPICs. My suggestion for now: creating a special "locked/protected" company that represents the org that owns the InvenTree instance and link the addresses there.

matmair avatar Jun 13 '25 19:06 matmair

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.34%. Comparing base (b465900) to head (3980b67).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9768   +/-   ##
=======================================
  Coverage   86.34%   86.34%           
=======================================
  Files        1234     1235    +1     
  Lines       54239    54245    +6     
  Branches     2236     2236           
=======================================
+ Hits        46830    46839    +9     
+ Misses       6841     6838    -3     
  Partials      568      568           
Flag Coverage Δ
backend 88.26% <100.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 13 '25 20:06 codecov[bot]

This PR seems stale. Please react to show this is still important.

github-actions[bot] avatar Sep 18 '25 11:09 github-actions[bot]

Still relevant

matmair avatar Sep 25 '25 19:09 matmair

@Reza98Sh I'm moving this to the 1.2.0 release target - there are still some questions to address here, I will get back to review this soon

SchrodingersGat avatar Nov 01 '25 21:11 SchrodingersGat