Fixes for model-cleanup frappe/frappe#478
This commit is contained in:
parent
f7daab7393
commit
13ae548ff6
@ -11,15 +11,15 @@ from erpnext.utilities.doctype.address.address import get_address_display
|
|||||||
from erpnext.utilities.doctype.contact.contact import get_contact_details
|
from erpnext.utilities.doctype.contact.contact import get_contact_details
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_party_details(party=None, account=None, party_type="Customer", company=None,
|
def get_party_details(party=None, account=None, party_type="Customer", company=None,
|
||||||
posting_date=None, price_list=None, currency=None):
|
posting_date=None, price_list=None, currency=None):
|
||||||
|
|
||||||
return _get_party_details(party, account, party_type, company, posting_date, price_list, currency)
|
return _get_party_details(party, account, party_type, company, posting_date, price_list, currency)
|
||||||
|
|
||||||
def _get_party_details(party=None, account=None, party_type="Customer", company=None,
|
def _get_party_details(party=None, account=None, party_type="Customer", company=None,
|
||||||
posting_date=None, price_list=None, currency=None, ignore_permissions=False):
|
posting_date=None, price_list=None, currency=None, ignore_permissions=False):
|
||||||
out = frappe._dict(set_account_and_due_date(party, account, party_type, company, posting_date))
|
out = frappe._dict(set_account_and_due_date(party, account, party_type, company, posting_date))
|
||||||
|
|
||||||
party = out[party_type.lower()]
|
party = out[party_type.lower()]
|
||||||
|
|
||||||
if not ignore_permissions and not frappe.has_permission(party_type, "read", party):
|
if not ignore_permissions and not frappe.has_permission(party_type, "read", party):
|
||||||
@ -31,38 +31,41 @@ def _get_party_details(party=None, account=None, party_type="Customer", company=
|
|||||||
set_contact_details(out, party, party_type)
|
set_contact_details(out, party, party_type)
|
||||||
set_other_values(out, party, party_type)
|
set_other_values(out, party, party_type)
|
||||||
set_price_list(out, party, party_type, price_list)
|
set_price_list(out, party, party_type, price_list)
|
||||||
|
|
||||||
if not out.get("currency"):
|
if not out.get("currency"):
|
||||||
out["currency"] = currency
|
out["currency"] = currency
|
||||||
|
|
||||||
# sales team
|
# sales team
|
||||||
if party_type=="Customer":
|
if party_type=="Customer":
|
||||||
out["sales_team"] = [{
|
out["sales_team"] = [{
|
||||||
"sales_person": d.sales_person,
|
"sales_person": d.sales_person,
|
||||||
"sales_designation": d.sales_designation
|
"sales_designation": d.sales_designation
|
||||||
} for d in party.get("sales_team")]
|
} for d in party.get("sales_team")]
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def set_address_details(out, party, party_type):
|
def set_address_details(out, party, party_type):
|
||||||
billing_address_field = "customer_address" if party_type == "Lead" \
|
billing_address_field = "customer_address" if party_type == "Lead" \
|
||||||
else party_type.lower() + "_address"
|
else party_type.lower() + "_address"
|
||||||
out[billing_address_field] = frappe.db.get_value("Address",
|
out[billing_address_field] = frappe.db.get_value("Address",
|
||||||
{party_type.lower(): party.name, "is_primary_address":1}, "name")
|
{party_type.lower(): party.name, "is_primary_address":1}, "name")
|
||||||
|
|
||||||
# address display
|
# address display
|
||||||
out.address_display = get_address_display(out[billing_address_field])
|
out.address_display = get_address_display(out[billing_address_field])
|
||||||
|
|
||||||
# shipping address
|
# shipping address
|
||||||
if party_type in ["Customer", "Lead"]:
|
if party_type in ["Customer", "Lead"]:
|
||||||
out.shipping_address_name = frappe.db.get_value("Address",
|
out.shipping_address_name = frappe.db.get_value("Address",
|
||||||
{party_type.lower(): party.name, "is_shipping_address":1}, "name")
|
{party_type.lower(): party.name, "is_shipping_address":1}, "name")
|
||||||
out.shipping_address = get_address_display(out["shipping_address_name"])
|
out.shipping_address = get_address_display(out["shipping_address_name"])
|
||||||
|
|
||||||
def set_contact_details(out, party, party_type):
|
def set_contact_details(out, party, party_type):
|
||||||
out.contact_person = frappe.db.get_value("Contact",
|
out.contact_person = frappe.db.get_value("Contact",
|
||||||
{party_type.lower(): party.name, "is_primary_contact":1}, "name")
|
{party_type.lower(): party.name, "is_primary_contact":1}, "name")
|
||||||
|
|
||||||
|
if not out.contact_person:
|
||||||
|
return
|
||||||
|
|
||||||
out.update(get_contact_details(out.contact_person))
|
out.update(get_contact_details(out.contact_person))
|
||||||
|
|
||||||
def set_other_values(out, party, party_type):
|
def set_other_values(out, party, party_type):
|
||||||
@ -73,7 +76,7 @@ def set_other_values(out, party, party_type):
|
|||||||
to_copy = ["supplier_name", "supplier_type"]
|
to_copy = ["supplier_name", "supplier_type"]
|
||||||
for f in to_copy:
|
for f in to_copy:
|
||||||
out[f] = party.get(f)
|
out[f] = party.get(f)
|
||||||
|
|
||||||
# fields prepended with default in Customer doctype
|
# fields prepended with default in Customer doctype
|
||||||
for f in ['currency', 'taxes_and_charges'] \
|
for f in ['currency', 'taxes_and_charges'] \
|
||||||
+ (['sales_partner', 'commission_rate'] if party_type=="Customer" else []):
|
+ (['sales_partner', 'commission_rate'] if party_type=="Customer" else []):
|
||||||
@ -81,16 +84,16 @@ def set_other_values(out, party, party_type):
|
|||||||
out[f] = party.get("default_" + f)
|
out[f] = party.get("default_" + f)
|
||||||
|
|
||||||
def set_price_list(out, party, party_type, given_price_list):
|
def set_price_list(out, party, party_type, given_price_list):
|
||||||
# price list
|
# price list
|
||||||
price_list = get_restrictions().get("Price List")
|
price_list = get_restrictions().get("Price List")
|
||||||
if isinstance(price_list, list):
|
if isinstance(price_list, list):
|
||||||
price_list = None
|
price_list = None
|
||||||
|
|
||||||
if not price_list:
|
if not price_list:
|
||||||
price_list = party.default_price_list
|
price_list = party.default_price_list
|
||||||
|
|
||||||
if not price_list and party_type=="Customer":
|
if not price_list and party_type=="Customer":
|
||||||
price_list = frappe.db.get_value("Customer Group",
|
price_list = frappe.db.get_value("Customer Group",
|
||||||
party.customer_group, "default_price_list")
|
party.customer_group, "default_price_list")
|
||||||
|
|
||||||
if not price_list:
|
if not price_list:
|
||||||
@ -98,9 +101,9 @@ def set_price_list(out, party, party_type, given_price_list):
|
|||||||
|
|
||||||
if price_list:
|
if price_list:
|
||||||
out.price_list_currency = frappe.db.get_value("Price List", price_list, "currency")
|
out.price_list_currency = frappe.db.get_value("Price List", price_list, "currency")
|
||||||
|
|
||||||
out["selling_price_list" if party.doctype=="Customer" else "buying_price_list"] = price_list
|
out["selling_price_list" if party.doctype=="Customer" else "buying_price_list"] = price_list
|
||||||
|
|
||||||
|
|
||||||
def set_account_and_due_date(party, account, party_type, company, posting_date):
|
def set_account_and_due_date(party, account, party_type, company, posting_date):
|
||||||
if not posting_date:
|
if not posting_date:
|
||||||
@ -108,13 +111,13 @@ def set_account_and_due_date(party, account, party_type, company, posting_date):
|
|||||||
return {
|
return {
|
||||||
party_type.lower(): party
|
party_type.lower(): party
|
||||||
}
|
}
|
||||||
|
|
||||||
if party:
|
if party:
|
||||||
account = get_party_account(company, party, party_type)
|
account = get_party_account(company, party, party_type)
|
||||||
elif account:
|
elif account:
|
||||||
party = frappe.db.get_value('Account', account, 'master_name')
|
party = frappe.db.get_value('Account', account, 'master_name')
|
||||||
|
|
||||||
account_fieldname = "debit_to" if party_type=="Customer" else "credit_to"
|
account_fieldname = "debit_to" if party_type=="Customer" else "credit_to"
|
||||||
|
|
||||||
out = {
|
out = {
|
||||||
party_type.lower(): party,
|
party_type.lower(): party,
|
||||||
@ -133,8 +136,8 @@ def get_party_account(company, party, party_type):
|
|||||||
|
|
||||||
if not acc_head:
|
if not acc_head:
|
||||||
create_party_account(party, party_type, company)
|
create_party_account(party, party_type, company)
|
||||||
|
|
||||||
return acc_head
|
return acc_head
|
||||||
|
|
||||||
def get_due_date(posting_date, party, party_type, account, company):
|
def get_due_date(posting_date, party, party_type, account, company):
|
||||||
"""Set Due Date = Posting Date + Credit Days"""
|
"""Set Due Date = Posting Date + Credit Days"""
|
||||||
@ -147,34 +150,34 @@ def get_due_date(posting_date, party, party_type, account, company):
|
|||||||
credit_days = frappe.db.get_value(party_type, party, "credit_days")
|
credit_days = frappe.db.get_value(party_type, party, "credit_days")
|
||||||
if company and not credit_days:
|
if company and not credit_days:
|
||||||
credit_days = frappe.db.get_value("Company", company, "credit_days")
|
credit_days = frappe.db.get_value("Company", company, "credit_days")
|
||||||
|
|
||||||
due_date = add_days(posting_date, credit_days) if credit_days else posting_date
|
due_date = add_days(posting_date, credit_days) if credit_days else posting_date
|
||||||
|
|
||||||
return due_date
|
return due_date
|
||||||
|
|
||||||
def create_party_account(party, party_type, company):
|
def create_party_account(party, party_type, company):
|
||||||
if not company:
|
if not company:
|
||||||
frappe.throw(_("Company is required"))
|
frappe.throw(_("Company is required"))
|
||||||
|
|
||||||
company_details = frappe.db.get_value("Company", company,
|
company_details = frappe.db.get_value("Company", company,
|
||||||
["abbr", "receivables_group", "payables_group"], as_dict=True)
|
["abbr", "receivables_group", "payables_group"], as_dict=True)
|
||||||
if not frappe.db.exists("Account", (party + " - " + company_details.abbr)):
|
if not frappe.db.exists("Account", (party + " - " + company_details.abbr)):
|
||||||
parent_account = company_details.receivables_group \
|
parent_account = company_details.receivables_group \
|
||||||
if party_type=="Customer" else company_details.payables_group
|
if party_type=="Customer" else company_details.payables_group
|
||||||
if not parent_account:
|
if not parent_account:
|
||||||
frappe.throw(_("Please enter Account Receivable/Payable group in company master"))
|
frappe.throw(_("Please enter Account Receivable/Payable group in company master"))
|
||||||
|
|
||||||
# create
|
# create
|
||||||
account = frappe.get_doc({
|
account = frappe.get_doc({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
'account_name': party,
|
'account_name': party,
|
||||||
'parent_account': parent_account,
|
'parent_account': parent_account,
|
||||||
'group_or_ledger':'Ledger',
|
'group_or_ledger':'Ledger',
|
||||||
'company': company,
|
'company': company,
|
||||||
'master_type': party_type,
|
'master_type': party_type,
|
||||||
'master_name': party,
|
'master_name': party,
|
||||||
"freeze_account": "No",
|
"freeze_account": "No",
|
||||||
"report_type": "Balance Sheet"
|
"report_type": "Balance Sheet"
|
||||||
}).insert(ignore_permissions=True)
|
}).insert(ignore_permissions=True)
|
||||||
|
|
||||||
frappe.msgprint(_("Account Created") + ": " + account.name)
|
frappe.msgprint(_("Account Created") + ": " + account.name)
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-06-25 11:04:03.000000",
|
"creation": "2013-06-25 11:04:03.000000",
|
||||||
"description": "Settings for Buying Module",
|
"description": "Settings for Buying Module",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Other",
|
"document_type": "Other",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"default": "Supplier Name",
|
"default": "Supplier Name",
|
||||||
"fieldname": "supp_master_name",
|
"fieldname": "supp_master_name",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Supplier Naming By",
|
"label": "Supplier Naming By",
|
||||||
"options": "Supplier Name\nNaming Series",
|
"options": "Supplier Name\nNaming Series",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "supplier_type",
|
"fieldname": "supplier_type",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Default Supplier Type",
|
"label": "Default Supplier Type",
|
||||||
"options": "Supplier Type",
|
"options": "Supplier Type",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "buying_price_list",
|
"fieldname": "buying_price_list",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Default Buying Price List",
|
"label": "Default Buying Price List",
|
||||||
"options": "Price List",
|
"options": "Price List",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_3",
|
"fieldname": "column_break_3",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "maintain_same_rate",
|
"fieldname": "maintain_same_rate",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Maintain same rate throughout purchase cycle",
|
"label": "Maintain same rate throughout purchase cycle",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "po_required",
|
"fieldname": "po_required",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Purchase Order Required",
|
"label": "Purchase Order Required",
|
||||||
"options": "No\nYes",
|
"options": "No\nYes",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "pr_required",
|
"fieldname": "pr_required",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Purchase Receipt Required",
|
"label": "Purchase Receipt Required",
|
||||||
"options": "No\nYes",
|
"options": "No\nYes",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"modified": "2014-02-19 19:02:00.000000",
|
"modified": "2014-02-19 19:02:00.000000",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Buying Settings",
|
"name": "Buying Settings",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"role": "System Manager",
|
"role": "System Manager",
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,15 @@ class Supplier(TransactionBase):
|
|||||||
self.name = make_autoname(self.naming_series + '.#####')
|
self.name = make_autoname(self.naming_series + '.#####')
|
||||||
|
|
||||||
def update_address(self):
|
def update_address(self):
|
||||||
frappe.db.sql("""update `tabAddress` set supplier_name=%s, modified=NOW()
|
frappe.db.sql("""update `tabAddress` set supplier_name=%s, modified=NOW()
|
||||||
where supplier=%s""", (self.supplier_name, self.name))
|
where supplier=%s""", (self.supplier_name, self.name))
|
||||||
|
|
||||||
def update_contact(self):
|
def update_contact(self):
|
||||||
frappe.db.sql("""update `tabContact` set supplier_name=%s, modified=NOW()
|
frappe.db.sql("""update `tabContact` set supplier_name=%s, modified=NOW()
|
||||||
where supplier=%s""", (self.supplier_name, self.name))
|
where supplier=%s""", (self.supplier_name, self.name))
|
||||||
|
|
||||||
def update_credit_days_limit(self):
|
def update_credit_days_limit(self):
|
||||||
frappe.db.sql("""update tabAccount set credit_days = %s where name = %s""",
|
frappe.db.sql("""update tabAccount set credit_days = %s where name = %s""",
|
||||||
(cint(self.credit_days), self.name + " - " + self.get_company_abbr()))
|
(cint(self.credit_days), self.name + " - " + self.get_company_abbr()))
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
@ -47,45 +47,45 @@ class Supplier(TransactionBase):
|
|||||||
|
|
||||||
# update credit days and limit in account
|
# update credit days and limit in account
|
||||||
self.update_credit_days_limit()
|
self.update_credit_days_limit()
|
||||||
|
|
||||||
def get_company_abbr(self):
|
def get_company_abbr(self):
|
||||||
return frappe.db.sql("select abbr from tabCompany where name=%s", self.company)[0][0]
|
return frappe.db.sql("select abbr from tabCompany where name=%s", self.company)[0][0]
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
#validation for Naming Series mandatory field...
|
#validation for Naming Series mandatory field...
|
||||||
if frappe.defaults.get_global_default('supp_master_name') == 'Naming Series':
|
if frappe.defaults.get_global_default('supp_master_name') == 'Naming Series':
|
||||||
if not self.naming_series:
|
if not self.naming_series:
|
||||||
msgprint("Series is Mandatory.", raise_exception=1)
|
msgprint("Series is Mandatory.", raise_exception=1)
|
||||||
|
|
||||||
def get_contacts(self,nm):
|
def get_contacts(self,nm):
|
||||||
if nm:
|
if nm:
|
||||||
contact_details =frappe.db.convert_to_lists(frappe.db.sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = %s", nm))
|
contact_details =frappe.db.convert_to_lists(frappe.db.sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = %s", nm))
|
||||||
|
|
||||||
return contact_details
|
return contact_details
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def delete_supplier_address(self):
|
def delete_supplier_address(self):
|
||||||
for rec in frappe.db.sql("select * from `tabAddress` where supplier=%s", (self.name,), as_dict=1):
|
for rec in frappe.db.sql("select * from `tabAddress` where supplier=%s", (self.name,), as_dict=1):
|
||||||
frappe.db.sql("delete from `tabAddress` where name=%s",(rec['name']))
|
frappe.db.sql("delete from `tabAddress` where name=%s",(rec['name']))
|
||||||
|
|
||||||
def delete_supplier_contact(self):
|
def delete_supplier_contact(self):
|
||||||
for contact in frappe.db.sql_list("""select name from `tabContact`
|
for contact in frappe.db.sql_list("""select name from `tabContact`
|
||||||
where supplier=%s""", self.name):
|
where supplier=%s""", self.name):
|
||||||
frappe.delete_doc("Contact", contact)
|
frappe.delete_doc("Contact", contact)
|
||||||
|
|
||||||
def delete_supplier_account(self):
|
def delete_supplier_account(self):
|
||||||
"""delete supplier's ledger if exist and check balance before deletion"""
|
"""delete supplier's ledger if exist and check balance before deletion"""
|
||||||
acc = frappe.db.sql("select name from `tabAccount` where master_type = 'Supplier' \
|
acc = frappe.db.sql("select name from `tabAccount` where master_type = 'Supplier' \
|
||||||
and master_name = %s and docstatus < 2", self.name)
|
and master_name = %s and docstatus < 2", self.name)
|
||||||
if acc:
|
if acc:
|
||||||
frappe.delete_doc('Account', acc[0][0])
|
frappe.delete_doc('Account', acc[0][0])
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
self.delete_supplier_address()
|
self.delete_supplier_address()
|
||||||
self.delete_supplier_contact()
|
self.delete_supplier_contact()
|
||||||
self.delete_supplier_account()
|
self.delete_supplier_account()
|
||||||
|
|
||||||
def before_rename(self, olddn, newdn, merge=False):
|
def before_rename(self, olddn, newdn, merge=False):
|
||||||
from erpnext.accounts.utils import rename_account_for
|
from erpnext.accounts.utils import rename_account_for
|
||||||
rename_account_for("Supplier", olddn, newdn, merge, self.company)
|
rename_account_for("Supplier", olddn, newdn, merge, self.company)
|
||||||
@ -99,7 +99,7 @@ class Supplier(TransactionBase):
|
|||||||
self.update_supplier_address(newdn, set_field)
|
self.update_supplier_address(newdn, set_field)
|
||||||
|
|
||||||
def update_supplier_address(self, newdn, set_field):
|
def update_supplier_address(self, newdn, set_field):
|
||||||
frappe.db.sql("""update `tabAddress` set address_title=%(newdn)s
|
frappe.db.sql("""update `tabAddress` set address_title=%(newdn)s
|
||||||
{set_field} where supplier=%(newdn)s"""\
|
{set_field} where supplier=%(newdn)s"""\
|
||||||
.format(set_field=set_field), ({"newdn": newdn}))
|
.format(set_field=set_field), ({"newdn": newdn}))
|
||||||
|
|
||||||
@ -107,19 +107,19 @@ class Supplier(TransactionBase):
|
|||||||
def get_dashboard_info(supplier):
|
def get_dashboard_info(supplier):
|
||||||
if not frappe.has_permission("Supplier", "read", supplier):
|
if not frappe.has_permission("Supplier", "read", supplier):
|
||||||
frappe.msgprint("No Permission", raise_exception=True)
|
frappe.msgprint("No Permission", raise_exception=True)
|
||||||
|
|
||||||
out = {}
|
out = {}
|
||||||
for doctype in ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]:
|
for doctype in ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]:
|
||||||
out[doctype] = frappe.db.get_value(doctype,
|
out[doctype] = frappe.db.get_value(doctype,
|
||||||
{"supplier": supplier, "docstatus": ["!=", 2] }, "count(*)")
|
{"supplier": supplier, "docstatus": ["!=", 2] }, "count(*)")
|
||||||
|
|
||||||
billing = frappe.db.sql("""select sum(grand_total), sum(outstanding_amount)
|
billing = frappe.db.sql("""select sum(grand_total), sum(outstanding_amount)
|
||||||
from `tabPurchase Invoice`
|
from `tabPurchase Invoice`
|
||||||
where supplier=%s
|
where supplier=%s
|
||||||
and docstatus = 1
|
and docstatus = 1
|
||||||
and fiscal_year = %s""", (supplier, frappe.db.get_default("fiscal_year")))
|
and fiscal_year = %s""", (supplier, frappe.db.get_default("fiscal_year")))
|
||||||
|
|
||||||
out["total_billing"] = billing[0][0]
|
out["total_billing"] = billing[0][0]
|
||||||
out["total_unpaid"] = billing[0][1]
|
out["total_unpaid"] = billing[0][1]
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
@ -1,90 +1,90 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-06-25 10:25:16.000000",
|
"creation": "2013-06-25 10:25:16.000000",
|
||||||
"description": "Settings for Selling Module",
|
"description": "Settings for Selling Module",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Other",
|
"document_type": "Other",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"default": "Customer Name",
|
"default": "Customer Name",
|
||||||
"fieldname": "cust_master_name",
|
"fieldname": "cust_master_name",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Customer Naming By",
|
"label": "Customer Naming By",
|
||||||
"options": "Customer Name\nNaming Series",
|
"options": "Customer Name\nNaming Series",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "<a href=\"#Sales Browser/Customer Group\">Add / Edit</a>",
|
"description": "<a href=\"#Sales Browser/Customer Group\">Add / Edit</a>",
|
||||||
"fieldname": "customer_group",
|
"fieldname": "customer_group",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Default Customer Group",
|
"label": "Default Customer Group",
|
||||||
"options": "Customer Group",
|
"options": "Customer Group",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
|
"description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
|
||||||
"fieldname": "territory",
|
"fieldname": "territory",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Default Territory",
|
"label": "Default Territory",
|
||||||
"options": "Territory",
|
"options": "Territory",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "selling_price_list",
|
"fieldname": "selling_price_list",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Default Price List",
|
"label": "Default Price List",
|
||||||
"options": "Price List",
|
"options": "Price List",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_5",
|
"fieldname": "column_break_5",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "so_required",
|
"fieldname": "so_required",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Sales Order Required",
|
"label": "Sales Order Required",
|
||||||
"options": "No\nYes",
|
"options": "No\nYes",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "dn_required",
|
"fieldname": "dn_required",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Delivery Note Required",
|
"label": "Delivery Note Required",
|
||||||
"options": "No\nYes",
|
"options": "No\nYes",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "maintain_same_sales_rate",
|
"fieldname": "maintain_same_sales_rate",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Maintain Same Rate Throughout Sales Cycle",
|
"label": "Maintain Same Rate Throughout Sales Cycle",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "editable_price_list_rate",
|
"fieldname": "editable_price_list_rate",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Allow user to edit Price List Rate in transactions",
|
"label": "Allow user to edit Price List Rate in transactions",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"modified": "2014-02-19 18:35:36.000000",
|
"modified": "2014-02-19 18:35:36.000000",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Selling Settings",
|
"name": "Selling Settings",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"role": "System Manager",
|
"role": "System Manager",
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ def after_install():
|
|||||||
def import_country_and_currency():
|
def import_country_and_currency():
|
||||||
from frappe.country_info import get_all
|
from frappe.country_info import get_all
|
||||||
data = get_all()
|
data = get_all()
|
||||||
|
|
||||||
for name in data:
|
for name in data:
|
||||||
country = frappe._dict(data[name])
|
country = frappe._dict(data[name])
|
||||||
if not frappe.db.exists("Country", name):
|
if not frappe.db.exists("Country", name):
|
||||||
@ -31,7 +31,7 @@ def import_country_and_currency():
|
|||||||
"date_format": country.date_format or "dd-mm-yyyy",
|
"date_format": country.date_format or "dd-mm-yyyy",
|
||||||
"time_zones": "\n".join(country.timezones or [])
|
"time_zones": "\n".join(country.timezones or [])
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
if country.currency and not frappe.db.exists("Currency", country.currency):
|
if country.currency and not frappe.db.exists("Currency", country.currency):
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"doctype": "Currency",
|
"doctype": "Currency",
|
||||||
@ -44,6 +44,9 @@ def import_country_and_currency():
|
|||||||
|
|
||||||
def import_defaults():
|
def import_defaults():
|
||||||
records = [
|
records = [
|
||||||
|
# role
|
||||||
|
{'doctype': "Role", "role_name": "Analytics"},
|
||||||
|
|
||||||
# item group
|
# item group
|
||||||
{'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
|
{'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
|
||||||
{'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
{'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
||||||
@ -51,40 +54,40 @@ def import_defaults():
|
|||||||
{'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
{'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
||||||
{'doctype': 'Item Group', 'item_group_name': 'Sub Assemblies', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
{'doctype': 'Item Group', 'item_group_name': 'Sub Assemblies', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
||||||
{'doctype': 'Item Group', 'item_group_name': 'Consumable', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
{'doctype': 'Item Group', 'item_group_name': 'Consumable', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
||||||
|
|
||||||
# deduction type
|
# deduction type
|
||||||
{'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
|
{'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
|
||||||
{'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
|
{'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
|
||||||
{'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
|
{'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
|
||||||
|
|
||||||
# earning type
|
# earning type
|
||||||
{'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
|
{'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
|
||||||
{'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
|
{'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
|
||||||
|
|
||||||
# expense claim type
|
# expense claim type
|
||||||
{'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
|
{'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
|
||||||
{'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
|
{'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
|
||||||
{'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
|
{'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
|
||||||
{'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
|
{'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
|
||||||
{'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
|
{'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
|
||||||
|
|
||||||
# leave type
|
# leave type
|
||||||
{'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
|
{'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
|
||||||
{'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
|
{'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
|
||||||
{'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
|
{'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
|
||||||
{'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
|
{'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
|
||||||
{'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
|
{'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
|
||||||
|
|
||||||
# territory
|
# territory
|
||||||
{'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
|
{'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
|
||||||
|
|
||||||
# customer group
|
# customer group
|
||||||
{'doctype': 'Customer Group', 'customer_group_name': 'All Customer Groups', 'is_group': 'Yes', 'name': 'All Customer Groups', 'parent_customer_group': ''},
|
{'doctype': 'Customer Group', 'customer_group_name': 'All Customer Groups', 'is_group': 'Yes', 'name': 'All Customer Groups', 'parent_customer_group': ''},
|
||||||
{'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
{'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
||||||
{'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
{'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
||||||
{'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
{'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
||||||
{'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
{'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
||||||
|
|
||||||
# supplier type
|
# supplier type
|
||||||
{'doctype': 'Supplier Type', 'supplier_type': 'Services'},
|
{'doctype': 'Supplier Type', 'supplier_type': 'Services'},
|
||||||
{'doctype': 'Supplier Type', 'supplier_type': 'Local'},
|
{'doctype': 'Supplier Type', 'supplier_type': 'Local'},
|
||||||
@ -93,33 +96,33 @@ def import_defaults():
|
|||||||
{'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
|
{'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
|
||||||
{'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
|
{'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
|
||||||
{'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
|
{'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
|
||||||
|
|
||||||
# Sales Person
|
# Sales Person
|
||||||
{'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
|
{'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
|
||||||
|
|
||||||
# UOM
|
# UOM
|
||||||
{'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit', "must_be_whole_number": 1},
|
{'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit', "must_be_whole_number": 1},
|
||||||
{'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box', "must_be_whole_number": 1},
|
{'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box', "must_be_whole_number": 1},
|
||||||
{'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
|
{'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
|
||||||
{'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos', "must_be_whole_number": 1},
|
{'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos', "must_be_whole_number": 1},
|
||||||
{'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair', "must_be_whole_number": 1},
|
{'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair', "must_be_whole_number": 1},
|
||||||
{'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1},
|
{'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1},
|
||||||
{'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
|
{'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
|
||||||
{'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
|
{'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
from frappe.modules import scrub
|
from frappe.modules import scrub
|
||||||
for r in records:
|
for r in records:
|
||||||
doc = frappe.get_doc(r)
|
doc = frappe.get_doc(r)
|
||||||
|
|
||||||
# ignore mandatory for root
|
# ignore mandatory for root
|
||||||
parent_link_field = ("parent_" + scrub(doc.doctype))
|
parent_link_field = ("parent_" + scrub(doc.doctype))
|
||||||
if doc.meta.get_field(parent_link_field) and not doc.get(parent_link_field):
|
if doc.meta.get_field(parent_link_field) and not doc.get(parent_link_field):
|
||||||
doc.ignore_mandatory = True
|
doc.ignore_mandatory = True
|
||||||
|
|
||||||
doc.insert()
|
doc.insert()
|
||||||
|
|
||||||
def feature_setup():
|
def feature_setup():
|
||||||
"""save global defaults and features setup"""
|
"""save global defaults and features setup"""
|
||||||
doc = frappe.get_doc("Features Setup", "Features Setup")
|
doc = frappe.get_doc("Features Setup", "Features Setup")
|
||||||
|
@ -80,7 +80,6 @@ def create_fiscal_year_and_company(args):
|
|||||||
'year_end_date': args.get('fy_end_date'),
|
'year_end_date': args.get('fy_end_date'),
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
print args
|
|
||||||
# Company
|
# Company
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"doctype":"Company",
|
"doctype":"Company",
|
||||||
@ -97,16 +96,16 @@ def create_fiscal_year_and_company(args):
|
|||||||
def create_price_lists(args):
|
def create_price_lists(args):
|
||||||
for pl_type in ["Selling", "Buying"]:
|
for pl_type in ["Selling", "Buying"]:
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"doctype": "Price List",
|
"doctype": "Price List",
|
||||||
"price_list_name": "Standard " + pl_type,
|
"price_list_name": "Standard " + pl_type,
|
||||||
"enabled": 1,
|
"enabled": 1,
|
||||||
"buying": 1 if pl_type == "Buying" else 0,
|
"buying": 1 if pl_type == "Buying" else 0,
|
||||||
"selling": 1 if pl_type == "Selling" else 0,
|
"selling": 1 if pl_type == "Selling" else 0,
|
||||||
"currency": args["currency"],
|
"currency": args["currency"],
|
||||||
"valid_for_territories": {
|
"valid_for_territories": [{
|
||||||
"territory": "All Territories"
|
"territory": "All Territories"
|
||||||
}
|
}]
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
def set_defaults(args):
|
def set_defaults(args):
|
||||||
# enable default currency
|
# enable default currency
|
||||||
|
@ -12,8 +12,11 @@ class PriceList(DocListController):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
if not cint(self.buying) and not cint(self.selling):
|
if not cint(self.buying) and not cint(self.selling):
|
||||||
throw(_("Price List must be applicable for Buying or Selling"))
|
throw(_("Price List must be applicable for Buying or Selling"))
|
||||||
|
|
||||||
if not self.get("valid_for_territories"):
|
try:
|
||||||
|
# at least one territory
|
||||||
|
self.validate_table_has_rows("valid_for_territories")
|
||||||
|
except frappe.EmptyTableError:
|
||||||
# if no territory, set default territory
|
# if no territory, set default territory
|
||||||
if frappe.defaults.get_user_default("territory"):
|
if frappe.defaults.get_user_default("territory"):
|
||||||
self.append("valid_for_territories", {
|
self.append("valid_for_territories", {
|
||||||
@ -21,8 +24,7 @@ class PriceList(DocListController):
|
|||||||
"territory": frappe.defaults.get_user_default("territory")
|
"territory": frappe.defaults.get_user_default("territory")
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
# at least one territory
|
raise
|
||||||
self.validate_table_has_rows("valid_for_territories")
|
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
self.set_default_if_missing()
|
self.set_default_if_missing()
|
||||||
@ -38,8 +40,8 @@ class PriceList(DocListController):
|
|||||||
frappe.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.name)
|
frappe.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.name)
|
||||||
|
|
||||||
def update_item_price(self):
|
def update_item_price(self):
|
||||||
frappe.db.sql("""update `tabItem Price` set currency=%s,
|
frappe.db.sql("""update `tabItem Price` set currency=%s,
|
||||||
buying=%s, selling=%s, modified=NOW() where price_list=%s""",
|
buying=%s, selling=%s, modified=NOW() where price_list=%s""",
|
||||||
(self.currency, cint(self.buying), cint(self.selling), self.name))
|
(self.currency, cint(self.buying), cint(self.selling), self.name))
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
@ -50,6 +52,6 @@ class PriceList(DocListController):
|
|||||||
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.save()
|
b.save()
|
||||||
|
|
||||||
for module in ["Selling", "Buying"]:
|
for module in ["Selling", "Buying"]:
|
||||||
_update_default_price_list(module)
|
_update_default_price_list(module)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user