# -*- coding: utf-8 -*-
##############################################################################
#
-# ReMembership module for OpenERP, Other membership module for member management.
-# Copyright (C) 2012 L'Heureux Cyclage (<http://www.heureux-cyclage.org>) Ludovic CHEVALIER
+# Remembership module for OpenERP, Membership module enhancement and bug fixes
+# Copyright (C) 2012-2013 L'Heureux Cyclage (<http://www.heureux-cyclage.org>)
#
-# This file is a part of ReMembership
+# This file is a part of Remembership
#
-# ReMembership is free software: you can redistribute it and/or modify
+# Remembership 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,
+# 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.
# -*- coding: utf-8 -*-
##############################################################################
#
-# Remembership module for OpenERP, Overload membership module
+# Remembership module for OpenERP, Membership module enhancement and bug fixes
# Copyright (C) 2012-2013 L'Heureux Cyclage (<http://www.heureux-cyclage.org>)
#
# This file is a part of Remembership
class Partner(osv.osv):
_inherit = 'res.partner'
-
+
# XXX: copied from openerp/addons/membership/membership.py
def _membership_date(self, cr, uid, ids, name, args, context=None):
"""Return date of membership"""
print ("DEV: [_membership_date] [associate] date_from: %s" % str(res[partner.id]['membership_start']))
else:
print ("DEV: [_membership_date] date_from: %s" % str(res[partner.id]['membership_start']))
-
+
if name == 'membership_stop':
line_id1 = member_line_obj.search(cr, uid, [('partner', '=', partner_id),('date_cancel','=',False)],
limit=1, order='date_to desc', context=context)
print ("DEV: [_membership_date] [associate] date_to: %s" % str(res[partner.id]['membership_stop']))
else:
print ("DEV: [_membership_date] date_to: %s" % str(res[partner.id]['membership_stop']))
-
+
if name == 'membership_cancel':
if partner.membership_state == 'canceled':
line_id2 = member_line_obj.search(cr, uid, [('partner', '=', partner.id)], limit=1, order='date_cancel', context=context)
ids2 = res_obj.search(cr, uid, [('associate_member', 'in', ids2)], context=context)
list_partner += ids2
return list_partner
-
+
_columns = {
'member_ident': fields.char('Member identifier', size=64),
'associate_members': fields.one2many('res.partner', 'associate_member', 'Associate members', help='Members who are associated to this partner.'),
'res.partner': (lambda self, cr, uid, ids, c={}: ids, ['free_member'], 10)
}, help="Date on which membership has been cancelled"),
}
-
+
_sql_constraints = [
('member_ident_uniq', 'unique(member_ident, company_id)', 'The member identifier must be unique !'),
]
-
+
def create_membership_invoice(self, cr, uid, ids, product_id=None, datas=None, context=None):
# NOTE: use context to supply date_from to account_invoice_line.create
context = context and context.copy() or {}
- context.update({'date_from': datas.get('date_from', None)});
+ #context.update({'date_from': datas.get('date_from', None)});
# XXX: copied from openerp/addons/membership/membership.py to fix account_invoice_line creation
print ("DEV: [remembership] [partner] [create_membership_invoice] ids=%s" % str(ids))
invoice_obj = self.pool.get('account.invoice')
line_value = {
'product_id': product_id,
}
-
+
print ("DEV: [remembership] [partner] [create_membership_invoice] ids=%s partner=%s [invoice_line_obj] [product_id_change]" % (str(ids),str(partner.id)))
line_dict = invoice_line_obj.product_id_change(cr, uid, {},
product_id, False, quantity, '', 'out_invoice', partner.id, fpos_id, price_unit=amount, context=context)
if line_value.get('invoice_line_tax_id', False):
tax_tab = [(6, 0, line_value['invoice_line_tax_id'])]
line_value['invoice_line_tax_id'] = tax_tab
-
+
print ("DEV: [remembership] [partner] [create_membership_invoice] ids=%s partner=%s [invoice_obj] [create] account=%s" % (str(ids),str(partner.id),str(account_id)))
# NOTE: let account_invoice_obj.create() call account_invoice_line.create()
# to have a correct membership_state: becauce now fields.function 'store' watchdogs
class Product(osv.osv):
_inherit = 'product.product'
-
+
_columns = {
'membership_grouped': fields.boolean('Grouped membership product', help='Check if it\'s a grouped membership product.'),
'membership_date2date': fields.boolean('Date to date membership product', required=False, help='Check if it\'s a date to date membership product.'),
class account_invoice_line(osv.osv):
_inherit = 'account.invoice.line'
-
+
def write(self, cr, uid, ids, vals, context=None):
member_line_obj = self.pool.get('membership.membership_line')
res = super(account_invoice_line, self).write(cr, uid, ids, vals, context=context)
member_line_obj.unlink(cr, uid, ml_ids, context=context)
print ("DEV: [remembership] [account_invoice_line] [write] : return=%s" % str(res))
return res
-
+
def create(self, cr, uid, vals, context=None):
member_line_obj = self.pool.get('membership.membership_line')
res = super(account_invoice_line, self).create(cr, uid, vals, context=context)
print ("DEV: [remembership] [account_invoice_line] [create] : begin res=%s" % str(res))
line = self.browse(cr, uid, res, context=context)
-
+
if line.invoice_id.type == 'out_invoice' and line.product_id and line.product_id.membership:
member_line_id = member_line_obj.search(cr, uid
, [('partner' , '=', line.invoice_id.partner_id.id)