+++ /dev/null
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Remembership module for OpenERP, Membership module enhancement and bug fixes
-# Copyright (C) 2012-2018 L'Heureux Cyclage (<http://www.heureux-cyclage.org>)
-#
-# This file is a part of Remembership
-#
-# 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,
-# 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
-from datetime import datetime
-
-
-class membership_invoice(osv.osv):
- _inherit = 'membership.invoice'
-
- _columns = {
- 'date_from': fields.date('This membership start date'),
- 'is_date2date': fields.boolean('This membership product is date to date.', readonly=True),
- }
-
- _defaults = {
- 'date_from': datetime.today().strftime('%Y-%m-%d'),
- }
-
- def onchange_product(self, cr, uid, ids, product_id=False):
- res = super(membership_invoice, self).onchange_product(cr, uid, ids, product_id)
- if product_id:
- res['value']['is_date2date'] = self.pool.get('product.product').browse(cr, uid, [product_id], context=None)[0].membership_date2date
- else:
- res['value']['is_date2date'] = False
-
- return res
-
- def membership_invoice(self, cr, uid, ids, context=None):
- """NOTE: Copy of orginial function for overwrite it by adding
- date_from value for date to date membership products. Keep an eye of it
- for taking advantage of its enhancements (2013-01-11)"""
- mod_obj = self.pool.get('ir.model.data')
- partner_obj = self.pool.get('res.partner')
- datas = {}
- if context is None:
- context = {}
- data = self.browse(cr, uid, ids, context=context)
- if data:
- data = data[0]
- datas = {
- 'membership_product_id': data.product_id.id,
- 'amount': data.member_price,
- 'date_from': data.date_from
- }
- invoice_list = partner_obj.create_membership_invoice(cr, uid, context.get('active_ids', []), datas=datas, context=context)
-
- res = mod_obj.get_object_reference(cr, uid, 'account', 'view_account_invoice_filter')
-
- return {
- 'domain': [('id', 'in', invoice_list)],
- 'name': 'Membership Invoices',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'account.invoice',
- 'type': 'ir.actions.act_window',
- 'search_view_id': res and res[1] or False
- }
-
-membership_invoice()