mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 21:29:11 +00:00
Group same item in SO print (#6959)
This commit is contained in:
committed by
Rushabh Mehta
parent
dc2195c52a
commit
49a50fef63
@@ -156,30 +156,6 @@ class PurchaseOrder(BuyingController):
|
|||||||
msgprint(_("{0} {1} has been modified. Please refresh.").format(self.doctype, self.name),
|
msgprint(_("{0} {1} has been modified. Please refresh.").format(self.doctype, self.name),
|
||||||
raise_exception=True)
|
raise_exception=True)
|
||||||
|
|
||||||
def before_print(self):
|
|
||||||
if self.get("group_same_items"):
|
|
||||||
|
|
||||||
group_item_qty = {}
|
|
||||||
group_item_amount = {}
|
|
||||||
|
|
||||||
for item in self.items:
|
|
||||||
group_item_qty[item.item_code] = group_item_qty.get(item.item_code, 0) + item.qty
|
|
||||||
group_item_amount[item.item_code] = group_item_amount.get(item.item_code, 0) + item.amount
|
|
||||||
|
|
||||||
duplicate_list = []
|
|
||||||
|
|
||||||
for item in self.items:
|
|
||||||
if item.item_code in group_item_qty:
|
|
||||||
item.qty = group_item_qty[item.item_code]
|
|
||||||
item.amount = group_item_amount[item.item_code]
|
|
||||||
del group_item_qty[item.item_code]
|
|
||||||
else:
|
|
||||||
duplicate_list.append(item)
|
|
||||||
|
|
||||||
for item in duplicate_list:
|
|
||||||
self.remove(item)
|
|
||||||
|
|
||||||
|
|
||||||
def update_status(self, status):
|
def update_status(self, status):
|
||||||
self.check_modified_date()
|
self.check_modified_date()
|
||||||
self.set_status(update=True, status=status)
|
self.set_status(update=True, status=status)
|
||||||
@@ -380,4 +356,3 @@ def update_status(status, name):
|
|||||||
po = frappe.get_doc("Purchase Order", name)
|
po = frappe.get_doc("Purchase Order", name)
|
||||||
po.update_status(status)
|
po.update_status(status)
|
||||||
po.update_delivered_qty_in_sales_order()
|
po.update_delivered_qty_in_sales_order()
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ class AccountsController(TransactionBase):
|
|||||||
if self.doctype == 'Purchase Invoice':
|
if self.doctype == 'Purchase Invoice':
|
||||||
self.validate_paid_amount()
|
self.validate_paid_amount()
|
||||||
|
|
||||||
|
def before_print(self):
|
||||||
|
if self.doctype in ['Purchase Order', 'Sales Order']:
|
||||||
|
if self.get("group_same_items"):
|
||||||
|
self.group_similar_items()
|
||||||
|
|
||||||
def validate_paid_amount(self):
|
def validate_paid_amount(self):
|
||||||
if hasattr(self, "is_pos") or hasattr(self, "is_paid"):
|
if hasattr(self, "is_pos") or hasattr(self, "is_paid"):
|
||||||
is_paid = self.get("is_pos") or self.get("is_paid")
|
is_paid = self.get("is_pos") or self.get("is_paid")
|
||||||
@@ -561,6 +566,28 @@ class AccountsController(TransactionBase):
|
|||||||
frappe.throw(_("Row #{0}: Asset {1} cannot be submitted, it is already {2}")
|
frappe.throw(_("Row #{0}: Asset {1} cannot be submitted, it is already {2}")
|
||||||
.format(d.idx, d.asset, asset.status))
|
.format(d.idx, d.asset, asset.status))
|
||||||
|
|
||||||
|
def group_similar_items(self):
|
||||||
|
group_item_qty = {}
|
||||||
|
group_item_amount = {}
|
||||||
|
|
||||||
|
for item in self.items:
|
||||||
|
group_item_qty[item.item_code] = group_item_qty.get(item.item_code, 0) + item.qty
|
||||||
|
group_item_amount[item.item_code] = group_item_amount.get(item.item_code, 0) + item.amount
|
||||||
|
|
||||||
|
duplicate_list = []
|
||||||
|
|
||||||
|
for item in self.items:
|
||||||
|
if item.item_code in group_item_qty:
|
||||||
|
item.qty = group_item_qty[item.item_code]
|
||||||
|
item.amount = group_item_amount[item.item_code]
|
||||||
|
del group_item_qty[item.item_code]
|
||||||
|
else:
|
||||||
|
duplicate_list.append(item)
|
||||||
|
|
||||||
|
for item in duplicate_list:
|
||||||
|
self.remove(item)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_tax_rate(account_head):
|
def get_tax_rate(account_head):
|
||||||
return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True)
|
return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True)
|
||||||
|
|||||||
@@ -2479,6 +2479,34 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "group_same_items",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Group same items",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@@ -3341,7 +3369,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-11-14 16:07:45.817880",
|
"modified": "2016-11-16 04:06:28.675876",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Sales Order",
|
"name": "Sales Order",
|
||||||
|
|||||||
Reference in New Issue
Block a user