Skip to content

Commit

Permalink
Merge pull request #30634 from resilient-tech/fix-mutable-reassignment
Browse files Browse the repository at this point in the history
fix: dont reassign mutable (list) to a different field
  • Loading branch information
sagarvora authored Apr 7, 2022
2 parents 18b1a93 + 3b4754f commit 26abfd4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
18 changes: 9 additions & 9 deletions erpnext/accounts/report/purchase_register/purchase_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,10 @@ def get_columns(invoice_list, additional_table_columns):
_("Purchase Receipt") + ":Link/Purchase Receipt:100",
{"fieldname": "currency", "label": _("Currency"), "fieldtype": "Data", "width": 80},
]
expense_accounts = (
tax_accounts
) = (
expense_columns
) = tax_columns = unrealized_profit_loss_accounts = unrealized_profit_loss_account_columns = []

expense_accounts = []
tax_accounts = []
unrealized_profit_loss_accounts = []

if invoice_list:
expense_accounts = frappe.db.sql_list(
Expand Down Expand Up @@ -163,10 +162,11 @@ def get_columns(invoice_list, additional_table_columns):
unrealized_profit_loss_account_columns = [
(account + ":Currency/currency:120") for account in unrealized_profit_loss_accounts
]

for account in tax_accounts:
if account not in expense_accounts:
tax_columns.append(account + ":Currency/currency:120")
tax_columns = [
(account + ":Currency/currency:120")
for account in tax_accounts
if account not in expense_accounts
]

columns = (
columns
Expand Down
3 changes: 2 additions & 1 deletion erpnext/crm/doctype/opportunity/opportunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def make_new_lead_if_required(self):
def declare_enquiry_lost(self, lost_reasons_list, competitors, detailed_reason=None):
if not self.has_active_quotation():
self.status = "Lost"
self.lost_reasons = self.competitors = []
self.lost_reasons = []
self.competitors = []

if detailed_reason:
self.order_lost_reason = detailed_reason
Expand Down
3 changes: 2 additions & 1 deletion erpnext/selling/doctype/customer/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def validate(self):
@frappe.whitelist()
def get_customer_group_details(self):
doc = frappe.get_doc("Customer Group", self.customer_group)
self.accounts = self.credit_limits = []
self.accounts = []
self.credit_limits = []
self.payment_terms = self.default_price_list = ""

tables = [["accounts", "account"], ["credit_limits", "credit_limit"]]
Expand Down
3 changes: 2 additions & 1 deletion erpnext/selling/doctype/customer/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def test_get_customer_group_details(self):
c_doc.customer_name = "Testing Customer"
c_doc.customer_group = "_Testing Customer Group"
c_doc.payment_terms = c_doc.default_price_list = ""
c_doc.accounts = c_doc.credit_limits = []
c_doc.accounts = []
c_doc.credit_limits = []
c_doc.insert()
c_doc.get_customer_group_details()
self.assertEqual(c_doc.payment_terms, "_Test Payment Term Template 3")
Expand Down

0 comments on commit 26abfd4

Please sign in to comment.