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

feat: Allow PI creation without PO #20864

Merged
merged 7 commits into from Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
Expand Up @@ -4,7 +4,7 @@

from __future__ import unicode_literals
import frappe, erpnext
from frappe.utils import cint, cstr, formatdate, flt, getdate, nowdate
from frappe.utils import cint, cstr, formatdate, flt, getdate, nowdate, get_link_to_form
from frappe import _, throw
import frappe.defaults

Expand Down Expand Up @@ -288,16 +288,26 @@ def set_against_expense_account(self):

def po_required(self):
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':

if frappe.get_value('Supplier', self.supplier, 'allow_purchase_invoice_creation_without_purchase_order'):
return

for d in self.get('items'):
if not d.purchase_order:
throw(_("As per the Buying Settings if Purchase Order Required == 'YES', then for creating Purchase Invoice, user need to create Purchase Order first for item {0}").format(d.item_code))
throw(_("""Purchase Order Required for item {0}
To submit the invoice without purchase order please set
{1} as {2} in {3}""").format(frappe.bold(d.item_code), frappe.bold('Purchase Order Required'),
marination marked this conversation as resolved.
Show resolved Hide resolved
frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings')))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_link_to_form ('Buying Settings', 'Buying Settings') works too


def pr_required(self):
stock_items = self.get_stock_items()
if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes':
for d in self.get('items'):
if not d.purchase_receipt and d.item_code in stock_items:
throw(_("As per the Buying Settings if Purchase Reciept Required == 'YES', then for creating Purchase Invoice, user need to create Purchase Receipt first for item {0}").format(d.item_code))
throw(_("""Purchase Receipt Required for item {0}
To submit the invoice without purchase receipt please set
{1} as {2} in {3}""").format(frappe.bold(d.item_code), frappe.bold('Purchase Receipt Required'),
marination marked this conversation as resolved.
Show resolved Hide resolved
frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings')))

def validate_write_off_account(self):
if self.write_off_amount and not self.write_off_account:
Expand Down
9 changes: 8 additions & 1 deletion erpnext/buying/doctype/supplier/supplier.json
Expand Up @@ -27,6 +27,7 @@
"supplier_type",
"pan",
"language",
"allow_purchase_invoice_creation_without_purchase_order",
"disabled",
"warn_rfqs",
"warn_pos",
Expand Down Expand Up @@ -364,13 +365,19 @@
"fieldname": "is_frozen",
"fieldtype": "Check",
"label": "Is Frozen"
},
{
"default": "0",
"fieldname": "allow_purchase_invoice_creation_without_purchase_order",
"fieldtype": "Check",
"label": "Allow Purchase Invoice creation without Purchase Order"
}
],
"icon": "fa fa-user",
"idx": 370,
"image_field": "image",
"links": [],
"modified": "2019-12-19 18:17:16.614567",
"modified": "2020-03-06 18:19:25.235183",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier",
Expand Down