Example case of how to hook an autoname to a WebsiteGenerator

To state my problem case:

My Auto Name spec is Foobar-.# that corresponds to this [series] - Series by prefix (separated by a dot)

When Foobar is a subclass of Document, autoname generates Foobar-1 as expected.

But when Foobar is a subclass of WebsiteGenerator I get this stack trace:

frappe@erpnext:~/frappe-bench$ bench run-tests --doctype Foobar --test test_create_Foobar
E

ERROR: test_create_Foobar (newapp.new_app.doctype.foobar.test_foobar.TestFoobar)

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/newapp/newapp/new_app/doctype/foobar/test_foobar.py”, line 20, in test_create_Foobar
fb.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 184, in insert
self.set_new_name()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 322, in set_new_name
set_new_name(self)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/naming.py”, line 38, in set_new_name
doc.run_method(“autoname”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 651, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 858, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 841, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 645, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/website_generator.py”, line 26, in autoname
self.name = self.scrub(self.get(self.website.page_title_field or “title”))
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/website_generator.py”, line 53, in scrub
return cleanup_page_name(text).replace(‘_’, ‘-’)
AttributeError: ‘NoneType’ object has no attribute ‘replace’


Ran 1 test in 0.047s

FAILED (errors=1)
<unittest.runner.TextTestResult run=1 errors=1 failures=0>