Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto create PR on SCR submission #38290

Merged
merged 24 commits into from
Nov 29, 2023
Merged

Conversation

s-aga-r
Copy link
Contributor

@s-aga-r s-aga-r commented Nov 23, 2023

Changes:

  • Auto create Subcontracting Order:

    scrnli_11_28_2023_1-58-29.PM.mp4
  • Auto create Purchase Receipt:

    scrnli_11_28_2023_2-00-05.PM.mp4
  • Provision to create Purchase Receipt from Subcontracting Receipt:

    image

  • Purchase Orders link in Subcontracting Receipt connections:

    image

  • Subcontracting Receipts link in Purchase Order connections:

    image

  • Hide the View button in the cancelled Subcontracting Receipt:

    image

Note: Creating a Purchase Receipt on submission of Subcontracting Receipt will not work for existing Subcontracting Documents, Purchase Receipt needs Purchase Order and Purchase Order Item references which get copied from Purchase Order -> Subcontracting Order -> Subcontracting Receipt -> Purchase Receipt. If the Subcontracting Order does not have the Purchase Order references, the same will not be copied to corresponding receipts.

no-docs

closes: #36704

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Nov 23, 2023
Copy link

codecov bot commented Nov 23, 2023

Codecov Report

Merging #38290 (5005730) into develop (8c3713b) will decrease coverage by 0.05%.
Report is 20 commits behind head on develop.
The diff coverage is 30.76%.

❗ Current head 5005730 differs from pull request most recent head 3da0aa6. Consider uploading reports for the commit 3da0aa6 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #38290      +/-   ##
===========================================
- Coverage    67.23%   67.18%   -0.05%     
===========================================
  Files          758      758              
  Lines        60619    60671      +52     
===========================================
+ Hits         40756    40764       +8     
- Misses       19863    19907      +44     
Files Coverage Δ
...ctype/subcontracting_order/subcontracting_order.py 89.92% <100.00%> (-0.08%) ⬇️
...e_comparison/stock_and_account_value_comparison.py 62.29% <0.00%> (ø)
...xt/buying/doctype/purchase_order/purchase_order.py 76.88% <33.33%> (-2.11%) ⬇️
...e/subcontracting_receipt/subcontracting_receipt.py 79.42% <17.94%> (-10.12%) ⬇️

... and 1 file with indirect coverage changes

@s-aga-r s-aga-r changed the title feat: auto create docs for subcontracting feat: auto create PR on SCR submission Nov 24, 2023
@s-aga-r
Copy link
Contributor Author

s-aga-r commented Nov 24, 2023

Todo:

  • Handle case for Subcontracting Receipt (Return)
    • There can be more than one PR against an SCR, not possible to find one and create a return PR based on it. What can be done is map a return PR against a recent PR (having SCR ref) and let the user update the items/qty manually (?) OR a standalone return PR (without Return Against set) with SCR ref (?)
  • SCR link on PR (?) Helps in two ways:
    • PR gets auto-cancelled when SCR gets cancelled.
    • To identify the Return Against for PR (Return).
  • Option to create Purchase Receipt from Subcontracting Receipt > Create.
  • Tests:
    • PO (submit) -> SCO (Draft).
    • SCR (submit) -> PR (Draft).

@s-aga-r s-aga-r removed the needs-tests This PR needs automated unit-tests. label Nov 29, 2023
@s-aga-r s-aga-r marked this pull request as ready for review November 29, 2023 12:26
@s-aga-r s-aga-r merged commit 2e8739f into frappe:develop Nov 29, 2023
s-aga-r added a commit that referenced this pull request Nov 30, 2023
* feat: add field `Action on Purchase Order Submission`

(cherry picked from commit 628ea42)

# Conflicts:
#	erpnext/buying/doctype/buying_settings/buying_settings.json

* feat: auto create SCO on PO submission

(cherry picked from commit 9ec6f1e)

# Conflicts:
#	erpnext/buying/doctype/buying_settings/buying_settings.json

* feat: add field `Action on Subcontracting Receipt Submission`

(cherry picked from commit 762906f)

# Conflicts:
#	erpnext/buying/doctype/buying_settings/buying_settings.json

* chore: notify user on SCO creation

(cherry picked from commit 745e3bf)

* feat: add field `Purchase Order Item` in SCO Service Item

(cherry picked from commit 45d5cff)

* fix: hold PO item ref in SCO Service Item

(cherry picked from commit 7e4dd33)

* feat: add field `Purchase Order Item` in SCO Item

(cherry picked from commit a2ede7d)

* fix: maintain PO and PO Item ref in SCR Item

(cherry picked from commit e1cea25)

* feat: auto create PR on SCR submission

(cherry picked from commit 040cc8d)

* feat: add `Purchase Order` link in SCR connections

(cherry picked from commit ca8a5b4)

* feat: add `Subcontracting Receipt` link in PO connections

(cherry picked from commit 98cba5e)

* fix: dont show `View` button on cancelled SCR

(cherry picked from commit dd80d3b)

* fix: use checkbox instead of select field

(cherry picked from commit d366a91)

# Conflicts:
#	erpnext/buying/doctype/buying_settings/buying_settings.json

* feat: Subcontracting Receipt ref in Purchase Receipt

(cherry picked from commit d891bd7)

* feat: SCR Item ref in PR Item

(cherry picked from commit 37b3ac7)

* feat: provision to create PR from SCR

(cherry picked from commit 8052103)

* chore: PR ref in SCR connections

(cherry picked from commit 096a2c8)

* fix: map warehouses in return SCR

(cherry picked from commit 874766a)

* fix(ux): hide `Create Purchase Receipt` button for Subcontract Return

(cherry picked from commit 7145b04)

* chore: `linter`

(cherry picked from commit 857f2b5)

* test: auto create SCO on PO submit

(cherry picked from commit 68585f6)

* test: auto create PR on SCR submit

(cherry picked from commit 7b0cd03)

* fix(test): `test_auto_create_purchase_receipt`

(cherry picked from commit 3da0aa6)

* chore: `conflicts`

---------

Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
frappe-pr-bot pushed a commit that referenced this pull request Dec 5, 2023
# [15.5.0](v15.4.0...v15.5.0) (2023-12-05)

### Bug Fixes

* `AttributeError` while saving Purchase Invoice (backport [#38482](#38482)) ([#38490](#38490)) ([f6c48e8](f6c48e8))
* `OperationalError` while selecting Serial No in `Warranty Claim` (backport [#38394](#38394)) ([#38414](#38414)) ([80afeca](80afeca))
* Add missing french translations ([#38368](#38368)) ([b5c89ec](b5c89ec))
* better overlap logic for job card (backport [#38432](#38432)) ([#38522](#38522)) ([2a9e843](2a9e843))
* consider the `Valuation Method` while picking incorrect SLE (backport [#38592](#38592)) ([#38595](#38595)) ([9d45bbd](9d45bbd))
* debit credit mismatch in multi-currecy asset purchase receipt ([#38342](#38342)) ([b9f26ae](b9f26ae))
* don't consider cancelled entries ([#38401](#38401)) ([0a29dbe](0a29dbe))
* don't show non-stock items in Stock Analytics report (backport [#38543](#38543)) ([#38545](#38545)) ([282a5b2](282a5b2))
* don't update previous doc on rate change (backport [#38493](#38493)) ([#38524](#38524)) ([0aa96f7](0aa96f7))
* exclude `invoice_doctypes` from party advance ([927538f](927538f))
* exploded items in Subcontracting Receipt (backport [#38441](#38441)) ([#38445](#38445)) ([e066698](e066698))
* german translations for Lost Quotations (backport [#38435](#38435)) ([#38516](#38516)) ([33c59a2](33c59a2))
* get dynamic link with parenttype contact ([cb9589b](cb9589b))
* incorrect customer outstanding amount ([#38475](#38475)) ([98fe89a](98fe89a))
* incorrect material request quantity in Production Plan (backport [#38566](#38566)) ([#38579](#38579)) ([145ed3a](145ed3a))
* incorrect ordered qty for Subcontracting Order ([#38415](#38415)) ([71fe2bc](71fe2bc))
* incorrect requested quantity for the subcontracting order ([abe3e41](abe3e41))
* incorrectly treating normal payment as advance ([#38437](#38437)) ([246dd74](246dd74))
* item group filter in sales person wise report ([602f6ca](602f6ca))
* make create button translatable ([#38165](#38165)) ([95f9cc9](95f9cc9))
* **regional:** use net figures for sales calc ([#38260](#38260)) ([4a243ce](4a243ce))
* remove hardcoded, implicit rounding loss allowance ([4baf796](4baf796))
* scan for serial or batch in bundle (backport [#38534](#38534)) ([#38552](#38552)) ([88d2a8d](88d2a8d))
* set cwip account before asset tests ([de7e1ab](de7e1ab))
* show item name as title instead of item group in BOM (backport [#38478](#38478)) ([#38481](#38481)) ([8e57862](8e57862))
* show party instead of party name where naming series not set ([f120dc5](f120dc5))
* sql error while filtering on finance book in GL ([3779943](3779943))
* **test:** use correct account type for testing ([8b6eb35](8b6eb35))
* unset discount amount based on coupon code ([0e50e77](0e50e77))
* use `docstatus` instead of `status` (backport [#38439](#38439)) ([#38443](#38443)) ([a50e872](a50e872))
* use predefined onload property `load_after_mapping` ([#38209](#38209)) ([4a558b7](4a558b7))
* **ux:** make valuation field read only when it can't be modified (backport [#38450](#38450)) ([#38464](#38464)) ([2d9ba88](2d9ba88))
* validation error has not throw for the batch (backport [#38494](#38494)) ([#38502](#38502)) ([c797c53](c797c53))

### Features

* `Company` filter in `Stock Ledger Variance` report (backport [#38553](#38553)) ([#38574](#38574)) ([02d7dd8](02d7dd8))
* add customer group filter in sales register ([#38365](#38365)) ([185b715](185b715))
* auto create PR on SCR submission (backport [#38290](#38290)) ([#38428](#38428)) ([7005d51](7005d51))
* enable automatic type annotations (backport [#38452](#38452)) ([#38454](#38454)) ([5e6a4d2](5e6a4d2))
* shift depreciation for assets (backport [#38327](#38327)) ([#38417](#38417)) ([12ad1ec](12ad1ec))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2024
target_doc.is_subcontracted = 1
target_doc.is_old_subcontracting_flow = 0

target_doc = get_mapped_doc(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Items in Purchase Receipt are fetched from Purchase Order.
Is there any specific reason for not doing get_mapped_doc on Purchase Order??

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Streamline subcontracting workflow
2 participants