Merge branch 'master' of github.com:webnotes/erpnext into custom_script_defer
This commit is contained in:
commit
f314051e30
@ -71,7 +71,8 @@ class DocType(BuyingController):
|
|||||||
self.validate_write_off_account()
|
self.validate_write_off_account()
|
||||||
self.update_raw_material_cost()
|
self.update_raw_material_cost()
|
||||||
self.update_valuation_rate("entries")
|
self.update_valuation_rate("entries")
|
||||||
self.validate_multiple_billing("Purchase Receipt", "pr_detail", "import_amount")
|
self.validate_multiple_billing("Purchase Receipt", "pr_detail", "import_amount",
|
||||||
|
"purchase_receipt_details")
|
||||||
|
|
||||||
def get_credit_to(self):
|
def get_credit_to(self):
|
||||||
acc_head = sql("""select name, credit_days from `tabAccount`
|
acc_head = sql("""select name, credit_days from `tabAccount`
|
||||||
|
@ -93,7 +93,8 @@ class DocType(SellingController):
|
|||||||
self.validate_c_form()
|
self.validate_c_form()
|
||||||
self.validate_time_logs_are_submitted()
|
self.validate_time_logs_are_submitted()
|
||||||
self.validate_recurring_invoice()
|
self.validate_recurring_invoice()
|
||||||
self.validate_multiple_billing("Delivery Note", "dn_detail", "export_amount")
|
self.validate_multiple_billing("Delivery Note", "dn_detail", "export_amount",
|
||||||
|
"delivery_note_details")
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if cint(self.doc.update_stock) == 1:
|
if cint(self.doc.update_stock) == 1:
|
||||||
@ -173,8 +174,8 @@ class DocType(SellingController):
|
|||||||
self.convert_to_recurring()
|
self.convert_to_recurring()
|
||||||
|
|
||||||
def set_missing_values(self, for_validate=False):
|
def set_missing_values(self, for_validate=False):
|
||||||
super(DocType, self).set_missing_values(for_validate)
|
|
||||||
self.set_pos_fields(for_validate)
|
self.set_pos_fields(for_validate)
|
||||||
|
super(DocType, self).set_missing_values(for_validate)
|
||||||
|
|
||||||
def set_customer_defaults(self):
|
def set_customer_defaults(self):
|
||||||
# TODO cleanup these methods
|
# TODO cleanup these methods
|
||||||
@ -215,6 +216,12 @@ class DocType(SellingController):
|
|||||||
"docstatus": ["!=", 2]
|
"docstatus": ["!=", 2]
|
||||||
}) or pos.customer_account
|
}) or pos.customer_account
|
||||||
|
|
||||||
|
if self.doc.debit_to and not self.doc.customer:
|
||||||
|
self.doc.customer = webnotes.conn.get_value("Account", {
|
||||||
|
"name": self.doc.debit_to,
|
||||||
|
"master_type": "Customer"
|
||||||
|
}, "master_name")
|
||||||
|
|
||||||
for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name',
|
for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name',
|
||||||
'price_list_name', 'company', 'select_print_heading', 'cash_bank_account'):
|
'price_list_name', 'company', 'select_print_heading', 'cash_bank_account'):
|
||||||
if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)):
|
if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)):
|
||||||
|
@ -382,18 +382,21 @@ class AccountsController(TransactionBase):
|
|||||||
"allocate_amount": 0
|
"allocate_amount": 0
|
||||||
})
|
})
|
||||||
|
|
||||||
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on):
|
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):
|
||||||
for item in self.doclist.get({"parentfield": "entries"}):
|
for item in self.doclist.get({"parentfield": "entries"}):
|
||||||
if item.fields.get(item_ref_dn):
|
if item.fields.get(item_ref_dn):
|
||||||
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
|
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
|
||||||
where %s=%s and docstatus=1""" % (based_on, self.tname, item_ref_dn, '%s'),
|
where %s=%s and docstatus=1""" % (based_on, self.tname, item_ref_dn, '%s'),
|
||||||
item.fields[item_ref_dn])[0][0]
|
item.fields[item_ref_dn])[0][0]
|
||||||
|
|
||||||
max_allowed_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
|
|
||||||
item.fields[item_ref_dn], based_on))
|
|
||||||
|
|
||||||
if max_allowed_amt and \
|
max_allowed_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
|
||||||
flt(already_billed) + flt(item.fields[based_on]) > max_allowed_amt:
|
item.fields[item_ref_dn], based_on), self.precision(based_on, item))
|
||||||
|
|
||||||
|
total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]),
|
||||||
|
self.precision(based_on, item))
|
||||||
|
webnotes.errprint([max_allowed_amt, total_billed_amt])
|
||||||
|
|
||||||
|
if max_allowed_amt and total_billed_amt - max_allowed_amt > 0.02:
|
||||||
webnotes.msgprint(_("Row ")+ cstr(item.idx) + ": " + cstr(item.item_code) +
|
webnotes.msgprint(_("Row ")+ cstr(item.idx) + ": " + cstr(item.item_code) +
|
||||||
_(" will be over-billed against mentioned ") + cstr(ref_dt) +
|
_(" will be over-billed against mentioned ") + cstr(ref_dt) +
|
||||||
_(". Max allowed " + cstr(based_on) + ": " + cstr(max_allowed_amt)),
|
_(". Max allowed " + cstr(based_on) + ": " + cstr(max_allowed_amt)),
|
||||||
|
@ -49,7 +49,7 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({
|
|||||||
erpnext.hide_naming_series();
|
erpnext.hide_naming_series();
|
||||||
erpnext.hide_company();
|
erpnext.hide_company();
|
||||||
this.show_item_wise_taxes();
|
this.show_item_wise_taxes();
|
||||||
this.frm.fields_dict.currency ? this.currency() : this.set_dynamic_labels();
|
this.set_dynamic_labels();
|
||||||
},
|
},
|
||||||
|
|
||||||
onload_post_render: function() {
|
onload_post_render: function() {
|
||||||
|
@ -190,7 +190,7 @@ def get_pos_settings(company):
|
|||||||
if not pos_settings:
|
if not pos_settings:
|
||||||
pos_settings = webnotes.conn.sql("""select * from `tabPOS Setting`
|
pos_settings = webnotes.conn.sql("""select * from `tabPOS Setting`
|
||||||
where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
|
where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
|
||||||
|
|
||||||
return pos_settings and pos_settings[0] or None
|
return pos_settings and pos_settings[0] or None
|
||||||
|
|
||||||
def apply_pos_settings(pos_settings, opts):
|
def apply_pos_settings(pos_settings, opts):
|
||||||
|
@ -114,7 +114,8 @@ class DocType(SellingController):
|
|||||||
|
|
||||||
def validate_with_previous_doc(self):
|
def validate_with_previous_doc(self):
|
||||||
prev_doctype = [d.prevdoc_doctype for d in self.doclist.get({
|
prev_doctype = [d.prevdoc_doctype for d in self.doclist.get({
|
||||||
"parentfield": "delivery_note_details", "prevdoc_doctype": ["!=", ""]})]
|
"parentfield": "delivery_note_details"}) if cstr(d.prevdoc_doctype) != ""]
|
||||||
|
|
||||||
if prev_doctype:
|
if prev_doctype:
|
||||||
super(DocType, self).validate_with_previous_doc(self.tname, {
|
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||||
prev_doctype[0]: {
|
prev_doctype[0]: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user