Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: customer group and territory not mandatory #37050

Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,25 @@ def make_company():
return company


def make_customer(customer=None):
def make_customer(customer=None, without_customer_group=False):
customer_name = customer or "Opening Customer"
customer = frappe.get_doc(
{
"doctype": "Customer",
"customer_name": customer_name,
"customer_group": "All Customer Groups",
"customer_type": "Company",
"territory": "All Territories",
}
)
if not without_customer_group:
customer.customer_group = "All Customer Groups"

if not frappe.db.exists("Customer", customer_name):
customer.insert(ignore_permissions=True)
return customer.name
else:
return frappe.db.exists("Customer", customer_name)


def make_customer_without_customer_group(customer=None):
return make_customer(customer, without_customer_group=True)
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,24 @@ def test_offsetting_entries_for_accounting_dimensions(self):
clear_dimension_defaults("Branch")
disable_dimension()

def test_purchase_invoice_without_supplier_group(self):
# create a supplier
supplier = create_supplier(
supplier_name="_Test Supplier Without Group", without_supplier_group=True
).name

po = create_purchase_order(
supplier=supplier,
rate=3000,
item="_Test Non Stock Item",
posting_date="2021-09-15",
)

pi = make_purchase_invoice(supplier=supplier)

self.assertEqual(po.docstatus, 1)
self.assertEqual(pi.docstatus, 1)


def set_advance_flag(company, flag, default_account):
frappe.db.set_value(
Expand Down
15 changes: 15 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3400,6 +3400,21 @@ def test_advance_entries_as_liability(self):

set_advance_flag(company="_Test Company", flag=0, default_account="")

def test_sales_invoice_with_customer_without_group(self):

from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import (
make_customer_without_customer_group,
)

# create a customer
customer = make_customer_without_customer_group(
customer="_Test Customer Without Customer Group "
)

# create a sales invoice
si = create_sales_invoice(customer=customer)
self.assertEqual(si.docstatus, 1)

@change_settings("Selling Settings", {"allow_negative_rates_for_items": 0})
def test_sales_return_negative_rate(self):
si = create_sales_invoice(is_return=1, qty=-2, rate=-10, do_not_save=True)
Expand Down
5 changes: 2 additions & 3 deletions erpnext/buying/doctype/supplier/supplier.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@
"label": "Supplier Group",
"oldfieldname": "supplier_type",
"oldfieldtype": "Link",
"options": "Supplier Group",
"reqd": 1
"options": "Supplier Group"
},
{
"default": "Company",
Expand Down Expand Up @@ -486,7 +485,7 @@
"link_fieldname": "party"
}
],
"modified": "2023-09-21 12:24:20.398889",
"modified": "2023-09-25 12:48:21.869563",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier",
Expand Down
7 changes: 5 additions & 2 deletions erpnext/buying/doctype/supplier/test_supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,14 @@ def create_supplier(**args):
"doctype": "Supplier",
"supplier_name": args.supplier_name,
"default_currency": args.default_currency,
"supplier_group": args.supplier_group or "Services",
"supplier_type": args.supplier_type or "Company",
"tax_withholding_category": args.tax_withholding_category,
}
).insert()
)
if not args.without_supplier_group:
doc.supplier_group = args.supplier_group or "Services"

doc.insert()

return doc

Expand Down
4 changes: 1 addition & 3 deletions erpnext/selling/doctype/customer/customer.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"oldfieldname": "customer_group",
"oldfieldtype": "Link",
"options": "Customer Group",
"reqd": 1,
"search_index": 1
},
{
Expand All @@ -193,8 +192,7 @@
"oldfieldname": "territory",
"oldfieldtype": "Link",
"options": "Territory",
"print_hide": 1,
"reqd": 1
"print_hide": 1
},
{
"fieldname": "tax_id",
Expand Down