[PYTHON] +override closing date for bank statements
authorLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Mon, 27 Jun 2016 12:49:47 +0000 (14:49 +0200)
committerLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Mon, 27 Jun 2016 12:49:47 +0000 (14:49 +0200)
__init__.py
__openerp__.py
account_cash_statement.py [new file with mode: 0644]
point_of_sale.py

index d44fe1d..ff4d6b5 100644 (file)
@@ -22,6 +22,7 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
+import account_cash_statement
 import point_of_sale
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index c7bb6d1..09a6f7a 100644 (file)
@@ -33,7 +33,7 @@
     'author': 'L\'Heureux Cyclage',
     'website': 'http://www.heureux-cyclage.org',
     'depends': [
-        'point_of_sale'
+        'point_of_sale',
     ],
     'init_xml': [],
     'data': [],
diff --git a/account_cash_statement.py b/account_cash_statement.py
new file mode 100644 (file)
index 0000000..c4155e3
--- /dev/null
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Non-real time point of sale module for OpenERP, Permit user to record his
+#    sales in point of sale interface in non-real time.
+#    Copyright (C) 2016 L'Heureux Cyclage (<http://www.heureux-cyclage>)
+#    Ludovic CHEVALIER
+#
+#    This file is a part of Non-real time point of sale
+#
+#    Non-real time point of sale is free software: you can redistribute it
+#    and/or modify it under the terms of the GNU General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    Non-real time point of sale is distributed in the hope that it will be
+#    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+#    Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import osv
+from openerp.osv import orm
+from openerp.osv import fields
+
+
+class account_cash_statement(orm.Model):
+    _inherit = 'account.bank.statement'
+
+    def button_confirm_cash(self, cr, uid, ids, context=None):
+        """
+        Put same closing date for account_bank_statement as pos session start_at date.
+        """
+        self.pool.get('pos.session')
+        res = super(account_cash_statement, self).button_confirm_cash(cr, uid, ids, context=context)
+        for statement in self.browse(cr, uid, ids, context=context):
+            if statement.pos_session_id:
+                return self.write(cr, uid, [statement.id], {'closing_date': statement.pos_session_id.start_at}, context=context)
+        return res
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 70f7c3f..71b2eb6 100644 (file)
@@ -75,15 +75,12 @@ class pos_session(orm.Model):
 
     def wkf_action_closing_control(self, cr, uid, ids, context=None):
         """
-        Disable default start_at date
-        Piece of this code was copied from
-        addons/point_of_sale/point_of_sale.py:397
+        Put same stop_at date in pos_session as its start_at date
         """
+        res = super(pos_session, self).wkf_action_closing_control(cr, uid, ids, context=context)
         for session in self.browse(cr, uid, ids, context=context):
-            for statement in session.statement_ids:
-                if (statement != session.cash_register_id) and (statement.balance_end != statement.balance_end_real):
-                    self.pool.get('account.bank.statement').write(cr, uid, [statement.id], {'balance_end_real': statement.balance_end})
-        return True
+            self.write(cr, uid, [session.id], {'stop_at': session.start_at}, context=context)
+        return res
 
     def onchange_start_at(self, cr, uid, ids, start_at, context=None):
         """Define same stop_at as start_at"""