Skip to content

Commit

Permalink
Merge pull request #40663 from barredterra/uom-data
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Mar 26, 2024
2 parents edced3f + 4d4d88e commit 652b4e5
Show file tree
Hide file tree
Showing 10 changed files with 430 additions and 317 deletions.
1 change: 1 addition & 0 deletions babel_extractors.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/setup/setup_wizard/data/uom_data.json,erpnext.gettext.extractors.uom_data.extract
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def get_item_dict():
income_expense_account_field = (
"income_account" if row.party_type == "Customer" else "expense_account"
)
default_uom = frappe.db.get_single_value("Stock Settings", "stock_uom") or _("Nos")
default_uom = frappe.db.get_single_value("Stock Settings", "stock_uom") or "Nos"
rate = flt(row.outstanding_amount) / flt(row.qty)

item_dict = frappe._dict(
Expand Down
Empty file added erpnext/gettext/__init__.py
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions erpnext/gettext/extractors/uom_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json


def extract(fileobj, *args, **kwargs):
"""
Extract messages from a JSON file with standard UOM data. To be used by the Babel extractor.
:param fileobj: the file-like object the messages should be extracted from
:rtype: `iterator`
"""
uom_list = json.load(fileobj)

if not isinstance(uom_list, list):
return

for uom_data in uom_list:
yield None, "_", uom_data.get("uom_name"), ["Name of a UOM"]
2 changes: 1 addition & 1 deletion erpnext/regional/italy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def get_invoice_summary(items, taxes):
rate=reference_row.tax_amount,
qty=1.0,
amount=reference_row.tax_amount,
stock_uom=frappe.db.get_single_value("Stock Settings", "stock_uom") or _("Nos"),
stock_uom=frappe.db.get_single_value("Stock Settings", "stock_uom") or "Nos",
tax_rate=tax.rate,
tax_amount=(reference_row.tax_amount * tax.rate) / 100,
net_amount=reference_row.tax_amount,
Expand Down
5 changes: 3 additions & 2 deletions erpnext/setup/doctype/uom/uom.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"icon": "fa fa-compass",
"idx": 1,
"links": [],
"modified": "2024-03-21 14:46:48.422406",
"modified": "2024-03-25 22:59:03.975975",
"modified_by": "Administrator",
"module": "Setup",
"name": "UOM",
Expand Down Expand Up @@ -104,5 +104,6 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "ASC",
"states": []
"states": [],
"translated_doctype": 1
}
Loading

0 comments on commit 652b4e5

Please sign in to comment.