brotherton-erpnext/erpnext/patches/v11_0/refactor_autoname_naming.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

122 lines
4.3 KiB
Python
Raw Normal View History

# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
doctype_series_map = {
"Activity Cost": "PROJ-ACC-.#####",
"Agriculture Task": "AG-TASK-.#####",
"Assessment Plan": "EDU-ASP-.YYYY.-.#####",
"Assessment Result": "EDU-RES-.YYYY.-.#####",
"Asset Movement": "ACC-ASM-.YYYY.-.#####",
"Attendance Request": "HR-ARQ-.YY.-.MM.-.#####",
"Authorization Rule": "HR-ARU-.#####",
"Bank Guarantee": "ACC-BG-.YYYY.-.#####",
"Bin": "MAT-BIN-.YYYY.-.#####",
"Certification Application": "NPO-CAPP-.YYYY.-.#####",
"Certified Consultant": "NPO-CONS-.YYYY.-.#####",
"Chat Room": "CHAT-ROOM-.#####",
"Compensatory Leave Request": "HR-CMP-.YY.-.MM.-.#####",
"Client Script": "SYS-SCR-.#####",
"Employee Benefit Application": "HR-BEN-APP-.YY.-.MM.-.#####",
"Employee Benefit Application Detail": "",
"Employee Benefit Claim": "HR-BEN-CLM-.YY.-.MM.-.#####",
"Employee Incentive": "HR-EINV-.YY.-.MM.-.#####",
"Employee Onboarding": "HR-EMP-ONB-.YYYY.-.#####",
"Employee Onboarding Template": "HR-EMP-ONT-.#####",
"Employee Promotion": "HR-EMP-PRO-.YYYY.-.#####",
"Employee Separation": "HR-EMP-SEP-.YYYY.-.#####",
"Employee Separation Template": "HR-EMP-STP-.#####",
"Employee Tax Exemption Declaration": "HR-TAX-DEC-.YYYY.-.#####",
"Employee Tax Exemption Proof Submission": "HR-TAX-PRF-.YYYY.-.#####",
"Employee Transfer": "HR-EMP-TRN-.YYYY.-.#####",
"Event": "EVENT-.YYYY.-.#####",
"Exchange Rate Revaluation": "ACC-ERR-.YYYY.-.#####",
"GL Entry": "ACC-GLE-.YYYY.-.#####",
"Guardian": "EDU-GRD-.YYYY.-.#####",
"Hotel Room Reservation": "HTL-RES-.YYYY.-.#####",
"Item Price": "",
"Job Applicant": "HR-APP-.YYYY.-.#####",
"Job Offer": "HR-OFF-.YYYY.-.#####",
"Leave Encashment": "HR-ENC-.YYYY.-.#####",
"Leave Period": "HR-LPR-.YYYY.-.#####",
"Leave Policy": "HR-LPOL-.YYYY.-.#####",
"Loan": "ACC-LOAN-.YYYY.-.#####",
"Loan Application": "ACC-LOAP-.YYYY.-.#####",
"Loyalty Point Entry": "",
"Membership": "NPO-MSH-.YYYY.-.#####",
"Packing Slip": "MAT-PAC-.YYYY.-.#####",
"Patient Appointment": "HLC-APP-.YYYY.-.#####",
"Payment Terms Template Detail": "",
"Payroll Entry": "HR-PRUN-.YYYY.-.#####",
"Period Closing Voucher": "ACC-PCV-.YYYY.-.#####",
"Plant Analysis": "AG-PLA-.YYYY.-.#####",
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
"POS Closing Entry": "POS-CLO-.YYYY.-.#####",
"Prepared Report": "SYS-PREP-.YYYY.-.#####",
"Program Enrollment": "EDU-ENR-.YYYY.-.#####",
"Quotation Item": "",
"Restaurant Reservation": "RES-RES-.YYYY.-.#####",
"Retention Bonus": "HR-RTB-.YYYY.-.#####",
"Room": "HTL-ROOM-.YYYY.-.#####",
"Salary Structure Assignment": "HR-SSA-.YY.-.MM.-.#####",
"Sales Taxes and Charges": "",
"Share Transfer": "ACC-SHT-.YYYY.-.#####",
"Shift Assignment": "HR-SHA-.YY.-.MM.-.#####",
"Shift Request": "HR-SHR-.YY.-.MM.-.#####",
"SMS Log": "SYS-SMS-.#####",
"Soil Analysis": "AG-ANA-.YY.-.MM.-.#####",
"Soil Texture": "AG-TEX-.YYYY.-.#####",
"Stock Ledger Entry": "MAT-SLE-.YYYY.-.#####",
"Subscription": "ACC-SUB-.YYYY.-.#####",
"Task": "TASK-.YYYY.-.#####",
"Tax Rule": "ACC-TAX-RULE-.YYYY.-.#####",
"Training Feedback": "HR-TRF-.YYYY.-.#####",
"Training Result": "HR-TRR-.YYYY.-.#####",
"Travel Request": "HR-TRQ-.YYYY.-.#####",
"UOM Conversion Factor": "MAT-UOM-CNV-.#####",
"Water Analysis": "HR-WAT-.YYYY.-.#####",
"Workflow Action": "SYS-WACT-.#####",
}
2022-03-28 13:22:46 +00:00
def execute():
series_to_set = get_series()
for doctype, opts in series_to_set.items():
set_series(doctype, opts["value"])
2022-03-28 13:22:46 +00:00
def set_series(doctype, value):
doc = frappe.db.exists("Property Setter", {"doc_type": doctype, "property": "autoname"})
if doc:
frappe.db.set_value("Property Setter", doc, "value", value)
else:
make_property_setter(doctype, "", "autoname", value, "", for_doctype=True)
2022-03-28 13:22:46 +00:00
def get_series():
series_to_set = {}
for doctype in doctype_series_map:
if not frappe.db.exists("DocType", doctype):
continue
if not frappe.db.a_row_exists(doctype):
continue
series_to_preserve = get_series_to_preserve(doctype)
if not series_to_preserve:
continue
# set autoname property setter
if series_to_preserve:
series_to_set[doctype] = {"value": series_to_preserve}
return series_to_set
2022-03-28 13:22:46 +00:00
def get_series_to_preserve(doctype):
series_to_preserve = frappe.db.get_value("DocType", doctype, "autoname")
return series_to_preserve