Repository: frappe/erpnext
Pull request: fix: price list when invoice created from timesheet
**Version 15**

fixes: #40921

**Before:**


https://github.com/frappe/erpnext/assets/141945075/7cf638f5-5874-44ae-b5d4-c0753d0badf6

<br>

**After:**


https://github.com/frappe/erpnext/assets/141945075/a1cfdf4e-d2ae-460c-ae43-b736ad173a67



Problem statement:
Wrong pricelist when invoice created from timesheet
### Information about bug

When an invoice is created from a timesheet, the pricelist for the invoice is set to the default price list instead of the price list defined in the customer.

Creating an invoice from scratch uses the correct price list for the customer.

### Module

selling, projects

### Version

ERPNext: v15.19.2 (version-15)
Frappe Framework: v15.20.0 (version-15)

### Installation method

easy-install

### Relevant log output / Stack trace / Full Error Message.

_No response_

Hints from issue discussion:

Commit message: fix: price list when invoice created from timesheet

Patch to review:
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index 90f436831f91..a625f9fee73a 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -389,6 +389,9 @@ def make_sales_invoice(source_name, item_code=None, customer=None, currency=None
 	target.project = timesheet.parent_project
 	if customer:
 		target.customer = customer
+		customer_doc = frappe.get_doc("Customer", customer)
+		if customer_doc and customer_doc.default_price_list:
+			target.selling_price_list = customer_doc.default_price_list
 
 	if currency:
 		target.currency = currency


Code review comments:
diff_hunk: @@ -389,6 +389,9 @@ def make_sales_invoice(source_name, item_code=None, customer=None, currency=None
 	target.project = timesheet.parent_project
 	if customer:
 		target.customer = customer
+		customer_doc = frappe.get_doc("Customer", customer)
path: erpnext/projects/doctype/timesheet/timesheet.py
text: @user1:
Use get_value instead of get_doc, get_doc is unnecessary