-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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: link items to supplier / customer #27281
Merged
rohitwaghchaure
merged 17 commits into
frappe:develop
from
DeeMysterio:party-specific-items
Sep 14, 2021
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5d965d3
feat: add party specific items doctype, remove supplier item group
DeeMysterio 472f44b
add patch for removing supplier item group doctype
DeeMysterio b15987f
feat: add party specific items doctype, remove supplier item group
DeeMysterio 740fc43
Merge branch 'party-specific-items' of github.com:DeeMysterio/erpnext…
DeeMysterio ed87f02
Merge branch 'develop' into party-specific-items
DeeMysterio d191cca
refactor: semgrep stuff
DeeMysterio 694a257
refactor: refactor for party specific item
DeeMysterio 0cdfdee
add tests for party specific item feature
DeeMysterio 9cd0dab
reasolve merge conflicts
DeeMysterio 8dd6c17
Merge branch 'develop' into party-specific-items
rohitwaghchaure ef4b5a0
Merge branch 'develop' into party-specific-items
rohitwaghchaure ba8899e
link party specific item on supplier and customer doctype
DeeMysterio 23bb220
fix imports order
DeeMysterio 8fe333f
fix tests
DeeMysterio f31bd32
merge develop
6dce933
damn rename
DeeMysterio 038518a
minor doctype changes for party specific item
DeeMysterio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 0 additions & 77 deletions
77
erpnext/buying/doctype/supplier_item_group/supplier_item_group.json
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
erpnext/buying/doctype/supplier_item_group/supplier_item_group.py
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
erpnext/buying/doctype/supplier_item_group/test_supplier_item_group.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
erpnext/patches/v13_0/replace_supplier_item_group_with_party_specific_item.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) 2019, Frappe and Contributors | ||
# License: GNU General Public License v3. See license.txt | ||
|
||
import frappe | ||
|
||
|
||
def execute(): | ||
if frappe.db.table_exists('Supplier Item Group'): | ||
frappe.reload_doc("buying", "doctype", "supplier_item_group") | ||
sig = frappe.db.get_all("Supplier Item Group", fields=["name", "supplier", "item_group"]) | ||
for item in sig: | ||
psi = frappe.new_doc("Party Specific Item") | ||
psi.party_type = "Supplier" | ||
psi.party = item.supplier | ||
psi.restrict_based_on = "Item Group" | ||
psi.based_on_value = item.item_group | ||
psi.insert() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...upplier_item_group/supplier_item_group.js → ...arty_specific_item/party_specific_item.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
erpnext/selling/doctype/party_specific_item/party_specific_item.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"actions": [], | ||
"creation": "2021-08-27 19:28:07.559978", | ||
"doctype": "DocType", | ||
"editable_grid": 1, | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"party_type", | ||
"party", | ||
"column_break_3", | ||
"restrict_based_on", | ||
"based_on_value" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "party_type", | ||
"fieldtype": "Select", | ||
"in_list_view": 1, | ||
"label": "Party Type", | ||
"options": "Customer\nSupplier", | ||
"reqd": 1 | ||
}, | ||
{ | ||
"fieldname": "party", | ||
"fieldtype": "Dynamic Link", | ||
"in_list_view": 1, | ||
"label": "Party", | ||
"options": "party_type", | ||
"reqd": 1 | ||
}, | ||
{ | ||
"fieldname": "restrict_based_on", | ||
"fieldtype": "Select", | ||
"in_list_view": 1, | ||
"label": "Restrict Items Based On", | ||
"options": "Item\nItem Group\nBrand", | ||
"reqd": 1 | ||
}, | ||
{ | ||
"fieldname": "column_break_3", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fieldname": "based_on_value", | ||
"fieldtype": "Dynamic Link", | ||
"in_list_view": 1, | ||
"label": "Based On Value", | ||
"options": "restrict_based_on", | ||
"reqd": 1 | ||
} | ||
], | ||
"index_web_pages_for_search": 1, | ||
"links": [], | ||
"modified": "2021-09-02 17:36:37.337094", | ||
"modified_by": "Administrator", | ||
"module": "Selling", | ||
"name": "Party Specific Item", | ||
"owner": "Administrator", | ||
"permissions": [ | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"export": 1, | ||
"print": 1, | ||
"read": 1, | ||
"report": 1, | ||
"role": "System Manager", | ||
"share": 1, | ||
"write": 1 | ||
} | ||
], | ||
"sort_field": "modified", | ||
"sort_order": "DESC", | ||
"track_changes": 1 | ||
} |
19 changes: 19 additions & 0 deletions
19
erpnext/selling/doctype/party_specific_item/party_specific_item.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors | ||
# For license information, please see license.txt | ||
|
||
import frappe | ||
from frappe import _ | ||
from frappe.model.document import Document | ||
|
||
|
||
class PartySpecificItem(Document): | ||
def validate(self): | ||
exists = frappe.db.exists({ | ||
'doctype': 'Party Specific Item', | ||
'party_type': self.party_type, | ||
'party': self.party, | ||
'restrict_based_on': self.restrict_based_on, | ||
'based_on': self.based_on_value, | ||
}) | ||
if exists: | ||
frappe.throw(_("This item filter has already been applied for the {0}").format(self.party_type)) |
38 changes: 38 additions & 0 deletions
38
erpnext/selling/doctype/party_specific_item/test_party_specific_item.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors | ||
# See license.txt | ||
|
||
import unittest | ||
|
||
import frappe | ||
|
||
from erpnext.controllers.queries import item_query | ||
|
||
test_dependencies = ['Item', 'Customer', 'Supplier'] | ||
|
||
def create_party_specific_item(**args): | ||
psi = frappe.new_doc("Party Specific Item") | ||
psi.party_type = args.get('party_type') | ||
psi.party = args.get('party') | ||
psi.restrict_based_on = args.get('restrict_based_on') | ||
psi.based_on_value = args.get('based_on_value') | ||
psi.insert() | ||
|
||
class TestPartySpecificItem(unittest.TestCase): | ||
def setUp(self): | ||
self.customer = frappe.get_last_doc("Customer") | ||
self.supplier = frappe.get_last_doc("Supplier") | ||
self.item = frappe.get_last_doc("Item") | ||
|
||
def test_item_query_for_customer(self): | ||
create_party_specific_item(party_type='Customer', party=self.customer.name, restrict_based_on='Item', based_on_value=self.item.name) | ||
filters = {'is_sales_item': 1, 'customer': self.customer.name} | ||
items = item_query(doctype= 'Item', txt= '', searchfield= 'name', start= 0, page_len= 20,filters=filters, as_dict= False) | ||
for item in items: | ||
self.assertEqual(item[0], self.item.name) | ||
|
||
def test_item_query_for_supplier(self): | ||
create_party_specific_item(party_type='Supplier', party=self.supplier.name, restrict_based_on='Item Group', based_on_value=self.item.item_group) | ||
filters = {'supplier': self.supplier.name, 'is_purchase_item': 1} | ||
items = item_query(doctype= 'Item', txt= '', searchfield= 'name', start= 0, page_len= 20,filters=filters, as_dict= False) | ||
for item in items: | ||
self.assertEqual(item[2], self.item.item_group) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of supplier_item_group, reload party_specific_item table