From: Sébastien Grignard Date: Tue, 14 Jan 2014 21:21:24 +0000 (+0100) Subject: Display a warning when closing a session with a 0 balance. Not perfect since it compl... X-Git-Url: http://git.cyclocoop.org/?p=burette%2Fpos_membership.git;a=commitdiff_plain;h=c82f9afbbfacfeecb0db9edc12aedec802a035a9 Display a warning when closing a session with a 0 balance. Not perfect since it completly forbids doing so and the message is not translated. --- diff --git a/pos_membership.py b/pos_membership.py index e61b697..ab6933f 100644 --- a/pos_membership.py +++ b/pos_membership.py @@ -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()