Merge lp:~openerp-open-net/openobject-addons/ons_membership into lp:openobject-addons

Proposed by Open Net Sàrl
Status: Rejected
Rejected by: Fabien (Open ERP)
Proposed branch: lp:~openerp-open-net/openobject-addons/ons_membership
Merge into: lp:openobject-addons
Diff against target: 512 lines (+493/-0)
4 files modified
__init__.py (+37/-0)
__openerp__.py (+55/-0)
membership.py (+295/-0)
membership_view.xml (+106/-0)
To merge this branch: bzr merge lp:~openerp-open-net/openobject-addons/ons_membership
Reviewer Review Type Date Requested Status
Fabien (Open ERP) Disapprove
Open Net Sàrl (community) Approve
Review via email: mp+36453@code.launchpad.net

Description of the change

This module has been developed and tested with OpenERP V6
That's why we propose this branch merging

To post a comment you must log in.
Revision history for this message
Open Net Sàrl (openerp-open-net) wrote :

Hi

Sorry but I need help as I have never done any merging.
If I launch the command "bzr merge ..." in my directory, it responds "Nothing to do.".
What do I do now?

Thanks in advance

Revision history for this message
Open Net Sàrl (openerp-open-net) wrote :

Si tu as pas la réponse, demande à Thierry

Cordialement

Eberhard J-A
Directeur

Open Net Sàrl
www.open-net.ch
Ch. de la Lande 1 CH 1008 Prilly
021 / 625.35.75 - 078 / 898.40.77

----- Mail original -----
De: "Open Net Sàrl" <email address hidden>
À: "Open Net Sàrl" <email address hidden>
Envoyé: Vendredi 24 Septembre 2010 13:53:39
Objet: Re: [Merge] lp:~openerp-open-net/openobject-addons/ons_membership into lp:openobject-addons

Hi

Sorry but I need help as I have never done any merging.
If I launch the command "bzr merge ..." in my directory, it responds "Nothing to do.".
What do I do now?

Thanks in advance
--
https://code.launchpad.net/~openerp-open-net/openobject-addons/ons_membership/+merge/36453
You are the owner of lp:~openerp-open-net/openobject-addons/ons_membership.

Revision history for this message
Open Net Sàrl (openerp-open-net) :
review: Approve
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

Seems to be a good improvement.
But I propose you to merge this in extra-addons or community-addons. So, I reject the proposal for addons.

Thanks,

review: Disapprove

Unmerged revisions

1. By <email address hidden>

First version

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '__init__.py'
2--- __init__.py 1970-01-01 00:00:00 +0000
3+++ __init__.py 2010-09-23 14:59:01 +0000
4@@ -0,0 +1,37 @@
5+# -*- encoding: utf-8 -*-
6+#
7+# File: __init__.py
8+# Module: ons_membership
9+#
10+# Created by cyp@open-net.ch
11+#
12+# Copyright (c) 2010 Open-Net Ltd. All rights reserved.
13+##############################################################################
14+#
15+# Author Yvon Philiippe Crittin / Open Net Sarl
16+#
17+# WARNING: This program as such is intended to be used by professional
18+# programmers who take the whole responsability of assessing all potential
19+# consequences resulting from its eventual inadequacies and bugs
20+# End users who are looking for a ready-to-use solution with commercial
21+# garantees and support are strongly adviced to contract a Free Software
22+# Service Company
23+#
24+# This program is Free Software; you can redistribute it and/or
25+# modify it under the terms of the GNU General Public License
26+# as published by the Free Software Foundation; either version 2
27+# of the License, or (at your option) any later version.
28+#
29+# This program is distributed in the hope that it will be useful,
30+# but WITHOUT ANY WARRANTY; without even the implied warranty of
31+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32+# GNU General Public License for more details.
33+#
34+# You should have received a copy of the GNU General Public License
35+# along with this program; if not, write to the Free Software
36+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37+#
38+##############################################################################
39+
40+
41+import membership
42
43=== added file '__openerp__.py'
44--- __openerp__.py 1970-01-01 00:00:00 +0000
45+++ __openerp__.py 2010-09-23 14:59:01 +0000
46@@ -0,0 +1,55 @@
47+# -*- encoding: utf-8 -*-
48+#
49+# File: __openerp__.py
50+# Module: ons_membership
51+#
52+# Created by cyp@open-net.ch
53+#
54+# Copyright (c) 2010 Open-Net Ltd. All rights reserved.
55+##############################################################################
56+#
57+# Author Yvon Philiippe Crittin / Open Net Sarl
58+#
59+# WARNING: This program as such is intended to be used by professional
60+# programmers who take the whole responsability of assessing all potential
61+# consequences resulting from its eventual inadequacies and bugs
62+# End users who are looking for a ready-to-use solution with commercial
63+# garantees and support are strongly adviced to contract a Free Software
64+# Service Company
65+#
66+# This program is Free Software; you can redistribute it and/or
67+# modify it under the terms of the GNU General Public License
68+# as published by the Free Software Foundation; either version 2
69+# of the License, or (at your option) any later version.
70+#
71+# This program is distributed in the hope that it will be useful,
72+# but WITHOUT ANY WARRANTY; without even the implied warranty of
73+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74+# GNU General Public License for more details.
75+#
76+# You should have received a copy of the GNU General Public License
77+# along with this program; if not, write to the Free Software
78+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
79+#
80+##############################################################################
81+
82+
83+
84+{
85+ "name" : "More for the membership, by Open-Net",
86+ "version" : "1.2.08",
87+ "author" : "cyp@open-net.ch",
88+ "website" : "http://open-net.ch",
89+ "category" : "Generic Modules/Association",
90+ "depends" : ["membership"],
91+ "description": """
92+This module lets you do more with the membership management:
93+- you can add a fixed duration for a membership, starting at the date the partner is joined to
94+- you can even have a variable membership, starting at the current date and ending at a pre-determined day
95+ """,
96+ 'init_xml': [],
97+ 'update_xml': [ "membership_view.xml" ],
98+ 'demo_xml': [],
99+ 'installable': True,
100+ 'active': False,
101+}
102
103=== added file 'membership.py'
104--- membership.py 1970-01-01 00:00:00 +0000
105+++ membership.py 2010-09-23 14:59:01 +0000
106@@ -0,0 +1,295 @@
107+# -*- encoding: utf-8 -*-
108+#
109+# File: __init__.py
110+# Module: ons_membership
111+#
112+# Created by cyp@open-net.ch
113+#
114+# Copyright (c) 2010 Open-Net Ltd. All rights reserved.
115+##############################################################################
116+#
117+# Author Yvon Philiippe Crittin / Open Net Sarl
118+#
119+# WARNING: This program as such is intended to be used by professional
120+# programmers who take the whole responsability of assessing all potential
121+# consequences resulting from its eventual inadequacies and bugs
122+# End users who are looking for a ready-to-use solution with commercial
123+# garantees and support are strongly adviced to contract a Free Software
124+# Service Company
125+#
126+# This program is Free Software; you can redistribute it and/or
127+# modify it under the terms of the GNU General Public License
128+# as published by the Free Software Foundation; either version 2
129+# of the License, or (at your option) any later version.
130+#
131+# This program is distributed in the hope that it will be useful,
132+# but WITHOUT ANY WARRANTY; without even the implied warranty of
133+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
134+# GNU General Public License for more details.
135+#
136+# You should have received a copy of the GNU General Public License
137+# along with this program; if not, write to the Free Software
138+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
139+#
140+##############################################################################
141+
142+from osv import fields, osv
143+from datetime import *
144+from tools.translate import _
145+import netsvc
146+
147+class membership_line(osv.osv):
148+ _inherit = 'membership.membership_line'
149+
150+ def _get_membership_summary(self, cr, uid, ids, field_name, arg, context={}):
151+ res = {}
152+ for id in ids:
153+ res[id] = False
154+ mbl = self.browse(cr, uid, id, context=context)
155+ if mbl:
156+ if mbl.kindof == 'period':
157+ res[id] = 'From ' + datetime.strptime(mbl.date_from, '%Y-%m-%d').strftime('%d/%m/%y') + ' to ' + datetime.strptime(mbl.date_to, '%Y-%m-%d').strftime('%d/%m/%y')
158+ elif mbl.kindof == 'duration':
159+ res[id] = str(mbl.duration) + ' days'
160+ elif mbl.kindof == 'until':
161+ res[id] = datetime.strptime(mbl.date_until, '%Y-%m-%d').strftime('%d/%m/%y')
162+ return res
163+
164+ _columns = {
165+ 'kindof': fields.selection([('period', 'Period'), ('duration', 'Duration'), ('until', 'Until')], 'Kind Of', required=True),
166+ 'duration': fields.integer('Duration', help='Expressed in days, starts with the current date'),
167+ 'date_until': fields.date('Until', help='Starts with the current date'),
168+ 'summary': fields.function( _get_membership_summary, method=True, type='char', size=60, string='Summary', readonly=True, store=False ),
169+ }
170+
171+ _defaults = {
172+ 'kindof': lambda *a: 'period',
173+ }
174+
175+membership_line()
176+
177+class Product(osv.osv):
178+ '''Product'''
179+ _inherit = 'product.product'
180+
181+ def _get_membership_summary(self, cr, uid, ids, field_name, arg, context={}):
182+ res = {}
183+ for id in ids:
184+ res[id] = False
185+ prod = self.browse(cr, uid, id, context=context)
186+ if prod:
187+ if prod.kindof == 'period':
188+ res[id] = 'From ' + datetime.strptime(prod.membership_date_from, '%Y-%m-%d').strftime('%d/%m/%y') + ' to ' + datetime.strptime(prod.membership_date_to, '%Y-%m-%d').strftime('%d/%m/%y')
189+ elif prod.kindof == 'duration':
190+ res[id] = str(prod.duration) + ' days'
191+ elif prod.kindof == 'until':
192+ res[id] = datetime.strptime(prod.date_until, '%Y-%m-%d').strftime('%d/%m/%y')
193+ return res
194+
195+ _columns = {
196+ 'kindof': fields.selection([('period', 'Period'), ('duration', 'Duration'), ('until', 'Until')], 'Kind Of', required=True),
197+ 'duration': fields.integer('Duration', help='Expressed in days, starts with the current date'),
198+ 'date_until': fields.date('Until', help='Starts with the current date'),
199+ 'summary': fields.function( _get_membership_summary, method=True, type='char', size=60, string='Summary', readonly=True, store=False ),
200+ }
201+
202+ _defaults = {
203+ 'kindof': lambda *a: 'period',
204+ }
205+Product()
206+
207+class account_invoice_line(osv.osv):
208+ _inherit='account.invoice.line'
209+
210+ def write(self, cr, uid, ids, vals, context=None):
211+ """Overrides membership write method
212+ """
213+
214+ if not context:
215+ context={}
216+ res = super(account_invoice_line, self).write(cr, uid, ids, vals, context=context)
217+ member_line_obj = self.pool.get('membership.membership_line')
218+ for line in self.browse(cr, uid, ids):
219+ if line.invoice_id.type == 'out_invoice':
220+ ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',line.id)])
221+ if line.product_id and line.product_id.membership and not ml_ids:
222+ # Product line has changed to a membership product
223+ date_from = line.product_id.membership_date_from
224+ date_to = line.product_id.membership_date_to
225+ membership_kindof = line.product_id.kindof
226+ membership_duration = line.product_id.duration
227+ membership_date_until = line.product_id.date_until
228+
229+ membership_ids = member_line_obj.search(cr, uid, [('membership_id','=',line.product_id.id)],context=context)
230+ if membership_ids and len(membership_ids):
231+ membership = member_line_obj.browse(cr, uid, membership_ids[0], context=context)
232+ if membership:
233+ if membership.kindof == 'duration':
234+ date_from = date.today()
235+ date_to = date.today() + timedelta(days=membership.duration)
236+ membership_duration = membership.duration
237+ elif membership.kindof == 'until':
238+ date_from = date.today()
239+ date_to = membership.date_until
240+ membership_date_until = membership.date_until
241+ membership_kindof = membership.kindof
242+
243+ if line.invoice_id.date_invoice > date_from and line.invoice_id.date_invoice < date_to:
244+ date_from = line.invoice_id.date_invoice
245+ values = {
246+ 'partner': line.invoice_id.partner_id.id,
247+ 'membership_id': line.product_id.id,
248+ 'member_price': line.price_unit,
249+ 'date': time.strftime('%Y-%m-%d'),
250+ 'date_from': date_from,
251+ 'date_to': date_to,
252+ 'account_invoice_line': line.id,
253+ 'kindof': membership_kindof,
254+ }
255+ if membership_duration:
256+ values['duration'] = membership_duration
257+ if membership_date_until:
258+ values['date_until'] = membership_date_until
259+ line_id = member_line_obj.create(cr, uid, values)
260+
261+ if line.product_id and not line.product_id.membership and ml_ids:
262+ # Product line has changed to a non membership product
263+ member_line_obj.unlink(cr, uid, ml_ids, context=context)
264+
265+ if line.product_id and line.product_id.membership and ml_ids:
266+ for ml_id in ml_ids:
267+ member_line = member_line_obj.browse( cr, uid, ml_id, context=context )
268+ if member_line:
269+ values = {
270+ 'kindof': line.product_id.kindof,
271+ 'duration': line.product_id.duration,
272+ 'date_until': line.product_id.date_until
273+ }
274+ if line.product_id.kindof == 'duration':
275+ date_from = date.today()
276+ values['date_from'] = date_from
277+ date_to = date_from + timedelta(days=line.product_id.duration)
278+ values['date_to'] = date_to
279+ elif line.product_id.kindof == 'until':
280+ date_from = date.today()
281+ values['date_from'] = date_from
282+ date_to = line.product_id.date_until
283+ values['date_to'] = date_to
284+ member_line_obj.write( cr, uid, [ml_id], values, context=context )
285+ return res
286+
287+ def create(self, cr, uid, vals, context={}):
288+ """Overrides membership create method
289+ """
290+
291+ result = super(account_invoice_line, self).create(cr, uid, vals, context)
292+ line = self.browse(cr, uid, result)
293+ member_line_obj = self.pool.get('membership.membership_line')
294+ if line.invoice_id.type == 'out_invoice':
295+
296+ ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',line.id)])
297+ if line.product_id and line.product_id.membership and not ml_ids:
298+ # Product line is a membership product
299+ date_from = line.product_id.membership_date_from
300+ date_to = line.product_id.membership_date_to
301+ membership_kindof = line.product_id.kindof
302+ membership_duration = line.product_id.duration
303+ membership_date_until = line.product_id.date_until
304+
305+ membership_ids = member_line_obj.search(cr, uid, [('membership_id','=',line.product_id.id)],context=context)
306+ if membership_ids and len(membership_ids):
307+ membership = member_line_obj.browse(cr, uid, membership_ids[0], context=context)
308+ if membership:
309+ if membership.kindof == 'duration':
310+ date_from = date.today()
311+ date_to = date.today() + timedelta(days=membership.duration)
312+ membership_duration = membership.duration
313+ elif membership.kindof == 'until':
314+ date_from = date.today()
315+ date_to = membership.date_until
316+ membership_date_until = membership.date_until
317+ membership_kindof = membership.kindof
318+
319+ if line.invoice_id.date_invoice > date_from and line.invoice_id.date_invoice < date_to:
320+ date_from = line.invoice_id.date_invoice
321+ values = {
322+ 'partner': line.invoice_id.partner_id and line.invoice_id.partner_id.id or False,
323+ 'membership_id': line.product_id.id,
324+ 'member_price': line.price_unit,
325+ 'date': time.strftime('%Y-%m-%d'),
326+ 'date_from': date_from,
327+ 'date_to': date_to,
328+ 'account_invoice_line': line.id,
329+ 'kindof': membership_kindof,
330+ }
331+ if membership_duration:
332+ values['duration'] = membership_duration
333+ if membership_date_until:
334+ values['date_until'] = membership_date_until
335+ line_id = member_line_obj.create(cr, uid, values)
336+
337+ return result
338+
339+account_invoice_line()
340+
341+class Partner(osv.osv):
342+ '''Partner'''
343+ _inherit = 'res.partner'
344+
345+ def create_membership_invoice(self, cr, uid, ids, product_id=None, datas=None, context=None):
346+ """ Create Customer Invoice of Membership for partners.
347+ @param datas: datas has dictionary value which consist Id of Membership product and Cost Amount of Membership.
348+ datas = {'membership_product_id': None, 'amount':None}
349+ """
350+
351+ invoice_obj = self.pool.get('account.invoice')
352+ product_obj = self.pool.get('product.product')
353+ invoice_line_obj = self.pool.get('account.invoice.line')
354+ invoice_tax_obj = self.pool.get('account.invoice.tax')
355+ product_id = product_id or datas.get('membership_product_id',False)
356+ amount = datas.get('amount', 0.0)
357+ if not context:
358+ context={}
359+ invoice_list = []
360+ if type(ids) in (int,long,):
361+ ids = [ids]
362+ for partner in self.browse(cr, uid, ids, context=context):
363+ account_id = partner.property_account_receivable and partner.property_account_receivable.id or False
364+ fpos_id = partner.property_account_position and partner.property_account_position.id or False
365+ addr = self.address_get(cr, uid, [partner.id], ['invoice'])
366+ if partner.free_member:
367+ raise osv.except_osv(_('Error !'),
368+ _("Partner is a free Member."))
369+ if not addr.get('invoice', False):
370+ raise osv.except_osv(_('Error !'),
371+ _("Partner doesn't have an address to make the invoice."))
372+ quantity = 1
373+ line_value = {
374+ 'product_id' : product_id,
375+ }
376+
377+ line_dict = invoice_line_obj.product_id_change(cr, uid, {},
378+ product_id, False, quantity, '', 'out_invoice', partner.id, fpos_id, price_unit=amount, context=context)
379+ line_value.update(line_dict['value'])
380+ if line_value.get('invoice_line_tax_id', False):
381+ tax_tab = [(6, 0, line_value['invoice_line_tax_id'])]
382+ line_value['invoice_line_tax_id'] = tax_tab
383+
384+ invoice_id = invoice_obj.create(cr, uid, {
385+ 'partner_id' : partner.id,
386+ 'address_invoice_id': addr.get('invoice', False),
387+ 'account_id': account_id,
388+ 'fiscal_position': fpos_id or False
389+ }
390+ )
391+ line_value['invoice_id'] = invoice_id
392+ invoice_line_id = invoice_line_obj.create(cr, uid, line_value, context=context)
393+ invoice_obj.write(cr, uid, invoice_id, {'invoice_line':[(6,0,[invoice_line_id])]}, context=context)
394+ invoice_list.append(invoice_id)
395+ if line_value['invoice_line_tax_id']:
396+ tax_value = invoice_tax_obj.compute(cr, uid, invoice_id).values()
397+ for tax in tax_value:
398+ invoice_tax_obj.create(cr, uid, tax, context=context)
399+ return invoice_list
400+
401+Partner()
402
403=== added file 'membership_view.xml'
404--- membership_view.xml 1970-01-01 00:00:00 +0000
405+++ membership_view.xml 2010-09-23 14:59:01 +0000
406@@ -0,0 +1,106 @@
407+<?xml version="1.0"?>
408+<openerp>
409+ <data>
410+
411+ <record model="ir.ui.view" id="ons_mbship_view_partner_form">
412+ <field name="name">res.partner.form.inherit</field>
413+ <field name="model">res.partner</field>
414+ <field name="inherit_id" ref="membership.view_partner_form"/>
415+ <field name="arch" type="xml">
416+ <field name="member_lines" position="replace">
417+ <field name="member_lines" nolabel="1" colspan="4" readonly="1">
418+ <tree string="Memberships">
419+ <field name="date"/>
420+ <field name="membership_id"/>
421+ <field name="kindof"/>
422+ <field name="summary"/>
423+ <field name="member_price"/>
424+ <field name="account_invoice_id"/>
425+ <field name="state"/>
426+ </tree>
427+ <form string="Memberships">
428+ <field name="date"/>
429+ <field name="member_price"/>
430+ <field name="membership_id"/>
431+ <field name="account_invoice_id"/>
432+ <field name="kindof"/>
433+ <field name="summary"/>
434+ <field name="state" colspan="4"/>
435+ </form>
436+ </field>
437+ </field>
438+ </field>
439+ </record>
440+
441+ <record model="ir.ui.view" id="ons_mbship_view_product_form_inherit1">
442+ <field name="name">ons_mbship.product.normal.form.1</field>
443+ <field name="type">form</field>
444+ <field name="model">product.product</field>
445+ <field name="inherit_id" ref="membership.membership_products_form"/>
446+ <field name="arch" type="xml">
447+ <field name="membership_date_from" position="before">
448+ <field name="kindof"/>
449+ <group colspan="2">
450+ <field colspan="2" name="duration" attrs="{'invisible':[('kindof','&lt;&gt;','duration')], 'required':[('kindof','=','duration')]}"/>
451+ <field colspan="2" name="date_until" attrs="{'invisible':[('kindof','&lt;&gt;','until')], 'required':[('kindof','=','until')]}"/>
452+ <newline/>
453+ </group>
454+ </field>
455+ </field>
456+ </record>
457+ <record model="ir.ui.view" id="ons_mbship_view_product_form_inherit2">
458+ <field name="name">ons_mbship.product.normal.form.2</field>
459+ <field name="type">form</field>
460+ <field name="model">product.product</field>
461+ <field name="inherit_id" ref="membership.membership_products_form"/>
462+ <field name="arch" type="xml">
463+ <field name="membership_date_from" position="replace">
464+ <field name="membership_date_from" attrs="{'invisible':[('kindof','&lt;&gt;','period')], 'required':[('kindof','=','period')]}"/>
465+ </field>
466+ </field>
467+ </record>
468+ <record model="ir.ui.view" id="ons_mbship_view_product_form_inherit3">
469+ <field name="name">ons_mbship.product.normal.form.3</field>
470+ <field name="type">form</field>
471+ <field name="model">product.product</field>
472+ <field name="inherit_id" ref="membership.membership_products_form"/>
473+ <field name="arch" type="xml">
474+ <field name="membership_date_to" position="replace">
475+ <field name="membership_date_to" attrs="{'invisible':[('kindof','&lt;&gt;','period')], 'required':[('kindof','=','period')]}"/>
476+ </field>
477+ </field>
478+ </record>
479+
480+ <record model="ir.ui.view" id="ons_mbship_view_product_tree_inherit1">
481+ <field name="name">ons_mbship.product.normal.tree.1</field>
482+ <field name="type">form</field>
483+ <field name="model">product.product</field>
484+ <field name="inherit_id" ref="membership.membership_products_tree"/>
485+ <field name="arch" type="xml">
486+ <field name="membership_date_from" position="replace"/>
487+ </field>
488+ </record>
489+ <record model="ir.ui.view" id="ons_mbship_view_product_tree_inherit2">
490+ <field name="name">ons_mbship.product.normal.tree.2</field>
491+ <field name="type">form</field>
492+ <field name="model">product.product</field>
493+ <field name="inherit_id" ref="membership.membership_products_tree"/>
494+ <field name="arch" type="xml">
495+ <field name="membership_date_to" position="replace"/>
496+ </field>
497+ </record>
498+ <record model="ir.ui.view" id="ons_mbship_view_product_tree_inherit3">
499+ <field name="name">ons_mbship.product.normal.tree.3</field>
500+ <field name="type">form</field>
501+ <field name="model">product.product</field>
502+ <field name="inherit_id" ref="membership.membership_products_tree"/>
503+ <field name="arch" type="xml">
504+ <field name="list_price" position="after">
505+ <field name="summary"/>
506+ <field name="kindof"/>
507+ </field>
508+ </field>
509+ </record>
510+
511+ </data>
512+</openerp>

Subscribers

People subscribed via source and target branches

to all changes: