Display a warning when closing a session with a 0 balance. Not perfect since it compl...
authorSébastien Grignard <seb@amakaze.org>
Tue, 14 Jan 2014 21:21:24 +0000 (22:21 +0100)
committerSébastien Grignard <seb@amakaze.org>
Tue, 14 Jan 2014 21:21:24 +0000 (22:21 +0100)
pos_membership.py

index e61b697..ab6933f 100644 (file)
@@ -59,6 +59,19 @@ class pos_session(osv.osv):
 
         return {
         }
+
+    def wkf_action_close(self, cr, uid, ids, context=None):
+       # Check that a register is not closed with a zero balance if it started with a positive balance
+       for record in self.browse(cr, uid, ids, context=context):
+             for st in record.statement_ids:
+                 
+                 if st.balance_start>0 and not st.balance_end_real:
+                     # The pos manager can close sessions with 0 for the end balance.
+                     if not self.pool.get('ir.model.access').check_groups(cr, uid, "point_of_sale.group_pos_manager"):
+                         raise osv.except_osv( _('Please check your ending balance!'),
+                                               _("Your ending balance is zero, don't forget to enter it before closing the session! Leave around 20-30 EUR in the register."))
+       return super(pos_session, self).wkf_action_close(cr, uid, ids, context)
+        
 pos_session()