Update pricing role checks (#893)

* Update pricing role checks

Ref: https://github.com/inventree/InvenTree/pull/13034

* Update release notes
This commit is contained in:
Oliver authored and GitHub committed 2026-10-21 07:00:21 +11:00
1 parent 7554bbdfa2
commit a76675dd4d
5 files changed
+28 -6

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
- Supports new multi-note API for model instances
- Implement rendering for HTML note content
- Adds support for separate "pricing" permission set
## 0.25.2 - September 2026
---
+10
View File
@@ -349,6 +349,16 @@ class InvenTreeAPI {
// Ref: https://github.com/inventree/InvenTree/pull/11971
bool get supportsMultiNotes => apiVersion >= 537;
// Does the server support the "pricing" user role?
// (Pricing endpoints also moved to the /api/pricing/ namespace)
// Ref: https://github.com/inventree/InvenTree/pull/13034
bool get supportsPricingRole => apiVersion >= 561;
// Can the current user view part pricing information?
// Older servers do not have a separate "pricing" role, so no check is performed
bool get canViewPricing =>
!supportsPricingRole || checkRole("pricing", "view");
// Cached list of plugins (refreshed when we connect to the server)
List<InvenTreePlugin> _plugins = [];
+11 -1
View File
@@ -237,8 +237,18 @@ class InvenTreePart extends InvenTreeModel {
// Request pricing data for this part
Future<InvenTreePartPricing?> getPricing() async {
final api = InvenTreeAPI();
if (!api.canViewPricing) {
return null;
}
final String url = api.supportsPricingRole
? "/api/pricing/part/${pk}/"
: "/api/part/${pk}/pricing/";
try {
final response = await InvenTreeAPI().get("/api/part/${pk}/pricing/");
final response = await api.get(url);
if (response.isValid()) {
final pricingData = response.data;
+3 -4
View File
@@ -158,10 +158,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
false,
);
showPricing = await InvenTreeSettingsManager().getBool(
INV_PART_SHOW_PRICING,
true,
);
showPricing =
api.canViewPricing &&
await InvenTreeSettingsManager().getBool(INV_PART_SHOW_PRICING, true);
showBom = await InvenTreeSettingsManager().getBool(INV_PART_SHOW_BOM, true);
allowLabelPrinting = await InvenTreeSettingsManager().getBool(
INV_ENABLE_LABEL_PRINTING,
+3
View File
@@ -138,6 +138,9 @@ void main() {
assert(!api.checkRole("part", "weirdpermission"));
assert(api.checkRole("blah", "bloo"));
// Pricing role (or legacy server with no pricing role)
assert(api.canViewPricing);
debugContains("Received token from server");
debugContains("showSnackIcon: 'Connected to Server'");
});