Skip to content

Commit

Permalink
Merge pull request #220 from efeone/rename_jewellery_receipt
Browse files Browse the repository at this point in the history
fix:Renamed Doctype purchase Tool and filter applied
  • Loading branch information
muhammadmp authored Feb 17, 2024
2 parents 5e76a8c + 0aac820 commit 4597c81
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 47 deletions.
106 changes: 106 additions & 0 deletions aumms/aumms/doctype/jewellery_item_receipt/jewellery_item_receipt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2024-02-12 23:46:19.937061",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"item_details_column",
"item_code",
"gold_weight",
"net_weight",
"uom",
"column_break_juco",
"stone",
"stone_weight",
"stone_charge",
"purity",
"amount"
],
"fields": [
{
"fieldname": "item_details_column",
"fieldtype": "Column Break",
"label": "Item Details "
},
{
"fieldname": "gold_weight",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Gold Weight"
},
{
"fieldname": "net_weight",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Net Weight",
"read_only": 1
},
{
"fieldname": "amount",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Amount",
"read_only": 1
},
{
"fieldname": "column_break_juco",
"fieldtype": "Column Break"
},
{
"fieldname": "stone",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Stone",
"read_only": 1
},
{
"depends_on": "eval:doc.stone",
"fieldname": "stone_weight",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Stone Weight"
},
{
"depends_on": "eval:doc.stone",
"fieldname": "stone_charge",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Stone Charge"
},
{
"fieldname": "purity",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Purity",
"options": "Purity"
},
{
"fieldname": "uom",
"fieldtype": "Link",
"in_list_view": 1,
"label": "UOM",
"options": "UOM"
},
{
"fieldname": "item_code",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Item Code",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-02-16 15:46:24.566785",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Jewellery Item Receipt",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
from frappe.model.document import Document


class PurchaseItemDetails(Document):
class JewelleryItemReceipt(Document):
pass
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
// Copyright (c) 2024, efeone and contributors
// For license information, please see license.txt

frappe.ui.form.on("Purchase Tool", {
// refresh: function(frm) {}
frappe.ui.form.on("Jewellery Receipt", {
refresh:function(frm) {

// show only customers whose territory is set to India
frm.set_query('stone', () => {
return {
filters: {
is_stone_item: 1
}
}
})

},
});

frappe.ui.form.on("Purchase Item Details", {
frappe.ui.form.on("Jewellery Item Receipt", {
item_details_add: function(frm, cdt, cdn) {
let child = locals[cdt][cdn];
if (frm.doc.stone) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "PT-.#####",
"autoname": "JR-.#####",
"creation": "2024-02-13 00:05:57.984587",
"doctype": "DocType",
"engine": "InnoDB",
Expand All @@ -26,12 +26,10 @@
"fieldtype": "Section Break"
},
{
"fieldname": "supplier",
"fieldname": "item_category",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Supplier",
"options": "Supplier",
"reqd": 1
"label": "Item Category",
"options": "Item Category"
},
{
"fieldname": "item_type",
Expand All @@ -49,16 +47,30 @@
"options": "Item Group",
"reqd": 1
},
{
"fieldname": "supplier",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Supplier",
"options": "Supplier",
"reqd": 1
},
{
"fieldname": "column_break_pnvl",
"fieldtype": "Column Break"
},
{
"depends_on": "eval:doc.has_stone == 1",
"fieldname": "stone",
"fieldtype": "Link",
"label": "Stone",
"options": "Stone Type"
"fieldname": "board_rate",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Board Rate",
"reqd": 1
},
{
"fieldname": "date",
"fieldtype": "Date",
"label": "Date",
"reqd": 1
},
{
"default": "0",
Expand All @@ -67,52 +79,40 @@
"label": "Has Stone"
},
{
"fieldname": "item_details",
"fieldtype": "Table",
"label": "Item details",
"options": "Purchase Item Details"
"depends_on": "eval:doc.has_stone == 1",
"fieldname": "stone",
"fieldtype": "Link",
"label": "Stone",
"options": "AuMMS Item"
},
{
"fieldname": "section_break_vxux",
"fieldtype": "Section Break"
},
{
"fieldname": "item_details",
"fieldtype": "Table",
"label": "Item Details",
"options": "Jewellery Item Receipt"
},
{
"fieldname": "amended_from",
"fieldtype": "Link",
"label": "Amended From",
"no_copy": 1,
"options": "Purchase Tool",
"options": "Jewellery Receipt",
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"fieldname": "date",
"fieldtype": "Date",
"label": "Date",
"reqd": 1
},
{
"fieldname": "board_rate",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Board Rate",
"reqd": 1
},
{
"fieldname": "item_category",
"fieldtype": "Link",
"label": "Item Category",
"options": "Item Category"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-02-16 11:39:30.426147",
"modified": "2024-02-17 11:00:48.481280",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Purchase Tool",
"name": "Jewellery Receipt",
"naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
Expand All @@ -133,4 +133,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from frappe.model.document import Document
from frappe.model.naming import make_autoname
from frappe.model.mapper import get_mapped_doc
from frappe.model import meta

class PurchaseTool(Document):
class JewelleryReceipt(Document):

def autoname(self):
"""
Expand All @@ -20,7 +21,6 @@ def autoname(self):
for item_detail in self.get("item_details"):
item_detail.item_code = f"{self.item_category} {item_detail.gold_weight}"


def before_submit(self):
self.create_item()

Expand All @@ -46,8 +46,9 @@ def create_item(self):
'item_name': self.stone,
'item_type': self.stone,
})
frappe.msgprint('AuMMS Item Created.')
aumms_item.insert(ignore_permissions=True)
frappe.msgprint('AuMMS Item Created.', indicator="green", alert=1)


def create_purchase_receipt(self):
purchase_receipt = frappe.new_doc('Purchase Receipt')
Expand All @@ -73,4 +74,23 @@ def create_purchase_receipt(self):
purchase_receipt.save(ignore_permissions=True)
purchase_receipt.submit()

frappe.msgprint('Purchase Receipt created and submitted successfully.')
frappe.msgprint('Purchase Receipt created.', indicator="green", alert=1)

@frappe.whitelist()
def get_stone_items():
stone_items = frappe.get_list("AuMMS Item", filters={"is_stone_item": 1}, fields=["item_code", "item_name"])
return stone_items

# @frappe.whitelist()
# def stone_filter_query(doctype, txt, searchfield, start, page_len, filters):
# '''
# Query for Stone field in JewelleryReceipt DocType
# '''
# return frappe.db.sql('''
# SELECT
# item_code
# FROM
# `tabAuMMS Item`
# WHERE
# is_stone_item = 1
# ''')
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
from frappe.tests.utils import FrappeTestCase


class TestPurchaseTool(FrappeTestCase):
class TestJewelleryReceipt(FrappeTestCase):
pass

0 comments on commit 4597c81

Please sign in to comment.