Merge branch 'develop' into po_supplier_skip
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/de_kontenplan_SKR04_with_account_number.json b/erpnext/accounts/doctype/account/chart_of_accounts/verified/de_kontenplan_SKR04_with_account_number.json
index ff95c5a..3fc109b 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/de_kontenplan_SKR04_with_account_number.json
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/de_kontenplan_SKR04_with_account_number.json
@@ -2433,29 +2433,26 @@
"Erl\u00f6se aus Verk\u00e4ufen Sachanlageverm\u00f6gen (bei Buchgewinn)": {
"account_number": "4849"
},
- "Erl\u00f6se aus Verk\u00e4ufen immaterieller VG (bei Buchgewinn) (Gruppe)": {
- "is_group": 1,
- "Erl\u00f6se aus Verk\u00e4ufen immaterieller VG (bei Buchgewinn)": {
- "account_number": "4850"
- },
- "Erl\u00f6se aus Verk\u00e4ufen Finanzanlagen (bei Buchgewinn)": {
- "account_number": "4851"
- },
- "Erl\u00f6se aus Verk\u00e4ufen Finanzanlagen (inl\u00e4ndische Kap.Ges., bei Buchgewinn)": {
- "account_number": "4852"
- },
- "Anlagenabg\u00e4nge Sachanlagen (Restbuchwert bei Buchvergewinn)": {
- "account_number": "4855"
- },
- "Anlagenabg\u00e4nge immaterielle VG (Restbuchwert bei Buchgewinn)": {
- "account_number": "4856"
- },
- "Anlagenabg\u00e4nge Finanzanlagen (Restbuchwert bei Buchgewinn)": {
- "account_number": "4857"
- },
- "Anlagenabg\u00e4nge Finanzanlagen (inl\u00e4ndische Kap.Ges., Restbuchwert bei Buchgewinn)": {
- "account_number": "4858"
- }
+ "Erl\u00f6se aus Verk\u00e4ufen immaterieller VG (bei Buchgewinn)": {
+ "account_number": "4850"
+ },
+ "Erl\u00f6se aus Verk\u00e4ufen Finanzanlagen (bei Buchgewinn)": {
+ "account_number": "4851"
+ },
+ "Erl\u00f6se aus Verk\u00e4ufen Finanzanlagen (inl\u00e4ndische Kap.Ges., bei Buchgewinn)": {
+ "account_number": "4852"
+ },
+ "Anlagenabg\u00e4nge Sachanlagen (Restbuchwert bei Buchvergewinn)": {
+ "account_number": "4855"
+ },
+ "Anlagenabg\u00e4nge immaterielle VG (Restbuchwert bei Buchgewinn)": {
+ "account_number": "4856"
+ },
+ "Anlagenabg\u00e4nge Finanzanlagen (Restbuchwert bei Buchgewinn)": {
+ "account_number": "4857"
+ },
+ "Anlagenabg\u00e4nge Finanzanlagen (inl\u00e4ndische Kap.Ges., Restbuchwert bei Buchgewinn)": {
+ "account_number": "4858"
},
"Ertr\u00e4ge aus Zuschreibungen des Sachanlageverm\u00f6gens": {
"account_number": "4910",
@@ -2578,20 +2575,17 @@
"Entnahme von Gegenst\u00e4nden ohne USt": {
"account_number": "4605"
},
- "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens 7 % USt (Gruppe)": {
- "is_group": 1,
- "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens 7 % USt": {
- "account_number": "4630"
- },
- "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens ohne USt": {
- "account_number": "4637"
- },
- "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternnehmens ohne USt (Telefon-Nutzung)": {
- "account_number": "4638"
- },
- "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens ohne USt (Kfz-Nutzung)": {
- "account_number": "4639"
- }
+ "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens 7 % USt": {
+ "account_number": "4630"
+ },
+ "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens ohne USt": {
+ "account_number": "4637"
+ },
+ "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternnehmens ohne USt (Telefon-Nutzung)": {
+ "account_number": "4638"
+ },
+ "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens ohne USt (Kfz-Nutzung)": {
+ "account_number": "4639"
},
"Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens 19 % USt (Gruppe)": {
"is_group": 1,
@@ -2629,14 +2623,11 @@
"Unentgeltliche Zuwendung von Gegenst\u00e4nden ohne USt": {
"account_number": "4689"
},
- "Nicht steuerbare Ums\u00e4tze (Innenums\u00e4tze) (Gruppe)": {
- "is_group": 1,
- "Nicht steuerbare Ums\u00e4tze (Innenums\u00e4tze)": {
- "account_number": "4690"
- },
- "Umsatzsteuerverg\u00fctungen, z.B. nach \u00a7 24 UStG": {
- "account_number": "4695"
- }
+ "Nicht steuerbare Ums\u00e4tze (Innenums\u00e4tze)": {
+ "account_number": "4690"
+ },
+ "Umsatzsteuerverg\u00fctungen, z.B. nach \u00a7 24 UStG": {
+ "account_number": "4695"
},
"Au\u00dferordentliche Ertr\u00e4ge (Gruppe)": {
"is_group": 1,
@@ -2646,41 +2637,35 @@
"Au\u00dferordentliche Ertr\u00e4ge finanzwirksam": {
"account_number": "7401"
},
- "Au\u00dferordentliche Ertr\u00e4ge nicht finanzwirksam (Gruppe)": {
- "is_group": 1,
- "Au\u00dferordentliche Ertr\u00e4ge nicht finanzwirksam": {
- "account_number": "7450"
- },
- "Ertr\u00e4ge durch Verschmelzung und Umwandlung": {
- "account_number": "7451"
- },
- "Ertr\u00e4ge durch den Verkauf von bedeutenden Beteiligungen": {
- "account_number": "7452"
- },
- "Ert\u00e4ge durch den Verkauf von bedeutenden Grundst\u00fccken": {
- "account_number": "7453"
- },
- "Gewinn aus der Ver\u00e4u\u00dferung oder der Aufgabe von Gesch\u00e4ftsaktivit\u00e4ten nach Steuern": {
- "account_number": "7454"
- }
+ "Au\u00dferordentliche Ertr\u00e4ge nicht finanzwirksam": {
+ "account_number": "7450"
},
- "Au\u00dferordentliche Ertr\u00e4ge aus der Anwendung von \u00dcbergangsvorschriften (Gruppe)": {
- "is_group": 1,
- "Au\u00dferordentliche Ertr\u00e4ge aus der Anwendung von \u00dcbergangsvorschriften": {
- "account_number": "7460"
- },
- "Au\u00dferordentliche Ertr\u00e4ge: Zuschreibung f. Sachanlageverm\u00f6gen": {
- "account_number": "7461"
- },
- "Au\u00dferordentliche Ertr\u00e4ge: Zuschreibung f. Finanzanlageverm\u00f6gen": {
- "account_number": "7462"
- },
- "Au\u00dferordentliche Ertr\u00e4ge: Wertpapiere im Umlaufverm\u00f6gen": {
- "account_number": "7463"
- },
- "Au\u00dferordentliche Ertr\u00e4ge: latente Steuern": {
- "account_number": "7464"
- }
+ "Ertr\u00e4ge durch Verschmelzung und Umwandlung": {
+ "account_number": "7451"
+ },
+ "Ertr\u00e4ge durch den Verkauf von bedeutenden Beteiligungen": {
+ "account_number": "7452"
+ },
+ "Ert\u00e4ge durch den Verkauf von bedeutenden Grundst\u00fccken": {
+ "account_number": "7453"
+ },
+ "Gewinn aus der Ver\u00e4u\u00dferung oder der Aufgabe von Gesch\u00e4ftsaktivit\u00e4ten nach Steuern": {
+ "account_number": "7454"
+ },
+ "Au\u00dferordentliche Ertr\u00e4ge aus der Anwendung von \u00dcbergangsvorschriften": {
+ "account_number": "7460"
+ },
+ "Au\u00dferordentliche Ertr\u00e4ge: Zuschreibung f. Sachanlageverm\u00f6gen": {
+ "account_number": "7461"
+ },
+ "Au\u00dferordentliche Ertr\u00e4ge: Zuschreibung f. Finanzanlageverm\u00f6gen": {
+ "account_number": "7462"
+ },
+ "Au\u00dferordentliche Ertr\u00e4ge: Wertpapiere im Umlaufverm\u00f6gen": {
+ "account_number": "7463"
+ },
+ "Au\u00dferordentliche Ertr\u00e4ge: latente Steuern": {
+ "account_number": "7464"
}
}
},
@@ -2718,40 +2703,43 @@
},
"Erl\u00f6sschm\u00e4lerungen aus im Inland steuerpfl. EU-Lieferungen 16 % USt": {
"account_number": "4729"
+ }
+ },
+ "Gew\u00e4hrte Skonti (Gruppe)": {
+ "is_group": 1,
+ "Gew. Skonti": {
+ "account_number": "4730"
},
- "Gew\u00e4hrte Skonti (Gruppe)": {
- "is_group": 1,
- "Gew. Skonti": {
- "account_number": "4730"
- },
- "Gew. Skonti 7 % USt": {
- "account_number": "4731"
- },
- "Gew. Skonti 19 % USt": {
- "account_number": "4736"
- },
- "Gew. Skonti aus Lieferungen von Mobilfunkger./Schaltkr., f. die der Leistungsempf. die Ust. schuldet": {
- "account_number": "4738"
- },
- "Gew. Skonti aus Leistungen, f. die der Leistungsempf. die Umsatzsteuer nach \u00a7 13b UStG schuldet": {
- "account_number": "4741"
- },
- "Gew. Skonti aus Erl\u00f6sen aus im anderen EU-Land steuerpfl. Leistungen, f. die der Leistungsempf. die Ust. schuldet": {
- "account_number": "4742"
- },
- "Gew. Skonti aus steuerfreien innergem. Lieferungen \u00a7 4 Nr. 1b UStG": {
- "account_number": "4743"
- },
- "Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen": {
- "account_number": "4745"
- },
- "Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen 7% USt": {
- "account_number": "4746"
- },
- "Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen 19% USt": {
- "account_number": "4748"
- }
+ "Gew. Skonti 7 % USt": {
+ "account_number": "4731"
},
+ "Gew. Skonti 19 % USt": {
+ "account_number": "4736"
+ },
+ "Gew. Skonti aus Lieferungen von Mobilfunkger./Schaltkr., f. die der Leistungsempf. die Ust. schuldet": {
+ "account_number": "4738"
+ },
+ "Gew. Skonti aus Leistungen, f. die der Leistungsempf. die Umsatzsteuer nach \u00a7 13b UStG schuldet": {
+ "account_number": "4741"
+ },
+ "Gew. Skonti aus Erl\u00f6sen aus im anderen EU-Land steuerpfl. Leistungen, f. die der Leistungsempf. die Ust. schuldet": {
+ "account_number": "4742"
+ },
+ "Gew. Skonti aus steuerfreien innergem. Lieferungen \u00a7 4 Nr. 1b UStG": {
+ "account_number": "4743"
+ },
+ "Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen": {
+ "account_number": "4745"
+ },
+ "Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen 7% USt": {
+ "account_number": "4746"
+ },
+ "Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen 19% USt": {
+ "account_number": "4748"
+ }
+ },
+ "Gew\u00e4hrte Boni (Gruppe)": {
+ "is_group": 1,
"Gew\u00e4hrte Boni 7 % USt": {
"account_number": "4750"
},
@@ -2864,103 +2852,79 @@
"account_number": "6398"
}
},
- "Versicherungen (Gruppe)": {
- "is_group": 1,
- "Versicherungen": {
- "account_number": "6400"
- },
- "Versicherungen f. Geb\u00e4ude, die zum Betriebsverm\u00f6gen geh\u00f6ren": {
- "account_number": "6405"
- },
- "Netto-Pr\u00e4mie f. R\u00fcckdeckung k\u00fcnftiger Versorgungsleistungen": {
- "account_number": "6410"
- },
- "Beitr\u00e4ge": {
- "account_number": "6420"
- },
- "Sonstige Abgaben": {
- "account_number": "6430"
- },
- "Steuerlich abzugsf\u00e4hige Versp\u00e4tungszuschl\u00e4ge und Zwangsgelder": {
- "account_number": "6436"
- },
- "Steuerlich nicht abzugsf\u00e4hige Versp\u00e4tungszuschl\u00e4ge und Zwangsgelder": {
- "account_number": "6437"
- },
- "Ausgleichsabgabe i. S. d. Schwerbehindertengesetzes": {
- "account_number": "6440"
- },
- "Reparaturen und Instandhaltung von Bauten": {
- "account_number": "6450"
- },
- "Reparaturen und Instandhaltung von technischenAnlagen und Maschinen": {
- "account_number": "6460"
- },
- "Reparaturen und Instandhaltung von anderen Anlagen und Betriebs- und Gesch\u00e4ftsausstattung": {
- "account_number": "6470"
- },
- "Zuf\u00fchrung zu Aufwandsr\u00fcckstellungen": {
- "account_number": "6475"
- },
- "Reparaturen und Instandhaltung von anderen Anlagen": {
- "account_number": "6485"
- },
- "Sonstige Reparaturen und Instandhaltungen": {
- "account_number": "6490"
- },
- "Wartungskosten f. Hard- und Software": {
- "account_number": "6495"
- },
- "Mietleasing (bewegliche Wirtschaftsg\u00fcter)": {
- "account_number": "6498"
- }
+ "Versicherungen": {
+ "account_number": "6400"
+ },
+ "Versicherungen f. Geb\u00e4ude, die zum Betriebsverm\u00f6gen geh\u00f6ren": {
+ "account_number": "6405"
+ },
+ "Netto-Pr\u00e4mie f. R\u00fcckdeckung k\u00fcnftiger Versorgungsleistungen": {
+ "account_number": "6410"
+ },
+ "Beitr\u00e4ge": {
+ "account_number": "6420"
+ },
+ "Sonstige Abgaben": {
+ "account_number": "6430"
+ },
+ "Steuerlich abzugsf\u00e4hige Versp\u00e4tungszuschl\u00e4ge und Zwangsgelder": {
+ "account_number": "6436"
+ },
+ "Steuerlich nicht abzugsf\u00e4hige Versp\u00e4tungszuschl\u00e4ge und Zwangsgelder": {
+ "account_number": "6437"
+ },
+ "Ausgleichsabgabe i. S. d. Schwerbehindertengesetzes": {
+ "account_number": "6440"
+ },
+ "Reparaturen und Instandhaltung von Bauten": {
+ "account_number": "6450"
+ },
+ "Reparaturen und Instandhaltung von technischenAnlagen und Maschinen": {
+ "account_number": "6460"
+ },
+ "Reparaturen und Instandhaltung von anderen Anlagen und Betriebs- und Gesch\u00e4ftsausstattung": {
+ "account_number": "6470"
+ },
+ "Zuf\u00fchrung zu Aufwandsr\u00fcckstellungen": {
+ "account_number": "6475"
+ },
+ "Reparaturen und Instandhaltung von anderen Anlagen": {
+ "account_number": "6485"
+ },
+ "Sonstige Reparaturen und Instandhaltungen": {
+ "account_number": "6490"
+ },
+ "Wartungskosten f. Hard- und Software": {
+ "account_number": "6495"
+ },
+ "Mietleasing (bewegliche Wirtschaftsg\u00fcter)": {
+ "account_number": "6498"
},
"Fahrzeugkosten (Gruppe)": {
"is_group": 1,
"Fahrzeugkosten": {
"account_number": "6500"
},
- "Kfz-Versicherungen (Gruppe)": {
- "is_group": 1,
- "Kfz-Versicherungen": {
- "account_number": "6520"
- }
+ "Kfz-Versicherungen": {
+ "account_number": "6520"
},
- "Laufende Kfz-Betriebskosten (Gruppe)": {
- "is_group": 1,
- "Laufende Kfz-Betriebskosten": {
- "account_number": "6530"
- }
+ "Laufende Kfz-Betriebskosten": {
+ "account_number": "6530"
},
- "Kfz-Reparaturen (Gruppe)": {
- "is_group": 1,
- "Kfz-Reparaturen": {
- "account_number": "6540"
- }
+ "Kfz-Reparaturen": {
+ "account_number": "6540"
},
- "Garagenmiete (Gruppe)": {
- "is_group": 1,
- "Garagenmiete": {
- "account_number": "6550"
- }
+ "Garagenmiete": {
+ "account_number": "6550"
},
- "Mietleasing Kfz (Gruppe)": {
- "is_group": 1,
- "Mietleasing Kfz": {
- "account_number": "6560"
- }
+ "Mietleasing Kfz": {
+ "account_number": "6560"
},
- "Sonstige Kfz-Kosten (Gruppe)": {
- "is_group": 1,
- "Sonstige Kfz-Kosten": {
- "account_number": "6570"
- }
+ "Sonstige Kfz-Kosten": {
+ "account_number": "6570"
},
- "Mautgeb\u00fchren (Gruppe)": {
- "is_group": 1,
- "Mautgeb\u00fchren": {
- "account_number": "6580"
- }
+ "Mautgeb\u00fchren": {
+ "account_number": "6580"
},
"Kfz-Kosten f. betrieblich genutzte zum Privatverm\u00f6gen geh\u00f6rende Kraftfahrzeuge": {
"account_number": "6590"
@@ -3022,20 +2986,23 @@
"Nicht abzugsf\u00e4hige Betriebsausgaben aus Werbe- und Repr\u00e4sentationskosten": {
"account_number": "6645"
},
- "Reisekosten Arbeitnehmer": {
- "account_number": "6650"
- },
- "Reisekosten Arbeitnehmer \u00dcbernachtungsaufwand": {
- "account_number": "6660"
- },
- "Reisekosten Arbeitnehmer Fahrtkosten": {
- "account_number": "6663"
- },
- "Reisekosten Arbeitnehmer Verpflegungsmehraufwand": {
- "account_number": "6664"
- },
- "Kilometergelderstattung Arbeitnehmer": {
- "account_number": "6668"
+ "Reisekosten Arbeitnehmer (Gruppe)": {
+ "is_group": 1,
+ "Reisekosten Arbeitnehmer": {
+ "account_number": "6650"
+ },
+ "Reisekosten Arbeitnehmer \u00dcbernachtungsaufwand": {
+ "account_number": "6660"
+ },
+ "Reisekosten Arbeitnehmer Fahrtkosten": {
+ "account_number": "6663"
+ },
+ "Reisekosten Arbeitnehmer Verpflegungsmehraufwand": {
+ "account_number": "6664"
+ },
+ "Kilometergelderstattung Arbeitnehmer": {
+ "account_number": "6668"
+ }
},
"Reisekosten Unternehmer (Gruppe)": {
"is_group": 1,
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index 0fade8c..7e9211a 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -317,13 +317,13 @@
"payment_request_type": args.get("payment_request_type"),
"currency": ref_doc.currency,
"grand_total": grand_total,
- "email_to": args.recipient_id or "",
+ "email_to": args.recipient_id or ref_doc.owner,
"subject": _("Payment Request for {0}").format(args.dn),
"message": gateway_account.get("message") or get_dummy_message(ref_doc),
"reference_doctype": args.dt,
"reference_name": args.dn,
- "party_type": args.get("party_type"),
- "party": args.get("party"),
+ "party_type": args.get("party_type") or "Customer",
+ "party": args.get("party") or ref_doc.customer,
"bank_account": bank_account
})
diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
index ef90b94..9c97426 100644
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -761,7 +761,7 @@
"depends_on": "is_fixed_asset",
"fetch_from": "item_code.asset_category",
"fieldname": "asset_category",
- "fieldtype": "Data",
+ "fieldtype": "Link",
"label": "Asset Category",
"options": "Asset Category",
"read_only": 1
@@ -777,7 +777,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2020-03-11 14:20:17.297284",
+ "modified": "2020-04-01 14:20:17.297284",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 5b05845..5b80349 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -437,13 +437,17 @@
if (not for_validate) or (for_validate and not self.get(fieldname)):
self.set(fieldname, pos.get(fieldname))
- customer_price_list = frappe.get_value("Customer", self.customer, 'default_price_list')
-
if pos.get("company_address"):
self.company_address = pos.get("company_address")
- if not customer_price_list:
- self.set('selling_price_list', pos.get('selling_price_list'))
+ customer_price_list, customer_group = frappe.get_value("Customer", self.customer, ['default_price_list', 'customer_group'])
+
+ customer_group_price_list = frappe.get_value("Customer Group", customer_group, 'default_price_list')
+
+ selling_price_list = customer_price_list or customer_group_price_list or pos.get('selling_price_list')
+
+ if selling_price_list:
+ self.set('selling_price_list', selling_price_list)
if not for_validate:
self.update_stock = cint(pos.get("update_stock"))
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 422ace6..4cfeb25 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -11,7 +11,7 @@
add_years, get_timestamp, nowdate, flt, cstr, add_months, get_last_day)
from frappe.contacts.doctype.address.address import (get_address_display,
get_default_address, get_company_address)
-from frappe.contacts.doctype.contact.contact import get_contact_details, get_default_contact
+from frappe.contacts.doctype.contact.contact import get_contact_details
from erpnext.exceptions import PartyFrozen, PartyDisabled, InvalidAccountCurrency
from erpnext.accounts.utils import get_fiscal_year
from erpnext import get_company_currency
@@ -281,8 +281,8 @@
existing_gle_currency = get_party_gle_currency(party_type, party, company)
if existing_gle_currency and party_account_currency != existing_gle_currency:
- frappe.throw(_("Accounting Entry for {0}: {1} can only be made in currency: {2}")
- .format(party_type, party, existing_gle_currency), InvalidAccountCurrency)
+ frappe.throw(_("{0} {1} has accounting entries in currency {2} for company {3}. Please select a receivable or payable account with currency {2}.")
+ .format(frappe.bold(party_type), frappe.bold(party), frappe.bold(existing_gle_currency), frappe.bold(company)), InvalidAccountCurrency)
def validate_party_accounts(doc):
companies = []
@@ -295,15 +295,13 @@
companies.append(account.company)
party_account_currency = frappe.db.get_value("Account", account.account, "account_currency", cache=True)
- existing_gle_currency = get_party_gle_currency(doc.doctype, doc.name, account.company)
if frappe.db.get_default("Company"):
company_default_currency = frappe.get_cached_value('Company',
frappe.db.get_default("Company"), "default_currency")
else:
company_default_currency = frappe.db.get_value('Company', account.company, "default_currency")
- if existing_gle_currency and party_account_currency != existing_gle_currency:
- frappe.throw(_("Accounting entries have already been made in currency {0} for company {1}. Please select a receivable or payable account with currency {0}.").format(existing_gle_currency, account.company))
+ validate_party_gle_currency(doc.doctype, doc.name, account.company, party_account_currency)
if doc.get("default_currency") and party_account_currency and company_default_currency:
if doc.default_currency != party_account_currency and doc.default_currency != company_default_currency:
@@ -615,3 +613,26 @@
if data:
return frappe._dict(data)
+
+def get_default_contact(doctype, name):
+ """
+ Returns default contact for the given doctype and name.
+ Can be ordered by `contact_type` to either is_primary_contact or is_billing_contact.
+ """
+ out = frappe.db.sql("""
+ SELECT dl.parent, c.is_primary_contact, c.is_billing_contact
+ FROM `tabDynamic Link` dl
+ INNER JOIN tabContact c ON c.name = dl.parent
+ WHERE
+ dl.link_doctype=%s AND
+ dl.link_name=%s AND
+ dl.parenttype = "Contact"
+ ORDER BY is_primary_contact DESC, is_billing_contact DESC
+ """, (doctype, name))
+ if out:
+ try:
+ return out[0][0]
+ except:
+ return None
+ else:
+ return None
\ No newline at end of file
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index a3264a4..3111a3a 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -499,7 +499,8 @@
reference_doctype: me.frm.doctype,
reference_name: me.frm.docname,
content: __('Reason for hold: ')+data.reason_for_hold,
- comment_email: frappe.session.user
+ comment_email: frappe.session.user,
+ comment_by: frappe.session.user_fullname
},
callback: function(r) {
if(!r.exc) {
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
index 39042b8..16061c6 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
@@ -4,15 +4,17 @@
// attach required files
{% include 'erpnext/public/js/controllers/buying.js' %};
-frappe.ui.form.on('Suppier Quotation', {
- setup: function(frm) {
- frm.custom_make_buttons = {
- 'Purchase Order': 'Purchase Order'
- }
- }
-});
-
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
+ setup: function() {
+ this.frm.custom_make_buttons = {
+ 'Purchase Order': 'Purchase Order',
+ 'Quotation': 'Quotation',
+ 'Subscription': 'Subscription'
+ }
+
+ this._super();
+ },
+
refresh: function() {
var me = this;
this._super();
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 88c8dba..fcc9098 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -672,19 +672,32 @@
# If asset has to be auto created
# Check for asset naming series
if item_data.get('asset_naming_series'):
+ created_assets = []
+
for qty in range(cint(d.qty)):
- self.make_asset(d)
- is_plural = 's' if cint(d.qty) != 1 else ''
- messages.append(_('{0} Asset{2} Created for <b>{1}</b>').format(cint(d.qty), d.item_code, is_plural))
+ asset = self.make_asset(d)
+ created_assets.append(asset)
+
+ if len(created_assets) > 5:
+ # dont show asset form links if more than 5 assets are created
+ messages.append(_('{} Asset{} created for {}').format(len(created_assets), is_plural, frappe.bold(d.item_code)))
+ else:
+ assets_link = list(map(lambda d: frappe.utils.get_link_to_form('Asset', d), created_assets))
+ assets_link = frappe.bold(','.join(assets_link))
+
+ is_plural = 's' if len(created_assets) != 1 else ''
+ messages.append(
+ _('Asset{} {assets_link} created for {}').format(is_plural, frappe.bold(d.item_code), assets_link=assets_link)
+ )
else:
- frappe.throw(_("Row {1}: Asset Naming Series is mandatory for the auto creation for item {0}")
- .format(d.item_code, d.idx))
+ frappe.throw(_("Row {}: Asset Naming Series is mandatory for the auto creation for item {}")
+ .format(d.idx, frappe.bold(d.item_code)))
else:
- messages.append(_("Assets not created for <b>{0}</b>. You will have to create asset manually.")
- .format(d.item_code))
+ messages.append(_("Assets not created for {0}. You will have to create asset manually.")
+ .format(frappe.bold(d.item_code)))
for message in messages:
- frappe.msgprint(message, title="Success")
+ frappe.msgprint(message, title="Success", indicator="green")
def make_asset(self, row):
if not row.asset_location:
@@ -716,6 +729,8 @@
asset.set_missing_values()
asset.insert()
+ return asset.name
+
def update_fixed_asset(self, field, delete_asset = False):
for d in self.get("items"):
if d.is_fixed_asset:
@@ -1026,4 +1041,4 @@
available_batches.append({'batch': batch, 'qty': available_qty})
required_qty -= available_qty
- return available_batches
\ No newline at end of file
+ return available_batches
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index d18f8e5..163ef72 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
+import erpnext
from frappe.desk.reportview import get_match_cond, get_filters_cond
from frappe.utils import nowdate, getdate
from collections import defaultdict
@@ -129,23 +130,26 @@
})
def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
+ company_currency = erpnext.get_company_currency(filters.get('company'))
+
tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount
where tabAccount.docstatus!=2
and account_type in (%s)
and is_group = 0
and company = %s
+ and account_currency = %s
and `%s` LIKE %s
order by idx desc, name
limit %s, %s""" %
- (", ".join(['%s']*len(filters.get("account_type"))), "%s", searchfield, "%s", "%s", "%s"),
- tuple(filters.get("account_type") + [filters.get("company"), "%%%s%%" % txt,
+ (", ".join(['%s']*len(filters.get("account_type"))), "%s", "%s", searchfield, "%s", "%s", "%s"),
+ tuple(filters.get("account_type") + [filters.get("company"), company_currency, "%%%s%%" % txt,
start, page_len]))
if not tax_accounts:
tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount
where tabAccount.docstatus!=2 and is_group = 0
- and company = %s and `%s` LIKE %s limit %s, %s"""
- % ("%s", searchfield, "%s", "%s", "%s"),
- (filters.get("company"), "%%%s%%" % txt, start, page_len))
+ and company = %s and account_currency = %s and `%s` LIKE %s limit %s, %s""" #nosec
+ % ("%s", "%s", searchfield, "%s", "%s", "%s"),
+ (filters.get("company"), company_currency, "%%%s%%" % txt, start, page_len))
return tax_accounts
diff --git a/erpnext/crm/doctype/lead/lead.json b/erpnext/crm/doctype/lead/lead.json
index bc007b1..5299368 100644
--- a/erpnext/crm/doctype/lead/lead.json
+++ b/erpnext/crm/doctype/lead/lead.json
@@ -171,7 +171,6 @@
"options": "Customer"
},
{
- "depends_on": "eval: doc.source==\"Campaign\"",
"fieldname": "campaign_name",
"fieldtype": "Link",
"label": "Campaign Name",
@@ -512,4 +511,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "title"
-}
\ No newline at end of file
+}
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index 73ef79b..eb9f860 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -135,10 +135,17 @@
# do not create an address if no fields are available,
# skipping country since the system auto-sets it from system defaults
- if not any([self.get(field) for field in address_fields if field != "country"]):
+ address = frappe.new_doc("Address")
+
+ mandatory_fields = [ df.fieldname for df in address.meta.fields if df.reqd ]
+
+ if not all([self.get(field) for field in mandatory_fields]):
+ frappe.msgprint(_('Missing mandatory fields in address. \
+ {0} to create address' ).format("<a href='desk#Form/Address/New Address 1' \
+ > Click here </a>"),
+ alert=True, indicator='yellow')
return
- address = frappe.new_doc("Address")
address.update({addr_field: self.get(addr_field) for addr_field in address_fields})
address.update({info_field: self.get(info_field) for info_field in info_fields})
address.insert()
diff --git a/erpnext/erpnext_integrations/custom/contact.json b/erpnext/erpnext_integrations/custom/contact.json
new file mode 100644
index 0000000..98a4bbc
--- /dev/null
+++ b/erpnext/erpnext_integrations/custom/contact.json
@@ -0,0 +1,60 @@
+{
+ "custom_fields": [
+ {
+ "_assign": null,
+ "_comments": null,
+ "_liked_by": null,
+ "_user_tags": null,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "collapsible_depends_on": null,
+ "columns": 0,
+ "creation": "2019-12-02 11:00:03.432994",
+ "default": null,
+ "depends_on": null,
+ "description": null,
+ "docstatus": 0,
+ "dt": "Contact",
+ "fetch_from": null,
+ "fetch_if_empty": 0,
+ "fieldname": "is_billing_contact",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "idx": 27,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "insert_after": "is_primary_contact",
+ "label": "Is Billing Contact",
+ "length": 0,
+ "modified": "2019-12-02 11:00:03.432994",
+ "modified_by": "Administrator",
+ "name": "Contact-is_billing_contact",
+ "no_copy": 0,
+ "options": null,
+ "owner": "Administrator",
+ "parent": null,
+ "parentfield": null,
+ "parenttype": null,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": null,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": null
+ }
+ ],
+ "custom_perms": [],
+ "doctype": "Contact",
+ "property_setters": [],
+ "sync_on_migrate": 1
+}
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js
index 3acaee4..0051ad9 100644
--- a/erpnext/manufacturing/doctype/bom/bom.js
+++ b/erpnext/manufacturing/doctype/bom/bom.js
@@ -43,8 +43,7 @@
frm.set_query("item_code", "items", function() {
return {
- query: "erpnext.controllers.queries.item_query",
- filters: [["Item", "name", "!=", cur_frm.doc.item]]
+ query: "erpnext.controllers.queries.item_query"
};
});
@@ -135,6 +134,7 @@
frappe.call({
method: "erpnext.manufacturing.doctype.work_order.work_order.make_work_order",
args: {
+ bom_no: frm.doc.name,
item: frm.doc.item,
qty: data.qty || 0.0,
project: frm.doc.project
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index f6cdb2e..b3e602b 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -114,10 +114,6 @@
child = self.append('operations', d)
child.hour_rate = flt(d.hour_rate / self.conversion_rate, 2)
- def validate_rm_item(self, item):
- if (item[0]['name'] in [it.item_code for it in self.items]) and item[0]['name'] == self.item:
- frappe.throw(_("BOM #{0}: Raw material cannot be same as main Item").format(self.name))
-
def set_bom_material_details(self):
for item in self.get("items"):
self.validate_bom_currecny(item)
@@ -147,7 +143,6 @@
args = json.loads(args)
item = self.get_item_det(args['item_code'])
- self.validate_rm_item(item)
args['bom_no'] = args['bom_no'] or item and cstr(item[0]['default_bom']) or ''
args['transfer_for_manufacture'] = (cstr(args.get('include_item_in_manufacturing', '')) or
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.js b/erpnext/manufacturing/doctype/job_card/job_card.js
index bc8c229..8c7876d 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.js
+++ b/erpnext/manufacturing/doctype/job_card/job_card.js
@@ -20,7 +20,7 @@
}
}
- if (frm.doc.docstatus == 0 && frm.doc.for_quantity > frm.doc.total_completed_qty
+ if (frm.doc.docstatus == 0 && (frm.doc.for_quantity > frm.doc.total_completed_qty || !frm.doc.for_quantity)
&& (!frm.doc.items.length || frm.doc.for_quantity == frm.doc.transferred_qty)) {
frm.trigger("prepare_timer_buttons");
}
@@ -59,10 +59,14 @@
let completed_time = frappe.datetime.now_datetime();
frm.trigger("hide_timer");
- frappe.prompt({fieldtype: 'Float', label: __('Completed Quantity'),
- fieldname: 'qty', reqd: 1, default: frm.doc.for_quantity}, data => {
- frm.events.complete_job(frm, completed_time, data.qty);
- }, __("Enter Value"), __("Complete"));
+ if (frm.doc.for_quantity) {
+ frappe.prompt({fieldtype: 'Float', label: __('Completed Quantity'),
+ fieldname: 'qty', reqd: 1, default: frm.doc.for_quantity}, data => {
+ frm.events.complete_job(frm, completed_time, data.qty);
+ }, __("Enter Value"), __("Complete"));
+ } else {
+ frm.events.complete_job(frm, completed_time, 0);
+ }
}).addClass("btn-primary");
}
},
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.json b/erpnext/manufacturing/doctype/job_card/job_card.json
index 156acce..7661fff 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.json
+++ b/erpnext/manufacturing/doctype/job_card/job_card.json
@@ -99,8 +99,7 @@
"fieldname": "for_quantity",
"fieldtype": "Float",
"in_list_view": 1,
- "label": "Qty To Manufacture",
- "reqd": 1
+ "label": "Qty To Manufacture"
},
{
"fieldname": "wip_warehouse",
@@ -122,6 +121,7 @@
"options": "Employee"
},
{
+ "allow_bulk_edit": 1,
"fieldname": "time_logs",
"fieldtype": "Table",
"label": "Time Logs",
@@ -290,7 +290,7 @@
}
],
"is_submittable": 1,
- "modified": "2019-12-03 13:08:57.926201",
+ "modified": "2020-03-27 13:36:35.417502",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Job Card",
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py
index 029db1c..f8c60f2 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/job_card.py
@@ -191,12 +191,9 @@
if not self.time_logs:
frappe.throw(_("Time logs are required for job card {0}").format(self.name))
- if self.total_completed_qty <= 0.0:
- frappe.throw(_("Total completed qty must be greater than zero"))
-
- if self.total_completed_qty != self.for_quantity:
- frappe.throw(_("The total completed qty({0}) must be equal to qty to manufacture({1})")
- .format(frappe.bold(self.total_completed_qty),frappe.bold(self.for_quantity)))
+ if self.for_quantity and self.total_completed_qty != self.for_quantity:
+ frappe.throw(_("The total completed qty({0}) must be equal to qty to manufacture({1})"
+ .format(frappe.bold(self.total_completed_qty),frappe.bold(self.for_quantity))))
def update_work_order(self):
if not self.work_order:
@@ -205,27 +202,34 @@
for_quantity, time_in_mins = 0, 0
from_time_list, to_time_list = [], []
- for d in frappe.get_all('Job Card',
- filters = {'docstatus': 1, 'operation_id': self.operation_id}):
- doc = frappe.get_doc('Job Card', d.name)
- for_quantity += doc.total_completed_qty
- time_in_mins += doc.total_time_in_mins
- for time_log in doc.time_logs:
- if time_log.from_time:
- from_time_list.append(time_log.from_time)
- if time_log.to_time:
- to_time_list.append(time_log.to_time)
+ data = frappe.get_all('Job Card',
+ fields = ["sum(total_time_in_mins) as time_in_mins", "sum(total_completed_qty) as completed_qty"],
+ filters = {"docstatus": 1, "work_order": self.work_order,
+ "workstation": self.workstation, "operation": self.operation})
+
+ if data and len(data) > 0:
+ for_quantity = data[0].completed_qty
+ time_in_mins = data[0].time_in_mins
if for_quantity:
+ time_data = frappe.db.sql("""
+ SELECT
+ min(from_time) as start_time, max(to_time) as end_time
+ FROM `tabJob Card` jc, `tabJob Card Time Log` jctl
+ WHERE
+ jctl.parent = jc.name and jc.work_order = %s
+ and jc.workstation = %s and jc.operation = %s and jc.docstatus = 1
+ """, (self.work_order, self.workstation, self.operation), as_dict=1)
+
wo = frappe.get_doc('Work Order', self.work_order)
for data in wo.operations:
- if data.name == self.operation_id:
+ if data.workstation == self.workstation and data.operation == self.operation:
data.completed_qty = for_quantity
data.actual_operation_time = time_in_mins
- data.actual_start_time = min(from_time_list) if from_time_list else None
- data.actual_end_time = max(to_time_list) if to_time_list else None
+ data.actual_start_time = time_data[0].start_time if time_data else None
+ data.actual_end_time = time_data[0].end_time if time_data else None
wo.flags.ignore_validate_update_after_submit = True
wo.update_operation_status()
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index a79ea0e..358a542 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -144,7 +144,7 @@
item_condition = " and mr_item.item_code ={0}".format(frappe.db.escape(self.item_code))
items = frappe.db.sql("""select distinct parent, name, item_code, warehouse, description,
- (qty - ordered_qty) as pending_qty
+ (qty - ordered_qty) * conversion_factor as pending_qty
from `tabMaterial Request Item` mr_item
where parent in (%s) and docstatus = 1 and qty > ordered_qty
and exists (select name from `tabBOM` bom where bom.item=mr_item.item_code
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py
index 71a62e4..84bfab2 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/work_order.py
@@ -552,24 +552,33 @@
d.db_set('transferred_qty', flt(transferred_qty), update_modified = False)
def update_consumed_qty_for_required_items(self):
- '''update consumed qty from submitted stock entries for that item against
- the work order'''
+ '''
+ Update consumed qty from submitted stock entries
+ against a work order for each stock item
+ '''
- for d in self.required_items:
- consumed_qty = frappe.db.sql('''select sum(qty)
- from `tabStock Entry` entry, `tabStock Entry Detail` detail
- where
+ for item in self.required_items:
+ consumed_qty = frappe.db.sql('''
+ SELECT
+ SUM(qty)
+ FROM
+ `tabStock Entry` entry,
+ `tabStock Entry Detail` detail
+ WHERE
entry.work_order = %(name)s
- and (entry.purpose = "Material Consumption for Manufacture"
- or entry.purpose = "Manufacture")
- and entry.docstatus = 1
- and detail.parent = entry.name
- and (detail.item_code = %(item)s or detail.original_item = %(item)s)''', {
- 'name': self.name,
- 'item': d.item_code
- })[0][0]
+ AND (entry.purpose = "Material Consumption for Manufacture"
+ OR entry.purpose = "Manufacture")
+ AND entry.docstatus = 1
+ AND detail.parent = entry.name
+ AND detail.s_warehouse IS NOT null
+ AND (detail.item_code = %(item)s
+ OR detail.original_item = %(item)s)
+ ''', {
+ 'name': self.name,
+ 'item': item.item_code
+ })[0][0]
- d.db_set('consumed_qty', flt(consumed_qty), update_modified = False)
+ item.db_set('consumed_qty', flt(consumed_qty), update_modified=False)
def make_bom(self):
data = frappe.db.sql(""" select sed.item_code, sed.qty, sed.s_warehouse
@@ -648,7 +657,7 @@
return res
@frappe.whitelist()
-def make_work_order(item, qty=0, project=None):
+def make_work_order(bom_no, item, qty=0, project=None):
if not frappe.has_permission("Work Order", "write"):
frappe.throw(_("Not permitted"), frappe.PermissionError)
@@ -657,6 +666,7 @@
wo_doc = frappe.new_doc("Work Order")
wo_doc.production_item = item
wo_doc.update(item_details)
+ wo_doc.bom_no = bom_no
if flt(qty) > 0:
wo_doc.qty = flt(qty)
diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js
index 3570a0f..5862963 100644
--- a/erpnext/projects/doctype/project/project.js
+++ b/erpnext/projects/doctype/project/project.js
@@ -18,7 +18,7 @@
};
},
onload: function (frm) {
- var so = frappe.meta.get_docfield("Project", "sales_order");
+ var so = frm.get_docfield("Project", "sales_order");
so.get_route_options_for_new_doc = function (field) {
if (frm.is_new()) return;
return {
@@ -135,4 +135,4 @@
frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
});
-}
\ No newline at end of file
+}
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index fc4541a..4397fe4 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -362,12 +362,17 @@
['serial_no', 'batch_no', 'barcode'].forEach(field => {
if (data[field] && frappe.meta.has_field(row_to_modify.doctype, field)) {
+
+ let value = (row_to_modify[field] && field === "serial_no")
+ ? row_to_modify[field] + '\n' + data[field] : data[field];
+
frappe.model.set_value(row_to_modify.doctype,
- row_to_modify.name, field, data[field]);
+ row_to_modify.name, field, value);
}
});
scan_barcode_field.set_value('');
+ refresh_field("items");
});
}
return false;
diff --git a/erpnext/public/js/utils/item_quick_entry.js b/erpnext/public/js/utils/item_quick_entry.js
index 2947d5b..27ef107 100644
--- a/erpnext/public/js/utils/item_quick_entry.js
+++ b/erpnext/public/js/utils/item_quick_entry.js
@@ -8,12 +8,19 @@
render_dialog: function() {
this.mandatory = this.get_variant_fields().concat(this.mandatory);
this.mandatory = this.mandatory.concat(this.get_attributes_fields());
+ this.check_naming_series_based_on();
this._super();
this.init_post_render_dialog_operations();
this.preset_fields_for_template();
this.dialog.$wrapper.find('.edit-full').text(__('Edit in full page for more options like assets, serial nos, batches etc.'))
},
+ check_naming_series_based_on: function() {
+ if (frappe.defaults.get_default("item_naming_by") === "Naming Series") {
+ this.mandatory = this.mandatory.filter(d => d.fieldname !== "item_code");
+ }
+ },
+
init_post_render_dialog_operations: function() {
this.dialog.fields_dict.attribute_html.$wrapper.append(frappe.render_template("item_quick_entry"));
this.init_for_create_variant_trigger();
diff --git a/erpnext/regional/report/datev/datev.js b/erpnext/regional/report/datev/datev.js
index 1e000b6..d8638ab 100644
--- a/erpnext/regional/report/datev/datev.js
+++ b/erpnext/regional/report/datev/datev.js
@@ -21,6 +21,12 @@
"default": frappe.datetime.now_date(),
"fieldtype": "Date",
"reqd": 1
+ },
+ {
+ "fieldname": "voucher_type",
+ "label": __("Voucher Type"),
+ "fieldtype": "Select",
+ "options": "\nSales Invoice\nPurchase Invoice\nPayment Entry\nExpense Claim\nPayroll Entry\nBank Reconciliation\nAsset\nStock Entry"
}
],
onload: function(query_report) {
diff --git a/erpnext/regional/report/datev/datev.py b/erpnext/regional/report/datev/datev.py
index e9b4235..a657912 100644
--- a/erpnext/regional/report/datev/datev.py
+++ b/erpnext/regional/report/datev/datev.py
@@ -62,6 +62,7 @@
filters -- dict of filters to be passed to the sql query
as_dict -- return as list of dicts [0,1]
"""
+ filter_by_voucher = 'AND gl.voucher_type = %(voucher_type)s' if filters.get('voucher_type') else ''
gl_entries = frappe.db.sql("""
SELECT
@@ -80,8 +81,10 @@
gl.posting_date as 'Belegdatum',
gl.voucher_no as 'Belegfeld 1',
gl.remarks as 'Buchungstext',
- gl.against_voucher_type as 'Beleginfo - Art 1',
- gl.against_voucher as 'Beleginfo - Inhalt 1'
+ gl.voucher_type as 'Beleginfo - Art 1',
+ gl.voucher_no as 'Beleginfo - Inhalt 1',
+ gl.against_voucher_type as 'Beleginfo - Art 2',
+ gl.against_voucher as 'Beleginfo - Inhalt 2'
FROM `tabGL Entry` gl
@@ -109,7 +112,8 @@
WHERE gl.company = %(company)s
AND DATE(gl.posting_date) >= %(from_date)s
AND DATE(gl.posting_date) <= %(to_date)s
- ORDER BY 'Belegdatum', gl.voucher_no""", filters, as_dict=as_dict)
+ {}
+ ORDER BY 'Belegdatum', gl.voucher_no""".format(filter_by_voucher), filters, as_dict=as_dict)
return gl_entries
@@ -281,24 +285,24 @@
def get_header(filters, csv_class):
coa = frappe.get_value("Company", filters.get("company"), "chart_of_accounts")
- coa_used = "SKR04" if "SKR04" in coa else ("SKR03" if "SKR03" in coa else "")
+ coa_used = "04" if "SKR04" in coa else ("03" if "SKR03" in coa else "")
header = [
# DATEV format
- # "DTVF" = created by DATEV software,
- # "EXTF" = created by other software
+ # "DTVF" = created by DATEV software,
+ # "EXTF" = created by other software
'"EXTF"',
# version of the DATEV format
- # 141 = 1.41,
- # 510 = 5.10,
- # 720 = 7.20
+ # 141 = 1.41,
+ # 510 = 5.10,
+ # 720 = 7.20
'700',
csv_class.DATA_CATEGORY,
'"%s"' % csv_class.FORMAT_NAME,
# Format version (regarding format name)
csv_class.FORMAT_VERSION,
# Generated on
- datetime.datetime.now().strftime("%Y%m%d%H%M%S"),
+ datetime.datetime.now().strftime("%Y%m%d%H%M%S") + '000',
# Imported on -- stays empty
'',
# Origin. Any two symbols, will be replaced by "SV" on import.
@@ -328,13 +332,21 @@
# R = Diktatkürzel
'',
# S = Buchungstyp
- # 1 = Transaction batch (Finanzbuchführung),
- # 2 = Annual financial statement (Jahresabschluss)
+ # 1 = Transaction batch (Finanzbuchführung),
+ # 2 = Annual financial statement (Jahresabschluss)
'1' if csv_class.DATA_CATEGORY == DataCategory.TRANSACTIONS else '',
# T = Rechnungslegungszweck
- '',
+ # 0 oder leer = vom Rechnungslegungszweck unabhängig
+ # 50 = Handelsrecht
+ # 30 = Steuerrecht
+ # 64 = IFRS
+ # 40 = Kalkulatorik
+ # 11 = Reserviert
+ # 12 = Reserviert
+ '0',
# U = Festschreibung
- '',
+ # TODO: Filter by Accounting Period. In export for closed Accounting Period, this will be "1"
+ '0',
# V = Default currency, for example, "EUR"
'"%s"' % frappe.get_value("Company", filters.get("company"), "default_currency"),
# reserviert
diff --git a/erpnext/regional/report/datev/datev_constants.py b/erpnext/regional/report/datev/datev_constants.py
index a4cd5fc..a059ed3 100644
--- a/erpnext/regional/report/datev/datev_constants.py
+++ b/erpnext/regional/report/datev/datev_constants.py
@@ -498,13 +498,27 @@
},
{
"label": "Beleginfo - Art 1",
- "fieldname": "Beleginfo - Art 2",
- "fieldtype": "Data",
+ "fieldname": "Beleginfo - Art 1",
+ "fieldtype": "Link",
+ "options": "DocType"
},
{
"label": "Beleginfo - Inhalt 1",
+ "fieldname": "Beleginfo - Inhalt 1",
+ "fieldtype": "Dynamic Link",
+ "options": "Beleginfo - Art 1"
+ },
+ {
+ "label": "Beleginfo - Art 2",
+ "fieldname": "Beleginfo - Art 2",
+ "fieldtype": "Link",
+ "options": "DocType"
+ },
+ {
+ "label": "Beleginfo - Inhalt 2",
"fieldname": "Beleginfo - Inhalt 2",
- "fieldtype": "Data",
+ "fieldtype": "Dynamic Link",
+ "options": "Beleginfo - Art 2"
}
]
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index fa765df..61aa608 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -664,7 +664,8 @@
reference_doctype: me.frm.doctype,
reference_name: me.frm.docname,
content: __('Reason for hold: ')+data.reason_for_hold,
- comment_email: frappe.session.user
+ comment_email: frappe.session.user,
+ comment_by: frappe.session.user_fullname
},
callback: function(r) {
if(!r.exc) {
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 13d2b15..ef2d19a 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -496,7 +496,7 @@
def get_requested_item_qty(sales_order):
return frappe._dict(frappe.db.sql("""
- select sales_order_item, sum(stock_qty)
+ select sales_order_item, sum(qty)
from `tabMaterial Request Item`
where docstatus = 1
and sales_order = %s
@@ -507,16 +507,12 @@
def make_material_request(source_name, target_doc=None):
requested_item_qty = get_requested_item_qty(source_name)
- def postprocess(source, doc):
- doc.material_request_type = "Purchase"
-
def update_item(source, target, source_parent):
# qty is for packed items, because packed items don't have stock_qty field
- qty = source.get("stock_qty") or source.get("qty")
+ qty = source.get("qty")
target.project = source_parent.project
target.qty = qty - requested_item_qty.get(source.name, 0)
- target.conversion_factor = 1
- target.stock_qty = qty - requested_item_qty.get(source.name, 0)
+ target.stock_qty = flt(target.qty) * flt(target.conversion_factor)
doc = get_mapped_doc("Sales Order", source_name, {
"Sales Order": {
@@ -537,14 +533,12 @@
"doctype": "Material Request Item",
"field_map": {
"name": "sales_order_item",
- "parent": "sales_order",
- "stock_uom": "uom",
- "stock_qty": "qty"
+ "parent": "sales_order"
},
"condition": lambda doc: not frappe.db.exists('Product Bundle', doc.item_code) and doc.stock_qty > requested_item_qty.get(doc.name, 0),
"postprocess": update_item
}
- }, target_doc, postprocess)
+ }, target_doc)
return doc
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py
index 3425f8f..17136e0 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.py
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.py
@@ -64,30 +64,40 @@
for d in item_prices_data:
item_prices[d.item_code] = d
-
+ # prepare filter for bin query
+ bin_filters = {'item_code': ['in', items]}
+ if warehouse:
+ bin_filters['warehouse'] = warehouse
if display_items_in_stock:
- filters = {'actual_qty': [">", 0], 'item_code': ['in', items]}
+ bin_filters['actual_qty'] = [">", 0]
- if warehouse:
- filters['warehouse'] = warehouse
+ # query item bin
+ bin_data = frappe.get_all(
+ 'Bin', fields=['item_code', 'sum(actual_qty) as actual_qty'],
+ filters=bin_filters, group_by='item_code'
+ )
- bin_data = frappe._dict(
- frappe.get_all("Bin", fields = ["item_code", "sum(actual_qty) as actual_qty"],
- filters = filters, group_by = "item_code")
- )
+ # convert list of dict into dict as {item_code: actual_qty}
+ bin_dict = {}
+ for b in bin_data:
+ bin_dict[b.get('item_code')] = b.get('actual_qty')
for item in items_data:
- row = {}
+ item_code = item.item_code
+ item_price = item_prices.get(item_code) or {}
+ item_stock_qty = bin_dict.get(item_code)
- row.update(item)
- item_price = item_prices.get(item.item_code) or {}
- row.update({
- 'price_list_rate': item_price.get('price_list_rate'),
- 'currency': item_price.get('currency'),
- 'actual_qty': bin_data.get('actual_qty')
- })
-
- result.append(row)
+ if display_items_in_stock and not item_stock_qty:
+ pass
+ else:
+ row = {}
+ row.update(item)
+ row.update({
+ 'price_list_rate': item_price.get('price_list_rate'),
+ 'currency': item_price.get('currency'),
+ 'actual_qty': item_stock_qty,
+ })
+ result.append(row)
res = {
'items': result
diff --git a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.py b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.py
index 4509904..28dd056 100644
--- a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.py
+++ b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
-from frappe.utils import getdate, cint
+from frappe.utils import getdate, cint, cstr
import calendar
def execute(filters=None):
@@ -48,7 +48,7 @@
new = new_customers_in.get(key, [0,0.0])
repeat = repeat_customers_in.get(key, [0,0.0])
- out.append([year, calendar.month_name[month],
+ out.append([cstr(year), calendar.month_name[month],
new[0], repeat[0], new[0] + repeat[0],
new[1], repeat[1], new[1] + repeat[1]])
diff --git a/erpnext/stock/__init__.py b/erpnext/stock/__init__.py
index a4d4cbd..8d64efe 100644
--- a/erpnext/stock/__init__.py
+++ b/erpnext/stock/__init__.py
@@ -13,12 +13,16 @@
]
def get_warehouse_account_map(company=None):
- if not frappe.flags.warehouse_account_map or frappe.flags.in_test:
+ company_warehouse_account_map = company and frappe.flags.setdefault('warehouse_account_map', {}).get(company)
+ warehouse_account_map = frappe.flags.warehouse_account_map
+
+ if not warehouse_account_map or not company_warehouse_account_map or frappe.flags.in_test:
warehouse_account = frappe._dict()
filters = {}
if company:
filters['company'] = company
+ frappe.flags.setdefault('warehouse_account_map', {}).setdefault(company, {})
for d in frappe.get_all('Warehouse',
fields = ["name", "account", "parent_warehouse", "company", "is_group"],
@@ -30,10 +34,12 @@
if d.account:
d.account_currency = frappe.db.get_value('Account', d.account, 'account_currency', cache=True)
warehouse_account.setdefault(d.name, d)
-
- frappe.flags.warehouse_account_map = warehouse_account
-
- return frappe.flags.warehouse_account_map
+ if company:
+ frappe.flags.warehouse_account_map[company] = warehouse_account
+ else:
+ frappe.flags.warehouse_account_map = warehouse_account
+
+ return frappe.flags.warehouse_account_map.get(company) or frappe.flags.warehouse_account_map
def get_warehouse_account(warehouse, warehouse_account=None):
account = warehouse.account
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
index d97b699..5ad0e13 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
@@ -8,6 +8,7 @@
from frappe.model.meta import get_field_precision
from frappe.model.document import Document
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
+from erpnext.accounts.doctype.account.account import get_account_currency
class LandedCostVoucher(Document):
def get_items_from_purchase_receipts(self):
@@ -43,6 +44,7 @@
else:
self.validate_applicable_charges_for_item()
self.validate_purchase_receipts()
+ self.validate_expense_accounts()
self.set_total_taxes_and_charges()
def check_mandatory(self):
@@ -71,6 +73,14 @@
frappe.throw(_("Row {0}: Cost center is required for an item {1}")
.format(item.idx, item.item_code))
+ def validate_expense_accounts(self):
+ company_currency = erpnext.get_company_currency(self.company)
+ for account in self.taxes:
+ if get_account_currency(account.expense_account) != company_currency:
+ frappe.throw(msg=_(""" Row {0}: Expense account currency should be same as company's default currency.
+ Please select expense account with account currency as {1}""")
+ .format(account.idx, frappe.bold(company_currency)), title=_("Invalid Account Currency"))
+
def set_total_taxes_and_charges(self):
self.total_taxes_and_charges = sum([flt(d.amount) for d in self.get("taxes")])
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index 4542847..285643d 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -501,7 +501,7 @@
wo_order = frappe.new_doc("Work Order")
wo_order.update({
"production_item": d.item_code,
- "qty": d.qty - d.ordered_qty,
+ "qty": d.stock_qty - d.ordered_qty,
"fg_warehouse": d.warehouse,
"wip_warehouse": default_wip_warehouse,
"description": d.description,
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 3af3524..3bb9415 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -310,12 +310,12 @@
method: "erpnext.stock.get_item_details.get_serial_no",
args: {"args": args},
callback: function(r) {
- if (!r.exe){
+ if (!r.exe && r.message){
frappe.model.set_value(cdt, cdn, "serial_no", r.message);
- }
- if (callback) {
- callback();
+ if (callback) {
+ callback();
+ }
}
}
});
@@ -623,10 +623,15 @@
if(r.message) {
var d = locals[cdt][cdn];
$.each(r.message, function(k, v) {
- frappe.model.set_value(cdt, cdn, k, v); // qty and it's subsequent fields weren't triggered
+ if (v) {
+ frappe.model.set_value(cdt, cdn, k, v); // qty and it's subsequent fields weren't triggered
+ }
});
refresh_field("items");
- erpnext.stock.select_batch_and_serial_no(frm, d);
+
+ if (!d.serial_no) {
+ erpnext.stock.select_batch_and_serial_no(frm, d);
+ }
}
}
});
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 8d746ba..be4c78b 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -238,7 +238,7 @@
if self.purpose == "Manufacture" and self.work_order:
production_item = frappe.get_value('Work Order', self.work_order, 'production_item')
for item in self.items:
- if item.item_code == production_item and item.qty != self.fg_completed_qty:
+ if item.item_code == production_item and item.t_warehouse and item.qty != self.fg_completed_qty:
frappe.throw(_("Finished product quantity <b>{0}</b> and For Quantity <b>{1}</b> cannot be different")
.format(item.qty, self.fg_completed_qty))
@@ -298,13 +298,8 @@
if validate_for_manufacture:
if d.bom_no:
d.s_warehouse = None
-
if not d.t_warehouse:
frappe.throw(_("Target warehouse is mandatory for row {0}").format(d.idx))
-
- elif self.pro_doc and (cstr(d.t_warehouse) != self.pro_doc.fg_warehouse and cstr(d.t_warehouse) != self.pro_doc.scrap_warehouse):
- frappe.throw(_("Target warehouse in row {0} must be same as Work Order").format(d.idx))
-
else:
d.t_warehouse = None
if not d.s_warehouse:
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index b100f45..7567a1a 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -428,7 +428,7 @@
frappe.get_desk_link(self.exceptions[0]["voucher_type"], self.exceptions[0]["voucher_no"]))
if self.verbose:
- frappe.throw(msg, NegativeStockError, title='Insufficent Stock')
+ frappe.throw(msg, NegativeStockError, title='Insufficient Stock')
else:
raise NegativeStockError(msg)