Merge branch 'master' into edge
This commit is contained in:
commit
071a1f548a
@ -34,11 +34,11 @@ class DocType:
|
||||
for d in getlist(self.doclist, 'invoice_details'):
|
||||
if d.invoice_no:
|
||||
inv = webnotes.conn.sql("""select c_form_applicable, c_form_no from
|
||||
`tabSales Invoice` where name = %s""", d.invoice_no)
|
||||
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
|
||||
|
||||
if not inv:
|
||||
webnotes.msgprint("Invoice: %s is not exists in the system, please check." %
|
||||
d.invoice_no, raise_exception=1)
|
||||
webnotes.msgprint("""Invoice: %s is not exists in the system or
|
||||
is not submitted, please check.""" % d.invoice_no, raise_exception=1)
|
||||
|
||||
elif inv[0][0] != 'Yes':
|
||||
webnotes.msgprint("C-form is not applicable for Invoice: %s" %
|
||||
@ -52,21 +52,30 @@ class DocType:
|
||||
|
||||
def on_update(self):
|
||||
""" Update C-Form No on invoices"""
|
||||
self.set_total_invoiced_amount()
|
||||
|
||||
def on_submit(self):
|
||||
self.set_cform_in_sales_invoices()
|
||||
|
||||
def before_cancel(self):
|
||||
# remove cform reference
|
||||
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no=null
|
||||
where c_form_no=%s""", self.doc.name)
|
||||
|
||||
def set_cform_in_sales_invoices(self):
|
||||
inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')]
|
||||
if inv:
|
||||
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s
|
||||
where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))),
|
||||
tuple([self.doc.name, self.doc.modified] + inv))
|
||||
|
||||
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no = '', modified = %s
|
||||
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s
|
||||
where name not in (%s) and ifnull(c_form_no, '') = %s""" %
|
||||
('%s', ', '.join(['%s']*len(inv)), '%s'),
|
||||
tuple([self.doc.modified] + inv + [self.doc.name]))
|
||||
else:
|
||||
webnotes.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1)
|
||||
|
||||
self.set_total_invoiced_amount()
|
||||
|
||||
def set_total_invoiced_amount(self):
|
||||
total = sum([flt(d.grand_total) for d in getlist(self.doclist, 'invoice_details')])
|
||||
webnotes.conn.set(self.doc, 'total_invoiced_amount', total)
|
||||
|
6
patches/march_2013/p01_c_form.py
Normal file
6
patches/march_2013/p01_c_form.py
Normal file
@ -0,0 +1,6 @@
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
for cform in webnotes.conn.sql("""select name from `tabC-Form` where docstatus=2"""):
|
||||
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no=null
|
||||
where c_form_no=%s""", cform[0])
|
@ -204,4 +204,5 @@ patch_list = [
|
||||
"patches.march_2013.update_po_prevdoc_doctype",
|
||||
"patches.february_2013.p09_timesheets",
|
||||
"execute:(not webnotes.conn.exists('UOM', 'Hour')) and webnotes.doc({'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'}).insert()",
|
||||
"patches.march_2013.p01_c_form"
|
||||
]
|
Loading…
Reference in New Issue
Block a user