[order] work in progress: disallow make anonym order when ther is a membership product
authorLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Mon, 4 Feb 2013 15:34:13 +0000 (16:34 +0100)
committerLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Mon, 4 Feb 2013 15:34:18 +0000 (16:34 +0100)
__init__.py
pos_membership.py [new file with mode: 0644]

index 96390f5..ee06cef 100644 (file)
@@ -20,5 +20,6 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
+import pos_membership
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/pos_membership.py b/pos_membership.py
new file mode 100644 (file)
index 0000000..d705c86
--- /dev/null
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    POS Membership module for OpenERP, Manage membership payments from POS.
+#    Copyright (C) 2013 L'Heureux Cyclage (<http://www.heureux-cyclage.org>)
+#
+#    This file is a part of POS Membership
+#
+#    POS Membership 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.
+#
+#    ReMembership 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 fields
+
+class pos_order(osv.osv):
+    _inherit = 'pos.order'
+
+    def _check_membership_product(self, cr, uid, ids, context=None):
+        #TODO : check condition and return boolean accordingly
+        if not context is None:
+            context = {}
+        order_line_obj = self.pool.get('pos.order.line')
+        #order_obj = self.pool.get('pos.order')
+        data_order_line = order_line_obj.browse(cr, uid, ids, context=context)
+        for data in data_order_line:
+            print("INFO: pos_membership - Line:" + data.id),
+            print("Product: " + data.product_id)
+        return True
+
+    _constraints = [
+        (_check_membership_product, 'Error: Invalid Message', ['field_name']),
+    ]
+
+pos_order()
+
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: