Commit Graph

60293 Commits

Author SHA1 Message Date
Mihir Kandoi
4bb63cca10 test: probe permlevel visibility via a value field only
get_permitted_fieldnames never lists Table fields, so allowed_companies
cannot be asserted through it; the write-reset assertions already cover
that field.
2026-07-23 12:26:59 +05:30
Mihir Kandoi
41fc23b9b2 fix: drop Customer's unused level-1 Sales User read grant
Makes visibility uniform across the three masters: only the
master-manager role can see or edit company restriction fields.
2026-07-23 12:12:49 +05:30
Mihir Kandoi
565220ebe5 fix: gate company restriction fields behind permlevel 1
Only the master-manager role of each doctype (Item Manager, Sales Master
Manager, Purchase Master Manager) can view and edit restrict_to_companies
and allowed_companies. Customer reuses its existing level-1 permission
rows; Item and Supplier get a new level-1 row.
2026-07-23 12:07:16 +05:30
Nabin Hait
7b93252621 Merge pull request #57299 from nabinhait/feat/warn-existing-draft-links
feat: warn when a draft linked document already exists
2026-07-23 10:38:45 +05:30
Nabin Hait
7e0c81391b test: use a role-less user for the permission check
test@example.com carries System Manager in the frappe fixtures, so on a
fresh CI site it can read Delivery Note and the lookup legitimately
returns the draft. test1@example.com has no roles, making the
no-permission assertion environment-independent.
2026-07-23 10:27:41 +05:30
Mihir Kandoi
5dab7b9928 Merge pull request #57361 from mihir-kandoi/batch-prefill-stock-controller
refactor: move new-doc route options to StockController
2026-07-22 18:01:56 +05:30
Mihir Kandoi
551559e804 refactor: move new-doc route options to StockController
set_route_options_for_new_doc lived in TransactionController, so doctypes
extending StockController directly (Stock Reconciliation, Stock Entry) missed
the Batch/SABB prefill or duplicated it locally. Move it to StockController
and call it from onload_post_render so all descendants inherit it.

- Batch quick entry from Stock Reconciliation items now prefills Item
- SABB route options unified: warehouse || s_warehouse || t_warehouse,
  so transaction doctypes now also prefill warehouse
- Stock Entry's duplicate handler removed; its onload_post_render now
  calls super
2026-07-22 17:58:38 +05:30
Mihir Kandoi
3d46f7eba2 Merge pull request #57357 from mihir-kandoi/posting-datetime-desc
chore: better description for posting datetime for naming series field
2026-07-22 15:40:24 +05:30
Mihir Kandoi
dcfe1706db Merge pull request #57356 from mihir-kandoi/company-restriction-link-scan-perf
perf: scan link fields once per table in company restriction check
2026-07-22 15:34:49 +05:30
Mihir Kandoi
deafe79dc9 chore: better description for posting datetime for naming series field 2026-07-22 15:28:56 +05:30
Mihir Kandoi
a22b10e5eb perf: scan link fields once per table instead of per row
Meta.get_link_fields rescans the field list on every call; hoisting it
out of the row loop cuts the reference walk on a 100-row invoice from
2.8ms to 0.1ms.
2026-07-22 15:21:51 +05:30
Nabin Hait
01f7e45058 Merge branch 'develop' into feat/warn-existing-draft-links 2026-07-22 15:18:39 +05:30
Mihir Kandoi
ae9bb27436 Merge pull request #57353 from mihir-kandoi/fix/reserved-batch-precision
fix: get reserved batch qty precision from settings
2026-07-22 15:11:11 +05:30
Mihir Kandoi
2401b04090 fix: get reserved batch qty precision from settings 2026-07-22 14:58:02 +05:30
Mihir Kandoi
e147f6be98 Merge pull request #57352 from mihir-kandoi/company-restriction-transaction-enforcement
fix: enforce company restrictions at transaction level
2026-07-22 14:52:54 +05:30
Mihir Kandoi
e3ec8d2975 refactor: exempt system doctypes via in_create flag
Doctypes marked In Create (GL Entry, Stock Ledger Entry, Bin, ledger
entries) are system-created by definition, so derive their exemption
from meta instead of listing them.
2026-07-22 14:40:27 +05:30
Mihir Kandoi
1982816a70 refactor: enforce company restrictions on any doctype with a Company link
Replace the manually maintained transaction allowlist with a wildcard
validate hook: any doctype carrying a Company link field is checked, so
new doctypes are covered automatically. System-managed doctypes (ledger
entries, reposts, bundles, bins, POS consolidation, bank feeds) are
exempted so cancel, repost and reconciliation of documents created
before a restriction changed keep working; that guarantee is pinned by
a cancel-after-restriction test.
2026-07-22 14:36:48 +05:30
Mihir Kandoi
ce01fa0e34 fix: cover manufacturing, logistics, asset and service doctypes
Extend company restriction enforcement to the remaining user-entered
transactions (BOM, Work Order, Job Card, Production Plan, Pick List,
Blanket Order, asset and maintenance documents). Ledger and repost
doctypes stay excluded so cancelling or reposting older documents
keeps working after a restriction changes.
2026-07-22 14:28:13 +05:30
Mihir Kandoi
01892c2e26 refactor: hook validate_allowed_companies instead of calling per master
Item, Customer and Supplier each imported and called it in their
validate; register it once in doc_events instead.
2026-07-22 14:17:32 +05:30
Mihir Kandoi
88b8ce3888 fix: enforce company restrictions at transaction level
Restrict to Companies only filtered list views and document reads, and
only for users with Company user permissions. Any user could still use
a master restricted to Company A in a Company B transaction, and users
without Company user permissions bypassed the feature entirely.

Validate on save of transactions that every linked Item, Customer and
Supplier allows the transaction company, and filter item link queries
by the transaction company so restricted items don't show up in the
item selector.
2026-07-22 14:13:22 +05:30
Nabin Hait
c522a1fdae fix: disable pagination in draft link lookup
frappe.get_list defaults to 20 rows; child-table joins can produce
duplicate parent names that fill the window and hide further drafts.
Also clarify the check-ordering regression test.
2026-07-22 12:06:00 +05:30
Nishka Gosalia
eafd43769b Merge pull request #57333 from nishkagosalia/fix-settings-map
fix: settings map cleanup
2026-07-22 11:09:23 +05:30
Jatin3128
1029cd988a fix(accounts receivable): made territory field multi select (#57322) 2026-07-22 10:53:17 +05:30
Diptanil Saha
8cb96496ec fix(payments): ensure payments app installed on the site in payment_app_import_guard (#57342) 2026-07-21 21:21:40 +00:00
Diptanil Saha
6d31af3a52 chore: remove apiclient (#57339) 2026-07-21 20:15:25 +00:00
nishkagosalia
721fd56013 fix: settings map cleanup 2026-07-21 19:51:05 +05:30
Mihir Kandoi
a008be7f0f Merge pull request #57316 from mihir-kandoi/fix-stock-ageing-reco-revaluation
fix: rescale stock ageing FIFO slot values on stock reconciliation
2026-07-21 15:45:51 +05:30
Mihir Kandoi
ed855c3823 fix: resolve float precision before streaming stock ledger entries
get_single_value inside _revalue_reconciled_batch_slots runs while
rows stream through the unbuffered cursor on MariaDB, killing the
active iterator. Resolve it once in generate() with the other
prefetches.
2026-07-21 14:34:08 +05:30
Mihir Kandoi
7cba539cb0 fix: use system float precision for batch qty comparison 2026-07-21 14:18:19 +05:30
Mihir Kandoi
4cd1b6a8bf fix: revalue batch reco slots only when the entry covers the full batch
stock_value_difference / qty equals the new batch rate only when the
reco entry carries the entire batch, as the split out/in reco SLEs and
batches reconciled from zero do. Partial direct-batch_no entries mix a
qty delta with existing stock, so their slots keep prior values.

Plain items need no such guard: the valuation engine collapses the
FIFO stack to qty_after * valuation_rate on every reconciliation, so
rescaling remaining slots at the reco rate matches the ledger. Lock
that with a test.
2026-07-21 14:09:28 +05:30
Mihir Kandoi
3ce31be80a fix: rescale batch FIFO slot values on stock reconciliation
Batch items take the batch-slot path, which mirrors the same value
arithmetic: the reco's incoming entry dumps the revaluation remainder
on one slot. Rescale each reconciled batch's slots at its post-reco
rate (stock_value_difference / qty of the incoming bundle entry).
2026-07-21 13:49:21 +05:30
Mihir Kandoi
7a68e8bf4d fix: rescale stock ageing FIFO slot values on stock reconciliation
A reconciliation's stock_value_difference includes the revaluation of
stock already in the FIFO queue, but the whole amount was attached to
the qty-delta slot while older slots kept pre-revaluation values. A
downward revaluation therefore produced negative bucket values in the
Stock Ageing report, and repeated recos let the queue total drift away
from Stock Balance.

Re-derive every slot value as qty * valuation_rate after processing a
reco SLE, since a reconciliation values the entire balance at its rate.
Covers both single-SLE recos and the zero-out/re-add pair that flows
through the transfer bucket.
2026-07-21 13:44:36 +05:30
Shllokkk
98d58bcd6a fix: sync process loss percentage when fg qty changes (#57063) 2026-07-21 07:32:43 +00:00
Henil Maru
83e04dd773 fix: show transaction currency symbol in Payment Request schedule dialog and reference table (#57050)
* fix: show transaction currency symbol in Payment Request schedule dialog and reference table

When company currency (INR) differs from customer currency (USD), the Amount
column in the Select Payment Schedule dialog and the Payment Reference table on
the Payment Request form incorrectly displayed the company currency symbol (₹)
instead of the transaction currency symbol ($).

- Pass `currency` from the parent document on each schedule row returned by
  `get_available_payment_schedules` so the dialog can resolve the symbol.
- Add a hidden `currency` field to the dialog table and set `options: "currency"`
  on `payment_amount` so Frappe renders the correct symbol.
- Propagate `currency` into Payment Reference rows in `set_payment_references`.
- Add a hidden `currency` Link field to the Payment Reference child DocType and
  set `options: "currency"` on its `amount` field so the table renders correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: preserve currency when serializing payment schedule rows

get_available_payment_schedules set `schedule.currency` directly on
the Payment Schedule Document row, but `currency` isn't a field on
that DocType, so the API response serializer stripped it before it
reached the client. The Select Payment Schedule dialog and the
Payment Reference table therefore always fell back to the company
currency symbol, even with the earlier options="currency" changes in
place.

Convert each row to a plain dict via as_dict() first, then set the
currency key on the dict so it survives serialization.

* refactor: source schedule currency in dialog instead of API serializer

get_available_payment_schedules had to convert each child row with
as_dict() and re-attach currency, because currency is not a field on
Payment Schedule and the response serializer drops attributes set on the
Document itself.

The schedule dialog already has the transaction currency on frm.doc, so
set it there and let the API keep returning the schedule rows unchanged.
Payment Reference still stores currency per row.

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Jatin3128 <jatinsarna8@gmail.com>
Co-authored-by: Jatin3128 <140256508+Jatin3128@users.noreply.github.com>
2026-07-21 11:58:38 +05:30
Diptanil Saha
8327f19ebf ci: fix zh two_letters_code mapping (#57307) 2026-07-21 01:06:14 +05:30
MochaMind
ab6931279d fix: sync translations from crowdin (#57259) 2026-07-21 00:41:52 +05:30
Soham Kulkarni
9d5e3be0b3 Merge pull request #57305 from frappe/revert-57292-customer
Revert "fix: mark selling as default workspace for customer"
2026-07-21 00:01:04 +05:30
Soham Kulkarni
58b839eb71 Revert "fix: mark selling as default workspace for customer" 2026-07-20 21:44:49 +05:30
Mihir Kandoi
1b36459d2b Merge pull request #57301 from mihir-kandoi/stock-summary-bin-qty-fields
feat(stock): expose all Bin qty fields in Stock Summary and Stock Projected Qty
2026-07-20 20:17:25 +05:30
Mihir Kandoi
e146c318e5 Merge pull request #57300 from mihir-kandoi/bin-recalculate-values
feat: recalculate valuation rate and stock value from Bin
2026-07-20 20:10:07 +05:30
Mihir Kandoi
59c0c15c2e feat(stock): expose all Bin qty fields in Stock Summary and Stock Projected Qty
Stock Summary's sort selector only offered 5 of Bin's 10 qty fields; add
the rest (ordered, requested, planned, reserved for production plan,
reserved stock) and extend get_data's or_filters so bins whose only
nonzero qty is one of the new fields show up when sorted by it. Sort
labels now mirror Bin field labels.

Stock Projected Qty report had a column for every Bin qty field except
reserved_stock; add it.
2026-07-20 20:05:37 +05:30
Mihir Kandoi
49a43aad81 fix: keep Standard Cost stock value in step with the standard rate
Mirrors update_qty's Standard Cost handling and drops fixed test item
names so reruns start from fresh SLE-less items.
2026-07-20 19:59:13 +05:30
Mihir Kandoi
df79e85f53 feat: recalculate valuation rate and stock value from Bin
Renames the Recalculate Bin Qty button to Recalculate Values and sets
valuation_rate and stock_value from the last SLE (0 when none exists).
2026-07-20 19:48:10 +05:30
Nabin Hait
7d351153bb feat: warn when a draft linked document already exists
When creating a follow-up document (SO->DN, PO->PR, PI->Payment Entry,
etc.), warn the user if a draft of the target doctype already linked to
the source document exists, with links to the drafts and the option to
proceed anyway.

The target doctype comes from the make_mapped_doc response via the new
frappe.model.add_mapped_doc_guard hook, so every open_mapped_doc flow is
covered without per-doctype code or method-name inference. The server
lookup walks parent-level and child-table Link / Dynamic Link fields of
the target doctype and queries through frappe.get_list, so role and user
permissions apply and docstatus filtering happens in the query itself.
Payment Entry creation bypasses open_mapped_doc, so its controller runs
the same guard explicitly.
2026-07-20 18:37:24 +05:30
Jatin3128
b917aca361 refactor: clearer labels for the overdue billing control (#57298)
refactor: clearer labels and messages, drop "threshold" wording

User-facing text only, no field or behaviour changes:

- Accounts Settings toggle label -> "Restrict Customer Over Billing".
- Bypass role label -> "Role Allowed to Bypass Over Billing Restriction".
- Customer Credit Limit field label -> "Overdue Limit".
- Rewrote the descriptions and the block message to match and to stop
  saying "threshold".
2026-07-20 18:14:44 +05:30
Mihir Kandoi
f19216979b Merge pull request #57280 from aerele/timesheet_group_by
fix(report): handle nonetype error in timesheet billing summary group…
2026-07-20 17:43:31 +05:30
Diptanil Saha
73004c6e4b refactor: rework appointment booking lifecycle and portal verification (#57270)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 16:35:58 +05:30
Soham Kulkarni
e728c24b80 Merge pull request #57292 from sokumon/customer
fix: mark selling as default workspace for customer
2026-07-20 16:06:09 +05:30
sokumon
873bce3c46 fix: mark selling as default workspace for customer 2026-07-20 15:53:41 +05:30
Poovetha
9a7209e668 fix(report): handle nonetype error in timesheet billing summary grouping logic 2026-07-20 13:39:07 +05:30