Merge pull request #16537 from nabinhait/stock-balance-fix
fix: Fixed error on stock balance report
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index d5f17c8..89ac6d9 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -5,7 +5,7 @@
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
-__version__ = '11.1.3'
+__version__ = '11.1.4'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index f2d5006..0dd716d 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -231,7 +231,7 @@
item.expense_account = warehouse_account[item.warehouse]["account"]
else:
item.expense_account = stock_not_billed_account
- elif item.is_fixed_asset and d.pr_detail:
+ elif item.is_fixed_asset and item.pr_detail:
item.expense_account = asset_received_but_not_billed
elif not item.expense_account and for_validate:
throw(_("Expense account is mandatory for item {0}").format(item.item_code or item.item_name))
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index e145a35..58e3e87 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -617,14 +617,14 @@
def get_outstanding_invoices(party_type, party, account, condition=None, limit=1000):
outstanding_invoices = []
- precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
+ precision = frappe.get_precision("Sales Invoice", "outstanding_amount") or 2
if erpnext.get_party_account_type(party_type) == 'Receivable':
dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
- payment_dr_or_cr = "payment_gl_entry.credit_in_account_currency - payment_gl_entry.debit_in_account_currency"
+ payment_dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
else:
dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
- payment_dr_or_cr = "payment_gl_entry.debit_in_account_currency - payment_gl_entry.credit_in_account_currency"
+ payment_dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
invoice = 'Sales Invoice' if erpnext.get_party_account_type(party_type) == 'Receivable' else 'Purchase Invoice'
held_invoices = get_held_invoices(party_type, party)
@@ -632,21 +632,9 @@
invoice_list = frappe.db.sql("""
select
- voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount,
- (
- select ifnull(sum({payment_dr_or_cr}), 0)
- from `tabGL Entry` payment_gl_entry
- where payment_gl_entry.against_voucher_type = invoice_gl_entry.voucher_type
- and if(invoice_gl_entry.voucher_type='Journal Entry',
- payment_gl_entry.against_voucher = invoice_gl_entry.voucher_no,
- payment_gl_entry.against_voucher = invoice_gl_entry.against_voucher)
- and payment_gl_entry.party_type = invoice_gl_entry.party_type
- and payment_gl_entry.party = invoice_gl_entry.party
- and payment_gl_entry.account = invoice_gl_entry.account
- and {payment_dr_or_cr} > 0
- ) as payment_amount
+ voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount
from
- `tabGL Entry` invoice_gl_entry
+ `tabGL Entry`
where
party_type = %(party_type)s and party = %(party)s
and account = %(account)s and {dr_or_cr} > 0
@@ -655,11 +643,9 @@
and (against_voucher = '' or against_voucher is null))
or (voucher_type not in ('Journal Entry', 'Payment Entry')))
group by voucher_type, voucher_no
- having (invoice_amount - payment_amount) > 0.005
order by posting_date, name {limit_cond}""".format(
dr_or_cr=dr_or_cr,
invoice = invoice,
- payment_dr_or_cr=payment_dr_or_cr,
condition=condition or "",
limit_cond = limit_cond
), {
@@ -668,25 +654,46 @@
"account": account,
}, as_dict=True)
- for d in invoice_list:
- if not d.voucher_type == "Purchase Invoice" or d.voucher_no not in held_invoices:
- due_date = frappe.db.get_value(
- d.voucher_type, d.voucher_no, "posting_date" if party_type == "Employee" else "due_date")
+ payment_entries = frappe.db.sql("""
+ select against_voucher_type, against_voucher,
+ ifnull(sum({payment_dr_or_cr}), 0) as payment_amount
+ from `tabGL Entry`
+ where party_type = %(party_type)s and party = %(party)s
+ and account = %(account)s
+ and {payment_dr_or_cr} > 0
+ and against_voucher is not null and against_voucher != ''
+ group by against_voucher_type, against_voucher
+ """.format(payment_dr_or_cr=payment_dr_or_cr), {
+ "party_type": party_type,
+ "party": party,
+ "account": account,
+ }, as_dict=True)
- outstanding_invoices.append(
- frappe._dict({
- 'voucher_no': d.voucher_no,
- 'voucher_type': d.voucher_type,
- 'posting_date': d.posting_date,
- 'invoice_amount': flt(d.invoice_amount),
- 'payment_amount': flt(d.payment_amount),
- 'outstanding_amount': flt(d.invoice_amount - d.payment_amount, precision),
- 'due_date': due_date
- })
- )
+ pe_map = frappe._dict()
+ for d in payment_entries:
+ pe_map.setdefault((d.against_voucher_type, d.against_voucher), d.payment_amount)
+
+ for d in invoice_list:
+ payment_amount = pe_map.get((d.voucher_type, d.voucher_no), 0)
+ outstanding_amount = flt(d.invoice_amount - payment_amount, precision)
+ if outstanding_amount > 0.5 / (10**precision):
+ if not d.voucher_type == "Purchase Invoice" or d.voucher_no not in held_invoices:
+ due_date = frappe.db.get_value(
+ d.voucher_type, d.voucher_no, "posting_date" if party_type == "Employee" else "due_date")
+
+ outstanding_invoices.append(
+ frappe._dict({
+ 'voucher_no': d.voucher_no,
+ 'voucher_type': d.voucher_type,
+ 'posting_date': d.posting_date,
+ 'invoice_amount': flt(d.invoice_amount),
+ 'payment_amount': payment_amount,
+ 'outstanding_amount': outstanding_amount,
+ 'due_date': due_date
+ })
+ )
outstanding_invoices = sorted(outstanding_invoices, key=lambda k: k['due_date'] or getdate(nowdate()))
-
return outstanding_invoices
@@ -859,5 +866,3 @@
def generator():
return cint(frappe.db.get_value('Accounts Settings', None, 'allow_cost_center_in_entry_of_bs_account'))
return frappe.local_cache("get_allow_cost_center_in_entry_of_bs_account", (), generator, regenerate_if_none=True)
-
-
diff --git a/erpnext/erpnext_integrations/doctype/woocommerce_settings/woocommerce_settings.py b/erpnext/erpnext_integrations/doctype/woocommerce_settings/woocommerce_settings.py
index bb4f62a..1edc102 100644
--- a/erpnext/erpnext_integrations/doctype/woocommerce_settings/woocommerce_settings.py
+++ b/erpnext/erpnext_integrations/doctype/woocommerce_settings/woocommerce_settings.py
@@ -28,7 +28,7 @@
if not frappe.get_value("Custom Field",{"name":i[0]}) or not frappe.get_value("Custom Field",{"name":i[1]}):
create_custom_field_id_and_check_status = True
- break;
+ break
if create_custom_field_id_and_check_status:
diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.js b/erpnext/hr/doctype/payroll_entry/payroll_entry.js
index fa1b63c..e4ab680 100644
--- a/erpnext/hr/doctype/payroll_entry/payroll_entry.js
+++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.js
@@ -95,6 +95,8 @@
},
setup: function (frm) {
+ frm.add_fetch('company', 'cost_center', 'cost_center');
+
frm.set_query("payment_account", function () {
var account_types = ["Bank", "Cash"];
return {
diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.json b/erpnext/hr/doctype/payroll_entry/payroll_entry.json
index a898f88..562b999 100644
--- a/erpnext/hr/doctype/payroll_entry/payroll_entry.json
+++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.json
@@ -1,5 +1,6 @@
{
"allow_copy": 1,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -861,7 +862,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "company.cost_center",
+ "default": ":Company",
+ "fetch_from": "",
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 0,
@@ -1189,7 +1191,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-08-21 16:15:45.276711",
+ "modified": "2019-02-05 10:41:08.865842",
"modified_by": "Administrator",
"module": "HR",
"name": "Payroll Entry",
diff --git a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py
index ada8e3d..3cf1322 100644
--- a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py
+++ b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py
@@ -21,6 +21,8 @@
make_earning_salary_component(setup=True)
make_deduction_salary_component(setup=True)
+ frappe.db.set_value("HR Settings", None, "email_salary_slip_to_employee", 0)
+
def test_payroll_entry(self): # pylint: disable=no-self-use
company = erpnext.get_default_company()
for data in frappe.get_all('Salary Component', fields = ["name"]):
diff --git a/erpnext/hr/doctype/salary_detail/salary_detail.json b/erpnext/hr/doctype/salary_detail/salary_detail.json
index bc9812c..0ec3cd6 100644
--- a/erpnext/hr/doctype/salary_detail/salary_detail.json
+++ b/erpnext/hr/doctype/salary_detail/salary_detail.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -348,7 +349,7 @@
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
@@ -417,7 +418,7 @@
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
@@ -692,7 +693,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2018-09-20 16:59:33.622652",
+ "modified": "2019-02-04 14:41:56.030991",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Detail",
diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.json b/erpnext/manufacturing/doctype/bom_item/bom_item.json
index 754540e..2258360 100644
--- a/erpnext/manufacturing/doctype/bom_item/bom_item.json
+++ b/erpnext/manufacturing/doctype/bom_item/bom_item.json
@@ -85,39 +85,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "operation",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Item operation",
- "length": 0,
- "no_copy": 0,
- "options": "Operation",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
- {
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
@@ -933,38 +900,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "allow_alternative_item",
- "fieldtype": "Check",
- "hidden": 1,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Allow Alternative Item",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
- {
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fetch_from": "item_code.include_item_in_manufacturing",
"fieldname": "include_item_in_manufacturing",
"fieldtype": "Check",
@@ -1115,4 +1050,4 @@
"track_changes": 0,
"track_seen": 0,
"track_views": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py
index 5343a28..5ed03be 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/job_card.py
@@ -57,7 +57,7 @@
.format(d.idx, d.item_code))
if self.get('operation') == d.operation:
- child = self.append('items', {
+ self.append('items', {
'item_code': d.item_code,
'source_warehouse': d.source_warehouse,
'uom': frappe.db.get_value("Item", d.item_code, 'stock_uom'),
@@ -108,6 +108,10 @@
if not self.items:
self.transferred_qty = self.for_quantity if self.docstatus == 1 else 0
+ doc = frappe.get_doc('Work Order', self.get('work_order'))
+ if doc.transfer_material_against == 'Work Order' or doc.skip_transfer:
+ return
+
if self.items:
self.transferred_qty = frappe.db.get_value('Stock Entry', {
'job_card': self.name,
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index 6c84ef1..d17adf6 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -567,7 +567,7 @@
else:
item_details = get_subitems(doc, data, item_details, bom_no, company,
include_non_stock_items, include_subcontracted_items, 1, planned_qty=planned_qty)
- else:
+ elif data.get('item_code'):
item_master = frappe.get_doc('Item', data['item_code']).as_dict()
purchase_uom = item_master.purchase_uom or item_master.stock_uom
conversion_factor = 0
diff --git a/erpnext/manufacturing/report/bom_stock_calculated/bom_stock_calculated.py b/erpnext/manufacturing/report/bom_stock_calculated/bom_stock_calculated.py
index 2d3d078..612f415 100644
--- a/erpnext/manufacturing/report/bom_stock_calculated/bom_stock_calculated.py
+++ b/erpnext/manufacturing/report/bom_stock_calculated/bom_stock_calculated.py
@@ -13,16 +13,16 @@
data = get_bom_stock(filters)
qty_to_make = filters.get("qty_to_make")
- for rows in data:
- item_map = get_item_details(rows[0])
- reqd_qty = qty_to_make * rows[3]
- last_pur_price = frappe.db.get_value("Item", rows[0], "last_purchase_rate")
- if rows[4] > 0:
- diff_qty = rows[4] - reqd_qty
- summ_data.append([rows[0], rows[1], item_map[rows[0]]["manufacturer"], item_map[rows[0]]["manufacturer_part_no"], rows[3], rows[4], reqd_qty, diff_qty, last_pur_price])
+ for row in data:
+ item_map = get_item_details(row.item_code)
+ reqd_qty = qty_to_make * row.actual_qty
+ last_pur_price = frappe.db.get_value("Item", row.item_code, "last_purchase_rate")
+ if row.to_build > 0:
+ diff_qty = row.to_build - reqd_qty
+ summ_data.append([row.item_code, row.description, item_map[row.item_code]["manufacturer"], item_map[row.item_code]["manufacturer_part_no"], row.actual_qty, row.to_build, reqd_qty, diff_qty, last_pur_price])
else:
diff_qty = 0 - reqd_qty
- summ_data.append([rows[0], rows[1], item_map[rows[0]]["manufacturer"], item_map[rows[0]]["manufacturer_part_no"], rows[3], "0.000", reqd_qty, diff_qty, last_pur_price])
+ summ_data.append([row.item_code, row.description, item_map[row.item_code]["manufacturer"], item_map[row.item_code]["manufacturer_part_no"], row.actual_qty, "0.000", reqd_qty, diff_qty, last_pur_price])
return columns, summ_data
@@ -72,8 +72,8 @@
bom_item.item_code,
bom_item.description,
bom_item.{qty_field},
- sum(ledger.actual_qty) as actual_qty,
- sum(FLOOR(ledger.actual_qty / bom_item.{qty_field}))as to_build
+ ifnull(sum(ledger.actual_qty), 0) as actual_qty,
+ ifnull(sum(FLOOR(ledger.actual_qty / bom_item.{qty_field})), 0) as to_build
FROM
{table} AS bom_item
LEFT JOIN `tabBin` AS ledger
@@ -83,7 +83,7 @@
WHERE
bom_item.parent = '{bom}' and bom_item.parenttype='BOM'
- GROUP BY bom_item.item_code""".format(qty_field=qty_field, table=table, conditions=conditions, bom=bom))
+ GROUP BY bom_item.item_code""".format(qty_field=qty_field, table=table, conditions=conditions, bom=bom), as_dict=1)
def get_item_details(item_code):
items = frappe.db.sql("""select it.item_group, it.item_name, it.stock_uom, it.name, it.brand, it.description, it.manufacturer_part_no, it.manufacturer from tabItem it where it.item_code = %s""", item_code, as_dict=1)
diff --git a/erpnext/patches/v11_0/create_salary_structure_assignments.py b/erpnext/patches/v11_0/create_salary_structure_assignments.py
index 2dab194..610fa85 100644
--- a/erpnext/patches/v11_0/create_salary_structure_assignments.py
+++ b/erpnext/patches/v11_0/create_salary_structure_assignments.py
@@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
from datetime import datetime
+from frappe.utils import getdate
from erpnext.hr.doctype.salary_structure_assignment.salary_structure_assignment import DuplicateAssignment
def execute():
@@ -31,14 +32,22 @@
where is_active='Yes'
AND employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')
""".format(cols), as_dict=1)
-
+
for d in ss_details:
try:
+ joining_date, relieving_date = frappe.db.get_value("Employee", d.employee,
+ ["date_of_joining", "relieving_date"])
+ from_date = d.from_date
+ if joining_date and getdate(from_date) < joining_date:
+ from_date = joining_date
+ elif relieving_date and getdate(from_date) > relieving_date:
+ continue
+
s = frappe.new_doc("Salary Structure Assignment")
s.employee = d.employee
s.employee_name = d.employee_name
s.salary_structure = d.salary_structure
- s.from_date = d.from_date
+ s.from_date = from_date
s.to_date = d.to_date if isinstance(d.to_date, datetime) else None
s.base = d.get("base")
s.variable = d.get("variable")
diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py
index dcf485a..3b42f6a6 100644
--- a/erpnext/projects/doctype/project/project.py
+++ b/erpnext/projects/doctype/project/project.py
@@ -459,7 +459,7 @@
fields.extend(["name"])
return frappe.get_all("Project", fields = fields,
- filters = {'collect_progress': 1, 'frequency': frequency})
+ filters = {'collect_progress': 1, 'frequency': frequency, 'status': 'Open'})
def send_project_update_email_to_users(project):
doc = frappe.get_doc('Project', project)
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 20e1098..3751d7b 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -314,8 +314,9 @@
show_description(child.idx, r.message.item_code, child.item_code);
frappe.model.set_value(child.doctype, child.name, {
- "item_code": r.message.item_code,
- "qty": (child.qty || 0) + 1
+ item_code: r.message.item_code,
+ qty: (child.qty || 0) + 1,
+ barcode: r.message.barcode
});
}
else{
diff --git a/erpnext/public/js/hub/pages/Item.vue b/erpnext/public/js/hub/pages/Item.vue
index 7735aa2..8dbd397 100644
--- a/erpnext/public/js/hub/pages/Item.vue
+++ b/erpnext/public/js/hub/pages/Item.vue
@@ -53,7 +53,20 @@
image: null,
sections: [],
- menu_items: [
+ };
+ },
+ computed: {
+ is_own_item() {
+ let is_own_item = false;
+ if(this.item) {
+ if(this.item.hub_seller === hub.settings.hub_seller_name) {
+ is_own_item = true;
+ }
+ }
+ return is_own_item;
+ },
+ menu_items(){
+ return [
{
label: __('Save Item'),
condition: hub.is_user_registered() && !this.is_own_item,
@@ -75,17 +88,6 @@
action: this.unpublish_item
}
]
- };
- },
- computed: {
- is_own_item() {
- let is_own_item = false;
- if(this.item) {
- if(this.item.hub_seller === hub.settings.hub_seller_name) {
- is_own_item = true;
- }
- }
- return is_own_item;
},
item_subtitle() {
@@ -272,11 +274,11 @@
},
edit_details() {
- //
+ frappe.msgprint(__('This feature is under development...'));
},
unpublish_item() {
- //
+ frappe.msgprint(__('This feature is under development...'));
}
}
}
diff --git a/erpnext/stock/dashboard/item_dashboard.py b/erpnext/stock/dashboard/item_dashboard.py
index d817e5f..6242fa7 100644
--- a/erpnext/stock/dashboard/item_dashboard.py
+++ b/erpnext/stock/dashboard/item_dashboard.py
@@ -13,7 +13,13 @@
if warehouse:
filters.append(['warehouse', '=', warehouse])
if item_group:
- filters.append(['item_group', '=', item_group])
+ lft, rgt = frappe.db.get_value("Item Group", item_group, ["lft", "rgt"])
+ items = frappe.db.sql_list("""
+ select i.name from `tabItem` i
+ where exists(select name from `tabItem Group`
+ where name=i.item_group and lft >=%s and rgt<=%s)
+ """, (lft, rgt))
+ filters.append(['item_code', 'in', items])
try:
# check if user has any restrictions based on user permissions on warehouse
if DatabaseQuery('Warehouse', user=frappe.session.user).build_match_conditions():
diff --git a/erpnext/templates/pages/non_profit/join-chapter.html b/erpnext/templates/pages/non_profit/join-chapter.html
index 029cd77..89a7d2a 100644
--- a/erpnext/templates/pages/non_profit/join-chapter.html
+++ b/erpnext/templates/pages/non_profit/join-chapter.html
@@ -15,7 +15,7 @@
{{ chapter_button() }}
<p><a href="">Leave Chapter</a></p>
{% else %}
- {% if frappe.local.request.method=='POST' %}
+ {% if request.method=='POST' %}
<p>Welcome to chapter {{ chapter.name }}!</p>
{{ chapter_button() }}
{% else %}