X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=etudesetchantiersidf.py;fp=etudesetchantiersidf.py;h=1f401023c9a6258c96d5c0a967374dfca394ad3a;hb=27da42444afa9508c4b12318645f651440a1d0d7;hp=0000000000000000000000000000000000000000;hpb=6837743e94c331def4cb594988ad4d98c5796bd5;p=burette%2Fetudesetchantiersidf.git
diff --git a/etudesetchantiersidf.py b/etudesetchantiersidf.py
new file mode 100644
index 0000000..1f40102
--- /dev/null
+++ b/etudesetchantiersidf.py
@@ -0,0 +1,79 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# etudesetchantiersidf module for OpenERP, Custom module for Ãtude et
+# Chantiers île-de-France
+# Copyright (C) 2014-2015 etudesetchantiersidf
+# ()
+#
+# This file is a part of etudesetchantiersidf
+#
+# etudesetchantiersidf 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.
+#
+# etudesetchantiersidf 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 .
+#
+##############################################################################
+
+from openerp.osv import osv
+from openerp.osv import orm
+from openerp.osv import fields
+
+
+class Partner(osv.osv):
+ '''Partner'''
+ _inherit = 'res.partner'
+ '''
+ def _get_invoice_partner(self, cr, uid, ids, context=None):
+ res = super(Partner, self)._get_invoice_partner(cr, uid, ids, context=context)
+ return res
+
+ def _get_partner_id(self, cr, uid, ids, context=None):
+ res = super(Partner, self)._get_partner_id(cr, uid, ids, context=context)
+ return res
+ '''
+
+ def _get_last_mb_product(self, cr, uid, ids, name, args, context=None):
+ """Return the last membership product buy by a user"""
+ name=name[0]
+ res ={}
+ member_line_obj = self.pool.get('membership.membership_line')
+ for partner in self.browse(cr, uid, ids, context=context):
+ partner_id = partner.id
+ line_id = member_line_obj.search(cr, uid, [
+ ('partner', '=', partner_id),
+ ('date_cancel', '=', False)
+ ], limit=1, order='date_from', context=context)
+ if line_id:
+ product_id = member_line_obj.read(cr, uid, line_id[0], [name], context=context)[name][0]
+ res[partner.id] = {name: product_id}
+ return res
+
+
+ _columns = {
+ 'membership_id': fields.function(
+ _get_last_mb_product, multi='membership_id',
+ string='Last membership product',
+ type='many2one',
+ obj='product.product',
+ store=True,
+ ),
+ }
+'''
+store = {
+ 'account.invoice': (_get_invoice_partner, ['state'], 10),
+ 'membership.membership_line': (_get_partner_id, ['state'], 10, )
+ }
+'''
+
+Partner()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: