Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
exclude: 'node_modules|.git'
default_stages: [pre-commit]
fail_fast: false


repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
files: "jewellery_erpnext.*"
exclude: ".*json$|.*txt$|.*csv|.*md"
- id: check-yaml
- id: no-commit-to-branch
args: ['--branch', 'develop']
- id: check-merge-conflict
- id: check-ast
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
types_or: [javascript, vue, scss]
# Ignore any files that might contain jinja / bundles
exclude: |
(?x)^(
jewellery_erpnext/public/dist/.*|
cypress/.*|
.*node_modules.*|
.*boilerplate.*|
jewellery_erpnext/public/js/controllers/.*|
jewellery_erpnext/templates/pages/order.js|
jewellery_erpnext/templates/includes/.*
)$

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.44.0
hooks:
- id: eslint
types_or: [javascript]
args: ['--quiet']
# Ignore any files that might contain jinja / bundles
exclude: |
(?x)^(
jewellery_erpnext/public/dist/.*|
cypress/.*|
.*node_modules.*|
.*boilerplate.*|
jewellery_erpnext/public/js/controllers/.*|
jewellery_erpnext/templates/pages/order.js|
jewellery_erpnext/templates/includes/.*
)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
hooks:
- id: ruff
name: "Run ruff import sorter"
args: ["--select=I", "--fix"]

- id: ruff
name: "Run ruff linter"

- id: ruff-format
name: "Run ruff formatter"

ci:
autoupdate_schedule: weekly
skip: []
submodules: false
Original file line number Diff line number Diff line change
@@ -1,62 +1,57 @@
import json

import frappe
from frappe.query_builder import Case
from frappe.query_builder.functions import Locate


@frappe.whitelist()
def get_mwo(source_name, target_doc=None):
if not target_doc:
target_doc = frappe.new_doc("Manufacturing Plan")
elif isinstance(target_doc, str):
target_doc = frappe.get_doc(json.loads(target_doc))
if not target_doc.get("manufacturing_work_order", {"manufacturing_work_order": source_name}):
target_doc.append(
"manufacturing_work_order",
{"manufacturing_work_order": source_name},
)
return target_doc


@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs
def get_mwo_details(doctype, txt, searchfield, start, page_len, filters):
conditions = ""
MWO = frappe.qb.DocType("Manufacturing Work Order")

query = (
frappe.qb.from_(MWO)
.select(MWO.name, MWO.company, MWO.customer)
.distinct()
.where((MWO.docstatus == 1) & (MWO.is_finding_mwo == 1))
)
if filters.get("company"):
# first_department = frappe.db.get_value(
# "Manufacturing Setting", {"company": filters.get("company")}, "default_department"
# )
first_department = frappe.db.get_value(
"Manufacturing Setting", {"manufacturer": filters.get("manufacturer")}, "default_department"
)
if first_department:
query = query.where(MWO.department == first_department)

query = (
query.where(
(MWO[searchfield].like(f"%{txt}%"))
| (MWO.company.like(f"%{txt}%"))
| (MWO.customer.like(f"%{txt}%"))
)
.orderby(Case().when(Locate(txt, MWO.name) > 0, Locate(txt, MWO.name)).else_(99999))
.orderby(Case().when(Locate(txt, MWO.company) > 0, Locate(txt, MWO.company)).else_(99999))
.orderby(Case().when(Locate(txt, MWO.customer) > 0, Locate(txt, MWO.customer)).else_(99999))
.orderby(MWO.idx, order=frappe.qb.desc)
.orderby(MWO.name)
.orderby(MWO.company)
.orderby(MWO.customer)
.limit(page_len)
.offset(start)
)
mwo_data = query.run(as_dict=True)

return mwo_data
MWO = frappe.qb.DocType("Manufacturing Work Order")

query = (
frappe.qb.from_(MWO)
.select(MWO.name, MWO.company, MWO.customer)
.distinct()
.where((MWO.docstatus == 1) & (MWO.is_finding_mwo == 1))
)
if filters.get("company"):
# first_department = frappe.db.get_value(
# "Manufacturing Setting", {"company": filters.get("company")}, "default_department"
# )
first_department = frappe.db.get_value(
"Manufacturing Setting",
{"manufacturer": filters.get("manufacturer")},
"default_department",
)
if first_department:
query = query.where(MWO.department == first_department)

query = (
query.where(
(MWO[searchfield].like("%{0}%".format(txt)))
| (MWO.company.like("%{0}%".format(txt)))
| (MWO.customer.like("%{0}%".format(txt)))
)
.orderby(
Case().when(Locate(txt, MWO.name) > 0, Locate(txt, MWO.name)).else_(99999)
)
.orderby(
Case()
.when(Locate(txt, MWO.company) > 0, Locate(txt, MWO.company))
.else_(99999)
)
.orderby(
Case()
.when(Locate(txt, MWO.customer) > 0, Locate(txt, MWO.customer))
.else_(99999)
)
.orderby(MWO.idx, order=frappe.qb.desc)
.orderby(MWO.name)
.orderby(MWO.company)
.orderby(MWO.customer)
.limit(page_len)
.offset(start)
)
mwo_data = query.run(as_dict=True)

return mwo_data
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ frappe.ui.form.on("Manufacturing Plan", {
},
get_sales_order(frm) {
map_current_doc({
method: "jewellery_erpnext.jewellery_erpnext.doctype.manufacturing_plan.manufacturing_plan.get_sales_order",
method: "jewellery_erpnext.jewellery_erpnext.doctype.manufacturing_plan.manufacturing_plan.get_details_to_append",
source_doctype: "Sales Order",
target: frm,
setters: {
Expand All @@ -35,7 +35,7 @@ frappe.ui.form.on("Manufacturing Plan", {
},
get_mwo(frm) {
map_current_doc({
method: "jewellery_erpnext.jewellery_erpnext.doctype.manufacturing_plan.doc_events.utils.get_mwo",
method: "jewellery_erpnext.jewellery_erpnext.doctype.manufacturing_plan.manufacturing_plan.get_details_to_append",
source_doctype: "Manufacturing Work Order",
target: frm,
setters: {
Expand Down Expand Up @@ -163,7 +163,7 @@ var map_current_doc = function (opts) {
// Sometimes we hit the limit for URL length of a GET request
// as we send the full target_doc. Hence this is a POST request.
type: "POST",
method: "frappe.model.mapper.map_docs",
method: "jewellery_erpnext.jewellery_erpnext.doctype.manufacturing_plan.manufacturing_plan.map_docs",
args: {
method: opts.method,
source_names: opts.source_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
"get_sales_order",
"get_repair_order",
"get_mwo",
"sales_order",
"manufacturing_work_order",
"setting_type",
"is_subcontracting",
"supplier",
"estimated_date",
"purchase_type",
"get_items_for_production_order",
"manufacturing_plan_table",
"section_break_cjenr",
"total_planned_qty",
Expand All @@ -45,25 +42,12 @@
"print_hide": 1,
"read_only": 1
},
{
"depends_on": "eval:doc.docstatus == 0",
"fieldname": "get_items_for_production_order",
"fieldtype": "Button",
"label": "Get Items for Production Order",
"options": "get_items_for_production"
},
{
"depends_on": "eval:doc.select_manufacture_order==\"Manufacturing\"",
"fieldname": "get_sales_order",
"fieldtype": "Button",
"label": "Get Sales Order"
},
{
"fieldname": "sales_order",
"fieldtype": "Table",
"label": "Sales Order",
"options": "Manufacturing Plan Sales Order"
},
{
"fieldname": "manufacturing_plan_table",
"fieldtype": "Table",
Expand Down Expand Up @@ -185,18 +169,13 @@
"label": "Purchase Type",
"options": "Purchase Type"
},
{
"fieldname": "manufacturing_work_order",
"fieldtype": "Table",
"label": "Manufacturing Work Order",
"options": "MWO Table"
},
{
"fieldname": "get_mwo",
"fieldtype": "Button",
"label": "Get MWO"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [
Expand All @@ -209,7 +188,7 @@
"link_fieldname": "manufacturing_plan"
}
],
"modified": "2024-06-13 16:57:21.321020",
"modified": "2025-12-17 16:48:20.890757",
"modified_by": "Administrator",
"module": "Jewellery Erpnext",
"name": "Manufacturing Plan",
Expand All @@ -231,6 +210,7 @@
"write": 1
}
],
"row_format": "Dynamic",
"sort_field": "modified",
"sort_order": "DESC",
"states": []
Expand Down
Loading