Merge branch 'develop' of https://github.com/frappe/erpnext into multi-currency
[fix][patch] delete item variant attributes if no variants exists against that item
This commit is contained in:
commit
f76d63b92a
@ -1,6 +1,6 @@
|
|||||||
# ERPNext - Open source ERP for small and medium-size business [](https://travis-ci.org/frappe/erpnext)
|
# ERPNext - ERP made simple
|
||||||
|
|
||||||
[](https://gitter.im/frappe/erpnext?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://travis-ci.org/frappe/erpnext) [](https://gitter.im/frappe/erpnext?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
[https://erpnext.com](https://erpnext.com)
|
[https://erpnext.com](https://erpnext.com)
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,8 @@ from frappe.utils import cstr, cint
|
|||||||
from frappe import throw, _
|
from frappe import throw, _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class RootNotEditable(frappe.ValidationError): pass
|
||||||
|
|
||||||
class Account(Document):
|
class Account(Document):
|
||||||
nsm_parent_field = 'parent_account'
|
nsm_parent_field = 'parent_account'
|
||||||
|
|
||||||
@ -68,7 +70,7 @@ class Account(Document):
|
|||||||
# does not exists parent
|
# does not exists parent
|
||||||
if frappe.db.exists("Account", self.name):
|
if frappe.db.exists("Account", self.name):
|
||||||
if not frappe.db.get_value("Account", self.name, "parent_account"):
|
if not frappe.db.get_value("Account", self.name, "parent_account"):
|
||||||
throw(_("Root cannot be edited."))
|
throw(_("Root cannot be edited."), RootNotEditable)
|
||||||
|
|
||||||
def validate_frozen_accounts_modifier(self):
|
def validate_frozen_accounts_modifier(self):
|
||||||
old_value = frappe.db.get_value("Account", self.name, "freeze_account")
|
old_value = frappe.db.get_value("Account", self.name, "freeze_account")
|
||||||
|
|||||||
@ -72,8 +72,6 @@ def migrate_item_variants():
|
|||||||
for attribute, value in item_attributes:
|
for attribute, value in item_attributes:
|
||||||
attribute_value_options.setdefault(attribute, []).append(value)
|
attribute_value_options.setdefault(attribute, []).append(value)
|
||||||
|
|
||||||
save_attributes_in_template(item, attribute_value_options)
|
|
||||||
|
|
||||||
possible_combinations = get_possible_combinations(attribute_value_options)
|
possible_combinations = get_possible_combinations(attribute_value_options)
|
||||||
|
|
||||||
for variant in all_variants:
|
for variant in all_variants:
|
||||||
@ -89,6 +87,8 @@ def migrate_item_variants():
|
|||||||
save_attributes_in_variant(variant, combination)
|
save_attributes_in_variant(variant, combination)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
save_attributes_in_template(item, attribute_value_options)
|
||||||
|
|
||||||
frappe.delete_doc("DocType", "Item Variant")
|
frappe.delete_doc("DocType", "Item Variant")
|
||||||
|
|
||||||
def save_attributes_in_template(item, attribute_value_options):
|
def save_attributes_in_template(item, attribute_value_options):
|
||||||
|
|||||||
@ -15,6 +15,7 @@ from .default_website import website_maker
|
|||||||
import install_fixtures
|
import install_fixtures
|
||||||
from .sample_data import make_sample_data
|
from .sample_data import make_sample_data
|
||||||
from erpnext.accounts.utils import FiscalYearError
|
from erpnext.accounts.utils import FiscalYearError
|
||||||
|
from erpnext.accounts.doctype.account.account import RootNotEditable
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def setup_account(args=None):
|
def setup_account(args=None):
|
||||||
@ -303,6 +304,7 @@ def get_fy_details(fy_start_date, fy_end_date):
|
|||||||
return fy
|
return fy
|
||||||
|
|
||||||
def create_taxes(args):
|
def create_taxes(args):
|
||||||
|
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
if args.get("tax_" + str(i)):
|
if args.get("tax_" + str(i)):
|
||||||
# replace % in case someone also enters the % symbol
|
# replace % in case someone also enters the % symbol
|
||||||
@ -320,6 +322,9 @@ def create_taxes(args):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
except RootNotEditable, e:
|
||||||
|
pass
|
||||||
|
|
||||||
def make_tax_head(args, i, tax_group, tax_rate):
|
def make_tax_head(args, i, tax_group, tax_rate):
|
||||||
return frappe.get_doc({
|
return frappe.get_doc({
|
||||||
"doctype":"Account",
|
"doctype":"Account",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user