Skip to content

Commit

Permalink
Merge pull request #219 from efeone/item_code_naming
Browse files Browse the repository at this point in the history
feat:Item Code Auto-Naming
  • Loading branch information
muhammadmp authored Feb 16, 2024
2 parents 519d9a1 + b4055e0 commit 5e76a8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"stone",
"stone_weight",
"stone_charge",
"amount",
"purity"
"purity",
"amount"
],
"fields": [
{
Expand Down Expand Up @@ -87,7 +87,8 @@
"fieldname": "item_code",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Item Code"
"label": "Item Code",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
Expand Down
14 changes: 14 additions & 0 deletions aumms/aumms/doctype/purchase_tool/purchase_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@

class PurchaseTool(Document):

def autoname(self):
"""
Set the autoname for the document based on the specified format.
"""
if self.has_stone:
# If the item has a stone, use the specified format
for item_detail in self.get("item_details"):
item_detail.item_code = f"{self.item_category} {item_detail.stone_weight} {item_detail.stone} {item_detail.gold_weight}"
else:
# If there is no stone, use a different format
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 Down

0 comments on commit 5e76a8c

Please sign in to comment.