Skip to content

fix: Frappe/ERPNext v16 compatibility (missing dependency declaration, broken hooks, broken link queries) - #26

Open
rjonesbsink wants to merge 3 commits into
Beveren-Software-Inc:developfrom
rjonesbsink:fix/frappe-v16-compat
Open

fix: Frappe/ERPNext v16 compatibility (missing dependency declaration, broken hooks, broken link queries)#26
rjonesbsink wants to merge 3 commits into
Beveren-Software-Inc:developfrom
rjonesbsink:fix/frappe-v16-compat

Conversation

@rjonesbsink

Copy link
Copy Markdown

Summary

While setting up this app on a fresh Frappe v16 / ERPNext v16 site, I ran into three separate bugs that needed fixing before it was usable. Filing them together since they were found (and fixed) in the same pass.

  • No [tool.bench.frappe-dependencies] in pyproject.toml — this is what bench actually uses to validate an app against the installed Frappe/ERPNext version (validate_app_dependencies()). The only version hint present was a commented-out, stale frappe~=15.0.0 line, so bench has no way to tell whether this app is compatible with whatever it's being installed on. Added frappe/erpnext >=16.0.0,<17.0.0, verified against Frappe 16.28.0 / ERPNext 16.29.0.

  • required_apps commented out — this app adds custom fields and doc_events to Sales Invoice, Purchase Order, Purchase Receipt, Purchase Invoice, Delivery Note, and Stock Entry, all ERPNext doctypes. Installing on a bare Frappe site (no ERPNext) fails partway through without this declared.

  • add_to_apps_screen commented out, and broken as written — it points has_permission at beveren_fsm.api.permission.has_app_permission, which doesn't exist anywhere in the app. frappe.apps.get_apps() calls frappe.get_attr() on that path, catches the resulting exception, and just logs it — so even uncommenting the block as-is silently fails to register a Desk "Apps" tile. Enabled it without has_permission (it's optional) and pointed the logo at the app's existing schedule favicon since logo.png was never added.

  • customer_address/customer_contact (service_address in Service Quotation) link-field queries in service_request.js, service_order.js, service_quotation.js filter directly on {link_doctype, link_name} against the Address/Contact doctypes. Neither doctype has those fields directly — they live on the child Dynamic Link table via the links field. Without an explicit query pointing at a handler that understands this, Frappe's default list query tries to resolve link_doctype as a literal column on Address/Contact, which doesn't exist, and surfaces as:

    You do not have permission to access field: Address.link_doctype
    You do not have permission to access field: Contact.link_doctype
    

    Fixed by routing through frappe.contacts.doctype.address.address.address_query and frappe.contacts.doctype.contact.contact.contact_query, the same functions ERPNext core uses for this exact pattern elsewhere (e.g. warranty_claim.js, opportunity.js, payment_entry.js).

Testing

All four fixes verified on a local Docker deployment: Frappe 16.28.0, ERPNext 16.29.0, MariaDB 11.8. Confirmed the Desk "Apps" tile renders and routes correctly, and that both address_query/contact_query calls return results instead of throwing, via direct frappe.call invocations matching what the form scripts trigger.

pyproject.toml had no [tool.bench.frappe-dependencies] table -- the
mechanism bench's validate_app_dependencies() actually uses to check an
app against the installed Frappe/ERPNext version. The only version hint
was a commented-out, stale "frappe~=15.0.0" line.

Declares frappe/erpnext >=16.0.0,<17.0.0. Verified working against
Frappe 16.28.0 / ERPNext 16.29.0.
- required_apps was commented out despite this app adding custom
  fields and doc_events to Sales Invoice, Purchase Order, Purchase
  Receipt, Purchase Invoice, Delivery Note, and Stock Entry -- all
  ERPNext doctypes. Installing on a bare Frappe site (no ERPNext)
  would fail partway through without this declared.

- add_to_apps_screen was commented out and pointed has_permission at
  beveren_fsm.api.permission.has_app_permission, a module/function
  that doesn't exist anywhere in this app, so even uncommenting it
  as-is would silently fail to register a Desk "Apps" tile (the
  exception is swallowed and logged by frappe.apps.get_apps()).
  Enabled without has_permission (optional; defaults to always
  visible) and pointed the logo at the app's existing schedule
  favicon instead of the never-added logo.png.
…query/contact_query

The customer_address and customer_contact (service_address in
Service Quotation) link-field queries in Service Request, Service
Order, and Service Quotation filtered directly on
{link_doctype, link_name} against the Address/Contact doctypes.
Neither doctype has those fields directly -- they live on the child
"Dynamic Link" table referenced via Address/Contact's "links" field.

Without an explicit query pointing at a handler that understands this
(as ERPNext core does everywhere it queries Address/Contact by dynamic
link), Frappe's default list query tries to resolve link_doctype as a
literal column on Address/Contact, which doesn't exist, surfacing as:

  You do not have permission to access field: Address.link_doctype
  You do not have permission to access field: Contact.link_doctype

Fixed by adding the same query methods ERPNext core uses for this
exact pattern: frappe.contacts.doctype.address.address.address_query
and frappe.contacts.doctype.contact.contact.contact_query.
@maniamartial
maniamartial self-requested a review July 24, 2026 13:13
@maniamartial

Copy link
Copy Markdown
Contributor

I will review

@rjonesbsink

Copy link
Copy Markdown
Author

Heads up on the CI failures, in case it helps triage — both look pre-existing/environmental rather than caused by this PR:

  • pre-commit: fails on README.md (trailing whitespace) and license.txt (missing EOF newline) — neither file is touched by this PR. Left them out to keep the diff scoped to the v16 fixes; happy to include a formatting fix in a separate PR if useful.
  • Server: fails before it even gets to this app — uv pip install -e apps/frappe errors with SyntaxError: invalid syntax while installing Frappe itself. CI is running Python 3.11; looks like Frappe's develop branch has moved past what 3.11 supports. develop's own CI history shows the same "Server" job failing on unrelated commits (e.g. runs from 2026-06-19 and 2026-04-13), so this predates this PR.

Let me know if you'd like anything adjusted.

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.

2 participants