Set po nos in DN and SI (#13290)

This commit is contained in:
Nabin Hait 2018-03-13 15:46:59 +05:30 committed by GitHub
parent 13460f023d
commit 96f4b22589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 13 deletions

View File

@ -687,12 +687,12 @@
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Customer's Purchase Order", "label": "Customer's Purchase Order",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 1,
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 1, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
@ -4683,7 +4683,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2018-01-12 15:19:54.711885", "modified": "2018-03-13 15:19:54.711885",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice", "name": "Sales Invoice",

View File

@ -38,6 +38,7 @@ class SellingController(StockController):
self.validate_max_discount() self.validate_max_discount()
self.validate_selling_price() self.validate_selling_price()
self.set_qty_as_per_stock_uom() self.set_qty_as_per_stock_uom()
self.set_po_nos()
check_active_sales_items(self) check_active_sales_items(self)
def set_missing_values(self, for_validate=False): def set_missing_values(self, for_validate=False):
@ -326,9 +327,16 @@ class SellingController(StockController):
"actual_qty": -1*flt(d.qty), "actual_qty": -1*flt(d.qty),
"incoming_rate": return_rate "incoming_rate": return_rate
})) }))
self.make_sl_entries(sl_entries) self.make_sl_entries(sl_entries)
def set_po_nos(self):
if self.doctype in ("Delivery Note", "Sales Invoice"):
ref_fieldname = "against_sales_order" if self.doctype == "Delivery Note" else "sales_order"
sales_orders = list(set([d.get(ref_fieldname) for d in self.items]))
if sales_orders:
po_nos = frappe.get_all('Sales Order', 'po_no', filters = {'name': ('in', sales_orders)})
self.po_no = ', '.join(list(set([d.po_no for d in po_nos if d.po_no])))
def check_active_sales_items(obj): def check_active_sales_items(obj):
for d in obj.get("items"): for d in obj.get("items"):
if d.item_code: if d.item_code:

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
import json import json
import frappe.utils import frappe.utils
from frappe.utils import cstr, flt, getdate, comma_and, cint, nowdate, add_days from frappe.utils import cstr, flt, getdate, comma_and, cint
from frappe import _ from frappe import _
from frappe.model.utils import get_fetch_values from frappe.model.utils import get_fetch_values
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
@ -477,13 +477,9 @@ def make_project(source_name, target_doc=None):
@frappe.whitelist() @frappe.whitelist()
def make_delivery_note(source_name, target_doc=None): def make_delivery_note(source_name, target_doc=None):
def set_missing_values(source, target): def set_missing_values(source, target):
so = [d.against_sales_order for d in target.items]
if so:
po_no_list = frappe.get_all('Sales Order', 'po_no', filters = {'name': ('in', so)})
target.po_no = ', '.join(d.po_no for d in po_no_list if d.po_no)
target.ignore_pricing_rule = 1 target.ignore_pricing_rule = 1
target.run_method("set_missing_values") target.run_method("set_missing_values")
target.run_method("set_po_nos")
target.run_method("calculate_taxes_and_totals") target.run_method("calculate_taxes_and_totals")
# set company address # set company address
@ -544,6 +540,7 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
target.ignore_pricing_rule = 1 target.ignore_pricing_rule = 1
target.flags.ignore_permissions = True target.flags.ignore_permissions = True
target.run_method("set_missing_values") target.run_method("set_missing_values")
target.run_method("set_po_nos")
target.run_method("calculate_taxes_and_totals") target.run_method("calculate_taxes_and_totals")
# set company address # set company address

View File

@ -508,14 +508,14 @@
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Customer's Purchase Order No", "label": "Customer's Purchase Order No",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 1,
"oldfieldname": "po_no", "oldfieldname": "po_no",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"print_width": "100px", "print_width": "100px",
"read_only": 1, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
@ -3701,7 +3701,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2018-01-12 15:27:44.471335", "modified": "2018-03-13 15:35:02.234116",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Delivery Note", "name": "Delivery Note",

View File

@ -387,6 +387,7 @@ def make_sales_invoice(source_name, target_doc=None):
target.is_pos = 0 target.is_pos = 0
target.ignore_pricing_rule = 1 target.ignore_pricing_rule = 1
target.run_method("set_missing_values") target.run_method("set_missing_values")
target.run_method("set_po_nos")
if len(target.get("items")) == 0: if len(target.get("items")) == 0:
frappe.throw(_("All these items have already been invoiced")) frappe.throw(_("All these items have already been invoiced"))