Skip to content

Added POS product management conflict fix#314

Open
lubshad wants to merge 6 commits into
BrainWise-DEV:developfrom
lubshad:feat/pos-product-management
Open

Added POS product management conflict fix#314
lubshad wants to merge 6 commits into
BrainWise-DEV:developfrom
lubshad:feat/pos-product-management

Conversation

@lubshad

@lubshad lubshad commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Added POS sidebar Product Management with permission-based access, product list/edit form, image upload, UOM conversions, pricing, maintain-stock control, Desk link, and live item refresh after save.

Screen.Recording.2026-06-13.at.5.45.22.PM_compressed.mp4

@engahmed1190

Copy link
Copy Markdown
Contributor

This is very nice feature.

@MohamedAliSmk

Copy link
Copy Markdown
Collaborator

@lubshad

Blockers (Must Fix Before Merge)

1. Init guard broken in POSSale.vue

During the conflict fix, module-scoped variables were changed from let to const:

// Module-scoped init guard — prevents redundant heavy initialization
// when component remounts due to translationVersion changes.
// Tracks the profile+shift key so a user/shift change correctly re-initializes.
const _initializedKey = null
const _posInitPromise = null

The file still reassigns them elsewhere (_posInitPromise = initPOS(), _initializedKey = ...). This throws "Assignment to constant variable" and breaks POS initialization.

Fix: Revert to:

let _initializedKey = null
let _posInitPromise = null

2. save_product() uses ignore_permissions=True

item.save(ignore_permissions=True)
# ...
price_doc.save(ignore_permissions=True)

Permission is checked once at the start, then bypassed on save. A user with partial Item permissions could still write Item Price without an explicit Item Price permission check.

Fix:

  • Remove ignore_permissions=True and rely on normal permission checks, or
  • Add explicit Item Price create/write permission checks before price updates
  • Do not bypass permissions after a partial check

3. get_products() ignores POS Profile item group scope

get_items() in items.py respects _get_pos_profile_allowed_item_groups(). get_products() returns all is_sales_item = 1 items (limit 100), not just items allowed for the active POS Profile.

Risk: Cashiers may see and edit items outside their profile scope.

Fix: Reuse _get_pos_profile_allowed_item_groups() (or a shared helper) when building filters.


Important Issues

Issue Details
Branch is stale Missing recent develop work. Expect merge conflicts on rebase.
Huge unrelated diff ~89 non-translation files changed — mostly formatting, plus printInvoice.js, offline.worker.js, posCart.js, etc. Should be split or rebased onto clean develop.
Translation churn ar.csv, id.csv, pt-br.csv fully reformatted (~9k line changes). Hard to review; likely merge noise. Prefer adding only new strings.
Item code = item name item.item_code = data.get("item_name") — duplicates and special characters will fail; no naming series.
No pagination Hard limit=100; no "load more" in UI.
Search fires on every keystroke watch([searchQuery, filterGroup], () => loadProducts()) with no debounce.
Search scope Backend only searches item_name, not item_code / name.
Missing frontend validation UI marks item group and UOM required but only validates product name and price.
Disabled items shown get_products does not filter disabled = 0.
Image upload No file size/type validation; errors only logged to console.
Direct REST for UOMs fetch('/api/resource/UOM?...') bypasses call() wrapper and consistent error handling.

@lubshad

lubshad commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

@MohamedAliSmk

Fixed all reported issues. Please check.

@MohamedAliSmk

Copy link
Copy Markdown
Collaborator

Remaining Blocker

itemStore.refreshItem() is not defined

ProductManagement.vue calls after save:

itemStore.invalidateCache()
await itemStore.refreshItem(itemCode, props.posProfile)

refreshItem does not exist in itemSearch.js on develop or on this branch. It was removed when unrelated itemSearch.js changes were reverted in d4044594.

Impact: Product save succeeds on the server, but the UI shows "Failed to save product" because refreshItem throws. POS item grid may not update until a manual refresh.

Fix options (pick one):

  1. Add a minimal refreshItem(itemCode, profile) export to itemSearch.js (recommended), or
  2. Remove the refreshItem call and rely on invalidateCache() + a documented full reload, or
  3. Call pos_next.api.items.get_items directly from ProductManagement.vue and upsert into the store

Minor Follow-ups (non-blocking)

  1. Translations — New UI strings (Product Management, Stock Lookup, etc.) are not in pos_next/translations/*.csv in the final diff. English works; ar/id/pt-br will fall back until strings are added cleanly (without full-file reformat).

  2. Naming series — Confirm POS-ITEM-.##### works on target sites (Frappe make_autoname usually auto-creates series counters; verify on a fresh site).

  3. Re-enabling disabled items — Disabled items are excluded from the list (disabled: 0 filter), so a product disabled via POS cannot be re-enabled from the same screen without Desk access.

  4. components.d.ts — May need regeneration after merge (pnpm/vite build).


@lubshad

lubshad commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Updated the blockers and suggestions .. please check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants