Create price list if missing
This commit is contained in:
parent
27e295a4cb
commit
c1bfb63d96
@ -59,3 +59,4 @@ erpnext.patches.v4_0.create_custom_fields_for_india_specific_fields
|
|||||||
erpnext.patches.v4_0.save_default_letterhead
|
erpnext.patches.v4_0.save_default_letterhead
|
||||||
erpnext.patches.v4_0.update_custom_print_formats_for_renamed_fields
|
erpnext.patches.v4_0.update_custom_print_formats_for_renamed_fields
|
||||||
erpnext.patches.v4_0.update_other_charges_in_custom_purchase_print_formats
|
erpnext.patches.v4_0.update_other_charges_in_custom_purchase_print_formats
|
||||||
|
erpnext.patches.v4_0.create_price_list_if_missing
|
||||||
|
28
erpnext/patches/v4_0/create_price_list_if_missing.py
Normal file
28
erpnext/patches/v4_0/create_price_list_if_missing.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from frappe import _
|
||||||
|
from frappe.utils.nestedset import get_root_of
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
if not frappe.db.sql("select name from `tabPrice List` where buying=1"):
|
||||||
|
create_price_list(_("Standard Buying"), buying=1)
|
||||||
|
|
||||||
|
if not frappe.db.sql("select name from `tabPrice List` where selling=1"):
|
||||||
|
create_price_list(_("Standard Selling"), selling=1)
|
||||||
|
|
||||||
|
def create_price_list(pl_name, buying=0, selling=0):
|
||||||
|
price_list = frappe.get_doc({
|
||||||
|
"doctype": "Price List",
|
||||||
|
"price_list_name": pl_name,
|
||||||
|
"enabled": 1,
|
||||||
|
"buying": buying,
|
||||||
|
"selling": selling,
|
||||||
|
"currency": frappe.db.get_default("currency"),
|
||||||
|
"valid_for_territories": [{
|
||||||
|
"territory": get_root_of("Territory")
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
price_list.insert()
|
@ -51,6 +51,7 @@ class PriceList(Document):
|
|||||||
|
|
||||||
if self.name == b.get(price_list_fieldname):
|
if self.name == b.get(price_list_fieldname):
|
||||||
b.set(price_list_fieldname, None)
|
b.set(price_list_fieldname, None)
|
||||||
|
b.ignore_permissions = True
|
||||||
b.save()
|
b.save()
|
||||||
|
|
||||||
for module in ["Selling", "Buying"]:
|
for module in ["Selling", "Buying"]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user