Example #1
0
    def before_rename(self, old, new, merge=False):
        # Add company abbr if not provided
        from setup.doctype.company.company import get_name_with_abbr
        new_account = get_name_with_abbr(new, self.doc.company)

        # Validate properties before merging
        if merge:
            if not webnotes.conn.exists("Account", new):
                webnotes.throw(_("Account ") + new + _(" does not exists"))

            val = list(
                webnotes.conn.get_value(
                    "Account", new_account,
                    ["group_or_ledger", "debit_or_credit", "is_pl_account"]))

            if val != [
                    self.doc.group_or_ledger, self.doc.debit_or_credit,
                    self.doc.is_pl_account
            ]:
                webnotes.throw(
                    _("""Merging is only possible if following \
					properties are same in both records.
					Group or Ledger, Debit or Credit, Is PL Account"""))

        return new_account
Example #2
0
	def before_rename(self, olddn, newdn, merge=False):
		# Add company abbr if not provided
		from setup.doctype.company.company import get_name_with_abbr
		new_cost_center = get_name_with_abbr(newdn, self.doc.company)
		
		# Validate properties before merging
		super(DocType, self).before_rename(olddn, new_cost_center, merge, "group_or_ledger")
		
		return new_cost_center
Example #3
0
    def before_rename(self, olddn, newdn, merge=False):
        # Add company abbr if not provided
        from setup.doctype.company.company import get_name_with_abbr
        new_cost_center = get_name_with_abbr(newdn, self.doc.company)

        # Validate properties before merging
        super(DocType, self).before_rename(olddn, new_cost_center, merge,
                                           "group_or_ledger")

        return new_cost_center
Example #4
0
	def before_rename(self, olddn, newdn, merge=False):
		# Add company abbr if not provided
		from setup.doctype.company.company import get_name_with_abbr
		new_warehouse = get_name_with_abbr(newdn, self.doc.company)

		if merge:
			if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"):
				webnotes.throw(_("Both Warehouse must belong to same Company"))
				
			webnotes.conn.sql("delete from `tabBin` where warehouse=%s", olddn)
			
		self.rename_account(olddn, new_warehouse, merge)

		return new_warehouse
Example #5
0
    def before_rename(self, olddn, newdn, merge=False):
        # Add company abbr if not provided
        from setup.doctype.company.company import get_name_with_abbr
        new_warehouse = get_name_with_abbr(newdn, self.doc.company)

        if merge:
            if self.doc.company != webnotes.conn.get_value(
                    "Warehouse", new_warehouse, "company"):
                webnotes.throw(_("Both Warehouse must belong to same Company"))

            webnotes.conn.sql("delete from `tabBin` where warehouse=%s", olddn)

        from accounts.utils import rename_account_for
        rename_account_for("Warehouse", olddn, new_warehouse, merge)

        return new_warehouse
Example #6
0
	def before_rename(self, old, new, merge=False):
		# Add company abbr if not provided
		from setup.doctype.company.company import get_name_with_abbr
		new_account = get_name_with_abbr(new, self.doc.company)
		
		# Validate properties before merging
		if merge:
			val = list(webnotes.conn.get_value("Account", new_account, 
				["group_or_ledger", "debit_or_credit", "is_pl_account"]))
			
			if val != [self.doc.group_or_ledger, self.doc.debit_or_credit, self.doc.is_pl_account]:
				webnotes.throw(_("""Merging is only possible if following \
					properties are same in both records.
					Group or Ledger, Debit or Credit, Is PL Account"""))
					
		return new_account
Example #7
0
def add_abbr_if_missing(dn, company):
	from setup.doctype.company.company import get_name_with_abbr
	return get_name_with_abbr(dn, company)