Merge pull request #8015 from rohitwaghchaure/gross_profit_issue
[fix] Gross profit report permission issue
This commit is contained in:
commit
f86d73fdc8
@ -5,6 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
from frappe import _, scrub
|
||||||
from erpnext.stock.utils import get_incoming_rate
|
from erpnext.stock.utils import get_incoming_rate
|
||||||
|
from erpnext.controllers.queries import get_match_cond
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
|
|
||||||
@ -251,28 +252,29 @@ class GrossProfitGenerator(object):
|
|||||||
|
|
||||||
if self.filters.group_by=="Sales Person":
|
if self.filters.group_by=="Sales Person":
|
||||||
sales_person_cols = ", sales.sales_person, sales.allocated_amount, sales.incentives"
|
sales_person_cols = ", sales.sales_person, sales.allocated_amount, sales.incentives"
|
||||||
sales_team_table = "left join `tabSales Team` sales on sales.parent = si.name"
|
sales_team_table = "left join `tabSales Team` sales on sales.parent = `tabSales Invoice`.name"
|
||||||
else:
|
else:
|
||||||
sales_person_cols = ""
|
sales_person_cols = ""
|
||||||
sales_team_table = ""
|
sales_team_table = ""
|
||||||
|
|
||||||
self.si_list = frappe.db.sql("""select item.parenttype, item.parent,
|
self.si_list = frappe.db.sql("""select `tabSales Invoice Item`.parenttype, `tabSales Invoice Item`.parent,
|
||||||
si.posting_date, si.posting_time, si.project, si.update_stock,
|
`tabSales Invoice`.posting_date, `tabSales Invoice`.posting_time, `tabSales Invoice`.project, `tabSales Invoice`.update_stock,
|
||||||
si.customer, si.customer_group, si.territory,
|
`tabSales Invoice`.customer, `tabSales Invoice`.customer_group, `tabSales Invoice`.territory,
|
||||||
item.item_code, item.item_name, item.description, item.warehouse,
|
`tabSales Invoice Item`.item_code, `tabSales Invoice Item`.item_name, `tabSales Invoice Item`.description,
|
||||||
item.item_group, item.brand, item.dn_detail, item.delivery_note,
|
`tabSales Invoice Item`.warehouse, `tabSales Invoice Item`.item_group, `tabSales Invoice Item`.brand,
|
||||||
item.stock_qty as qty, item.base_net_rate, item.base_net_amount, item.name as "item_row"
|
`tabSales Invoice Item`.dn_detail, `tabSales Invoice Item`.delivery_note, `tabSales Invoice Item`.stock_qty as qty,
|
||||||
|
`tabSales Invoice Item`.base_net_rate, `tabSales Invoice Item`.base_net_amount, `tabSales Invoice Item`.name as "item_row"
|
||||||
{sales_person_cols}
|
{sales_person_cols}
|
||||||
from
|
from
|
||||||
`tabSales Invoice` si
|
`tabSales Invoice`
|
||||||
inner join `tabSales Invoice Item` item on item.parent = si.name
|
inner join `tabSales Invoice Item` on `tabSales Invoice Item`.parent = `tabSales Invoice`.name
|
||||||
{sales_team_table}
|
{sales_team_table}
|
||||||
where
|
where
|
||||||
si.docstatus = 1 and si.is_return != 1 {conditions}
|
`tabSales Invoice`.docstatus = 1 and `tabSales Invoice`.is_return != 1 {conditions} {match_cond}
|
||||||
order by
|
order by
|
||||||
si.posting_date desc, si.posting_time desc"""
|
`tabSales Invoice`.posting_date desc, `tabSales Invoice`.posting_time desc"""
|
||||||
.format(conditions=conditions, sales_person_cols=sales_person_cols,
|
.format(conditions=conditions, sales_person_cols=sales_person_cols,
|
||||||
sales_team_table=sales_team_table), self.filters, as_dict=1)
|
sales_team_table=sales_team_table, match_cond = get_match_cond('Sales Invoice')), self.filters, as_dict=1)
|
||||||
|
|
||||||
def load_stock_ledger_entries(self):
|
def load_stock_ledger_entries(self):
|
||||||
res = frappe.db.sql("""select item_code, voucher_type, voucher_no,
|
res = frappe.db.sql("""select item_code, voucher_type, voucher_no,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user