[fix] Don't update the sales invoice number into the serial no if update stock is disabled in the invoice (#9593)
This commit is contained in:
parent
3e4bcfe2d8
commit
e5ca48a76a
@ -324,10 +324,12 @@ cur_frm.cscript.hide_fields = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
var item_fields_stock = ['batch_no', 'actual_batch_qty', 'actual_qty', 'expense_account',
|
||||
'warehouse', 'expense_account', 'quality_inspection']
|
||||
cur_frm.fields_dict['items'].grid.set_column_disp(item_fields_stock,
|
||||
(cint(doc.update_stock)==1 || cint(doc.is_return)==1 ? true : false));
|
||||
*/
|
||||
|
||||
// India related fields
|
||||
if (frappe.boot.sysdefaults.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);
|
||||
|
@ -131,6 +131,8 @@ class SalesInvoice(SellingController):
|
||||
if not self.is_return:
|
||||
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
|
||||
self.check_credit_limit()
|
||||
|
||||
if self.update_stock:
|
||||
self.update_serial_no()
|
||||
|
||||
if not cint(self.is_pos) == 1 and not self.is_return:
|
||||
@ -793,19 +795,18 @@ class SalesInvoice(SellingController):
|
||||
|
||||
def update_serial_no(self, in_cancel=False):
|
||||
""" update Sales Invoice refrence in Serial No """
|
||||
invoice = None if (in_cancel or self.is_return) else self.name
|
||||
if in_cancel and self.is_return:
|
||||
invoice = self.return_against
|
||||
|
||||
for item in self.items:
|
||||
if not item.serial_no:
|
||||
continue
|
||||
|
||||
serial_nos = ["'%s'"%serial_no for serial_no in item.serial_no.split("\n")]
|
||||
|
||||
frappe.db.sql(""" update `tabSerial No` set sales_invoice='{invoice}'
|
||||
where name in ({serial_nos})""".format(
|
||||
invoice='' if in_cancel else self.name,
|
||||
serial_nos=",".join(serial_nos)
|
||||
)
|
||||
)
|
||||
for serial_no in item.serial_no.split("\n"):
|
||||
sno = frappe.get_doc('Serial No', serial_no)
|
||||
sno.sales_invoice = invoice
|
||||
sno.db_update()
|
||||
|
||||
def validate_serial_numbers(self):
|
||||
"""
|
||||
|
@ -1423,7 +1423,7 @@
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "eval:doc.serial_no || doc.batch_no",
|
||||
"columns": 0,
|
||||
"depends_on": "eval: parent.update_stock",
|
||||
"depends_on": "",
|
||||
"fieldname": "warehouse_and_reference",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@ -2165,7 +2165,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-05-10 17:14:42.681757",
|
||||
"modified": "2017-07-03 19:34:14.820285",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Invoice Item",
|
||||
|
Loading…
x
Reference in New Issue
Block a user