Index: main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py	(revision 11596)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py	(revision 11597)
@@ -19,7 +19,8 @@
 from zope.i18n import translate
 from zope.component import getUtility
+from waeup.kofa.browser.layout import UtilityView
 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
 from waeup.kofa.interfaces import IKofaUtils
-from waeup.kofa.students.interfaces import IStudentsUtils
+from waeup.kofa.students.interfaces import IStudentsUtils, IStudent
 from waeup.kofa.students.browser import (
     StudentBasePDFFormPage,
@@ -188,2 +189,22 @@
             'waeup.kofa', target_language=portal_language) \
             + ' %s' % self.context.display_fullname
+
+class StudentGetMatricNumberPage(UtilityView, grok.View):
+    """ Construct and set the matriculation number.
+    """
+    grok.context(IStudent)
+    grok.name('get_matric_number')
+    grok.require('waeup.viewStudent')
+
+    def update(self):
+        students_utils = getUtility(IStudentsUtils)
+        msg, mnumber = students_utils.setMatricNumber(self.context)
+        if msg:
+            self.flash(msg, type="danger")
+        else:
+            self.flash(_('Matriculation number %s assigned.' % mnumber))
+        self.redirect(self.url(self.context))
+        return
+
+    def render(self):
+        return
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 11596)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 11597)
@@ -18,4 +18,6 @@
 import shutil
 import tempfile
+import grok
+from mechanize import LinkNotFoundError
 from hurry.workflow.interfaces import IWorkflowState
 from zope.component.hooks import setSite, clearSite
@@ -332,3 +334,27 @@
         return
 
-
+    def test_set_matric_number(self):
+        # Login as student
+        self.browser.open(self.login_path)
+        #IWorkflowState(self.student).setState('school fee paid')
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = self.student_id
+        self.browser.getControl(name="form.password").value = 'spwd'
+        self.browser.getControl("Login").click()
+        self.assertRaises(
+            LinkNotFoundError,
+            self.browser.getLink, 'Get Matriculation Number')
+        self.student.matric_number = None
+        site = grok.getSite()
+        site['configuration'].next_matric_integer = 1
+        self.student['studycourse'].certificate.study_mode = 'ug_pt'
+        self.browser.open(self.student_path)
+        self.browser.getLink("Get Matriculation Number").click()
+        self.assertTrue('Matriculation number PTP/fac1/dep1/04/00001 assigned.'
+            in self.browser.contents)
+        self.assertEqual(self.student.matric_number, 'PTP/fac1/dep1/04/00001')
+        self.assertRaises(
+            LinkNotFoundError,
+            self.browser.getLink, 'Get Matriculation Number')
+        return
+
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py	(revision 11596)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py	(revision 11597)
@@ -17,6 +17,12 @@
 ##
 
+import grok
+from zope.component import getUtility
+from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
 from waeup.kofa.students.viewlets import (
-    AddPreviousPaymentActionButton, AddBalancePaymentActionButton)
+    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
+    ManageActionButton, StudentBaseDisplayFormPage)
+
+from waeup.aaue.interfaces import MessageFactory as _
 
 class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
@@ -31,2 +37,20 @@
     def target_url(self):
         return ''
+
+class GetMatricNumberActionButton(ManageActionButton):
+    grok.order(10)
+    grok.context(IStudent)
+    grok.view(StudentBaseDisplayFormPage)
+    grok.require('waeup.viewStudent')
+    icon = 'actionicon_count.png'
+    text = _('Get Matriculation Number')
+
+    @property
+    def target_url(self):
+        students_utils = getUtility(IStudentsUtils)
+        if self.context.matric_number:
+            return ''
+        matric_number = students_utils.constructMatricNumber(self.context)
+        if not matric_number:
+            return ''
+        return self.view.url(self.view.context, 'get_matric_number')
