'Create a new website page, and assign it a xmlid based on the given one
:param name : the name of the page
:param template : potential xml_id of the page to create'

@api.model
def new_page(self, name, template='website.default_page', ispage=True):

    (template_module, dummy) = template.split('.')
    website_id = self._context.get('website_id')
    page_name = slugify(name, max_length=50)
    page_xmlid = ('%s.%s' % (template_module, page_name))
    inc = 0
    domain_static = [('website_id', '=', False), ('website_id', '=', website_id)]
    while self.env['ir.ui.view'].with_context(active_test=False).sudo().search(([('key', '=', page_xmlid), '|'] + domain_static)):
        inc += 1
        page_xmlid = ('%s.%s' % (template_module, (page_name + (('-%s' % inc) if inc else ''))))
    page_name += ((inc and ('-%s' % inc)) or '')
    template_record = self.env.ref(template)
    key = ('%s.%s' % (template_module, page_name))
    page = template_record.copy({'website_id': website_id, 'key': key})
    page.with_context(lang=None).write({'arch': page.arch.replace(template, page_xmlid), 'name': page_name, 'page': ispage})
    return page_xmlid
