Merge lp:~openerp-dev/openobject-addons/trunk-paypal-sub-ins-sgo into lp:openobject-addons

Proposed by Thibault Delavallée (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-paypal-sub-ins-sgo
Merge into: lp:openobject-addons
Diff against target: 619 lines (+399/-55)
11 files modified
account/account.py (+34/-17)
account/account_invoice.py (+1/-1)
account/account_view.xml (+31/-8)
account/demo/account_demo.xml (+1/-1)
account/edi/invoice.py (+15/-11)
paypal_installment_plan/__init__.py (+24/-0)
paypal_installment_plan/__openerp__.py (+46/-0)
paypal_installment_plan/paypal_installment_plan.py (+151/-0)
paypal_installment_plan/paypal_installment_plan_view.xml (+78/-0)
portal/portal_data.xml (+1/-6)
sale/edi/sale_order.py (+17/-11)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-paypal-sub-ins-sgo
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+192528@code.launchpad.net

Description of the change

[WIP]

To post a comment you must log in.

Unmerged revisions

8919. By Sanjay Gohel (Open ERP)

[MERGE]merge with parent

8918. By Sanjay Gohel (Open ERP)

[MERGE]sync with trunk

8917. By Sanjay Gohel (Open ERP)

[IMP]improve paypal installment

8916. By Sanjay Gohel (Open ERP)

[ADD]add paypal icon for installment

8915. By Sanjay Gohel (Open ERP)

[MERGE]sync with trunk

8914. By Sanjay Gohel (Open ERP)

[IMP]change string for field and help for fields as per new specificatin and give proper variable name. add compute method selection field for payment term line. add on change for it

8913. By Sanjay Gohel (Open ERP)

[MERGE]merge old paypal installment branch from which i can use it for new development

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account.py'
2--- account/account.py 2013-10-09 18:03:37 +0000
3+++ account/account.py 2013-10-24 15:18:27 +0000
4@@ -55,6 +55,7 @@
5 level -= 1
6 return True
7
8+COMPUTE_METHOD = [('other','Other')]
9 class account_payment_term(osv.osv):
10 _name = "account.payment.term"
11 _description = "Payment Term"
12@@ -63,12 +64,23 @@
13 'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the payment term without removing it."),
14 'note': fields.text('Description', translate=True),
15 'line_ids': fields.one2many('account.payment.term.line', 'payment_id', 'Terms'),
16+ 'compute_method': fields.selection (COMPUTE_METHOD, "Compute Method")
17 }
18 _defaults = {
19 'active': 1,
20+ 'compute_method': 'other',
21 }
22 _order = "name"
23
24+ def _get_next_date(self, date_ref, term_line):
25+ next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=term_line.days))
26+ if term_line.days2 < 0:
27+ next_first_date = next_date + relativedelta(day=1,months=1) #Getting 1st of next month
28+ next_date = next_first_date + relativedelta(days=term_line.days2)
29+ if term_line.days2 > 0:
30+ next_date += relativedelta(day=term_line.days2, months=1)
31+ return next_date
32+
33 def compute(self, cr, uid, id, value, date_ref=False, context=None):
34 if not date_ref:
35 date_ref = datetime.now().strftime('%Y-%m-%d')
36@@ -80,18 +92,12 @@
37 for line in pt.line_ids:
38 if line.value == 'fixed':
39 amt = round(line.value_amount, prec)
40- elif line.value == 'procent':
41+ elif line.value == 'percent':
42 amt = round(value * line.value_amount, prec)
43 elif line.value == 'balance':
44 amt = round(amount, prec)
45 if amt:
46- next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days))
47- if line.days2 < 0:
48- next_first_date = next_date + relativedelta(day=1,months=1) #Getting 1st of next month
49- next_date = next_first_date + relativedelta(days=line.days2)
50- if line.days2 > 0:
51- next_date += relativedelta(day=line.days2, months=1)
52- result.append( (next_date.strftime('%Y-%m-%d'), amt) )
53+ result.append( (self._get_next_date(date_ref, line).strftime('%Y-%m-%d'), amt) )
54 amount -= amt
55
56 amount = reduce(lambda x,y: x+y[1], result, 0.0)
57@@ -104,27 +110,38 @@
58 _name = "account.payment.term.line"
59 _description = "Payment Term Line"
60 _columns = {
61- 'value': fields.selection([('procent', 'Percent'),
62- ('balance', 'Balance'),
63- ('fixed', 'Fixed Amount')], 'Computation',
64- required=True, help="""Select here the kind of valuation related to this payment term line. Note that you should have your last line with the type 'Balance' to ensure that the whole amount will be treated."""),
65+ 'value': fields.selection([('fixed', 'Fixed Amount'),
66+ ('percent', 'Percentage'),
67+ ('balance', 'Balance')], 'Pay',
68+ required=True, help="Specify how to compute the amount to be paid with this payment term line. Make sure to always have ‘Balance’ in the last line of a payment term to insure full payment of the invoice."),
69
70- 'value_amount': fields.float('Amount To Pay', digits_compute=dp.get_precision('Payment Term'), help="For percent enter a ratio between 0-1."),
71- 'days': fields.integer('Number of Days', required=True, help="Number of days to add before computation of the day of month." \
72- "If Date=15/01, Number of Days=22, Day of Month=-1, then the due date is 28/02."),
73- 'days2': fields.integer('Day of the Month', required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."),
74+ 'value_amount': fields.float('Fixed Amount', digits_compute=dp.get_precision('Payment Term'), help="For percent enter a ratio between 0-1."),
75+ 'days': fields.integer('Number of days to add after invoice date', required=True, help="Number of net days to add the invoice date to compute the due date."),
76+ 'days2': fields.integer('Day of the month', required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."),
77 'payment_id': fields.many2one('account.payment.term', 'Payment Term', required=True, select=True, ondelete='cascade'),
78+ 'compute_due_date': fields.selection([('fixed',"in a fixed amount of days after invoice date (Net on receipt, Net 30…)"),('end_of_month',"end of month based on invoice date (Net E.O.M.)"), ('other',"Other")], string="Due date is")
79 }
80 _defaults = {
81 'value': 'balance',
82 'days': 30,
83 'days2': 0,
84+ 'compute_due_date': 'other'
85 }
86 _order = "value desc,days"
87
88+ def onchange_compute_due_date(self, cr, uid, ids, compute_due_date, context=None):
89+ res = {}
90+ if not compute_due_date:
91+ return res
92+ if compute_due_date == 'fixed':
93+ res['value'] = {'days': 30, 'days2' : 0}
94+ if compute_due_date == 'end_of_month':
95+ res['value'] = {'days': 0, 'days2' : -1}
96+ return res
97+
98 def _check_percent(self, cr, uid, ids, context=None):
99 obj = self.browse(cr, uid, ids[0], context=context)
100- if obj.value == 'procent' and ( obj.value_amount < 0.0 or obj.value_amount > 1.0):
101+ if obj.value == 'percent' and ( obj.value_amount < 0.0 or obj.value_amount > 1.0):
102 return False
103 return True
104
105
106=== modified file 'account/account_invoice.py'
107--- account/account_invoice.py 2013-09-23 17:13:10 +0000
108+++ account/account_invoice.py 2013-10-24 15:18:27 +0000
109@@ -955,7 +955,7 @@
110 for line in inv.payment_term.line_ids:
111 if line.value == 'fixed':
112 total_fixed += line.value_amount
113- if line.value == 'procent':
114+ if line.value == 'percent':
115 total_percent += line.value_amount
116 total_fixed = (total_fixed * 100) / (inv.amount_total or 1.0)
117 if (total_fixed + total_percent) > 100:
118
119=== modified file 'account/account_view.xml'
120--- account/account_view.xml 2013-09-12 13:20:32 +0000
121+++ account/account_view.xml 2013-10-24 15:18:27 +0000
122@@ -1594,20 +1594,42 @@
123 <field name="model">account.payment.term.line</field>
124 <field name="arch" type="xml">
125 <form string="Payment Term" version="7.0">
126- <group>
127- <group string="Amount Computation">
128- <field name="value"/>
129+ <group string="Amount Computation" col="4">
130+ <field name="value" class="oe_inline"/>
131 <label for="value_amount" string="Amount To Pay" attrs="{'invisible':[('value','=','balance')]}"/>
132 <div attrs="{'invisible':[('value','=','balance')]}">
133 <field name="value_amount" class="oe_inline"/>
134- <label string="%%" class="oe_inline" attrs="{'invisible':['!',('value','=','procent')]}" />
135+ <label string="%%" class="oe_inline" attrs="{'invisible':['!',('value','=','percent')]}" />
136 </div>
137 </group>
138- <group string="Due Date Computation">
139- <field name="days"/>
140- <field name="days2"/>
141+ <group name="Due Date Computation" string="Due Date Computation">
142+ <field name="compute_due_date" on_change="onchange_compute_due_date(compute_due_date)" class="oe_inline"/>
143+ <field name="days" attrs="{'invisible':[('compute_due_date','=','end_of_month')]}"/>
144+ <field name="days2" attrs="{'invisible':['|','|',('value','=','percent'),('compute_due_date','=','fixed'),('compute_due_date','=','end_of_month')]}"/>
145 </group>
146- </group>
147+ <div style="color: grey;" attrs="{'invisible':['|',('compute_due_date','=','fixed'),('compute_due_date','=','end_of_month')]}">
148+ <ul>
149+ <li>Set 0 for net days (you can also use the ‘in a fixed amount of days after invoice date…’ option).</li>
150+ <li>Set -1 for last day of the month, where month is the month of [invoice date + ‘Number of days to add after invoice date’].</li>
151+ <li>Set 1 for first day of the next month, where next month is the month after [invoice date + ‘Number of days to add after invoice date’].</li>
152+ <li> Example 1:
153+ <ul>
154+ <li>Invoice date = August 21st</li>
155+ <li>Number of days to add after invoice date = 12</li>
156+ <li>Day of the month = -1</li>
157+ <li>Then due date = September 30th</li>
158+ </ul>
159+ </li>
160+ <li>Example 2:
161+ <ul>
162+ <li>Invoice date = August 21st </li>
163+ <li>Number of days to add after invoice date = 12</li>
164+ <li>Day of the month = 2</li>
165+ <li>Then due date = October 2d</li>
166+ </ul>
167+ </li>
168+ </ul>
169+ </div>
170 </form>
171 </field>
172 </record>
173@@ -1629,6 +1651,7 @@
174 <group col="4">
175 <field name="name"/>
176 <field name="active"/>
177+ <field name="compute_method"/>
178 </group>
179 <field name="note" placeholder="Payment term explanation for the customer..."/>
180 <separator string="Computation"/>
181
182=== modified file 'account/demo/account_demo.xml'
183--- account/demo/account_demo.xml 2013-03-14 14:53:37 +0000
184+++ account/demo/account_demo.xml 2013-10-24 15:18:27 +0000
185@@ -146,7 +146,7 @@
186 <field name="note">30% Advance End 30 Days</field>
187 </record>
188 <record id="account_payment_term_line_advance1" model="account.payment.term.line">
189- <field name="value">procent</field>
190+ <field name="value">percent</field>
191 <field eval="0.300000" name="value_amount"/>
192 <field eval="0" name="days"/>
193 <field eval="0" name="days2"/>
194
195=== modified file 'account/edi/invoice.py'
196--- account/edi/invoice.py 2013-07-30 09:16:43 +0000
197+++ account/edi/invoice.py 2013-10-24 15:18:27 +0000
198@@ -259,21 +259,25 @@
199 pass
200 return action
201
202+ def _prepare_paypal_params(self, inv):
203+ params = {
204+ "cmd": "_xclick",
205+ "business": inv.company_id.paypal_account,
206+ "item_name": inv.company_id.name + " Invoice " + inv.number,
207+ "invoice": inv.number,
208+ "amount": inv.residual,
209+ "currency_code": inv.currency_id.name,
210+ "button_subtype": "services",
211+ "no_note": "1",
212+ "bn": "OpenERP_Invoice_PayNow_" + inv.currency_id.name,
213+ }
214+ return params
215+
216 def _edi_paypal_url(self, cr, uid, ids, field, arg, context=None):
217 res = dict.fromkeys(ids, False)
218 for inv in self.browse(cr, uid, ids, context=context):
219 if inv.type == 'out_invoice' and inv.company_id.paypal_account:
220- params = {
221- "cmd": "_xclick",
222- "business": inv.company_id.paypal_account,
223- "item_name": "%s Invoice %s" % (inv.company_id.name, inv.number or ''),
224- "invoice": inv.number,
225- "amount": inv.residual,
226- "currency_code": inv.currency_id.name,
227- "button_subtype": "services",
228- "no_note": "1",
229- "bn": "OpenERP_Invoice_PayNow_" + inv.currency_id.name,
230- }
231+ params = self._prepare_paypal_params(inv)
232 res[inv.id] = "https://www.paypal.com/cgi-bin/webscr?" + urlencode(params)
233 return res
234
235
236=== added directory 'paypal_installment_plan'
237=== added file 'paypal_installment_plan/__init__.py'
238--- paypal_installment_plan/__init__.py 1970-01-01 00:00:00 +0000
239+++ paypal_installment_plan/__init__.py 2013-10-24 15:18:27 +0000
240@@ -0,0 +1,24 @@
241+# -*- coding: utf-8 -*-
242+##############################################################################
243+#
244+# OpenERP, Open Source Management Solution
245+# Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
246+#
247+# This program is free software: you can redistribute it and/or modify
248+# it under the terms of the GNU Affero General Public License as
249+# published by the Free Software Foundation, either version 3 of the
250+# License, or (at your option) any later version.
251+#
252+# This program is distributed in the hope that it will be useful,
253+# but WITHOUT ANY WARRANTY; without even the implied warranty of
254+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
255+# GNU Affero General Public License for more details.
256+#
257+# You should have received a copy of the GNU Affero General Public License
258+# along with this program. If not, see <http://www.gnu.org/licenses/>.
259+#
260+##############################################################################
261+
262+import paypal_installment_plan
263+
264+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
265
266=== added file 'paypal_installment_plan/__openerp__.py'
267--- paypal_installment_plan/__openerp__.py 1970-01-01 00:00:00 +0000
268+++ paypal_installment_plan/__openerp__.py 2013-10-24 15:18:27 +0000
269@@ -0,0 +1,46 @@
270+# -*- coding: utf-8 -*-
271+##############################################################################
272+#
273+# OpenERP, Open Source Management Solution
274+# Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
275+#
276+# This program is free software: you can redistribute it and/or modify
277+# it under the terms of the GNU Affero General Public License as
278+# published by the Free Software Foundation, either version 3 of the
279+# License, or (at your option) any later version.
280+#
281+# This program is distributed in the hope that it will be useful,
282+# but WITHOUT ANY WARRANTY; without even the implied warranty of
283+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
284+# GNU Affero General Public License for more details.
285+#
286+# You should have received a copy of the GNU Affero General Public License
287+# along with this program. If not, see <http://www.gnu.org/licenses/>.
288+#
289+##############################################################################
290+
291+{
292+ 'name': 'Paypal Installment Plan',
293+ 'version': '1.1',
294+ 'author': 'OpenERP SA',
295+ 'website': 'http://www.openerp.com',
296+ 'description': """
297+ This module allows to use the Installment Plan feature of Paypal for customer invoices.
298+ You will also need to enable this feature on your Paypal account. With this module,
299+ your customers will be able to automatically pay an invoice in several installments
300+ with Paypal. They will be able to sign up for a payment plan in Paypal (with up to four
301+ installments) by clicking on the ‘Pay Now’ button included in the email sent from OpenERP
302+ for the invoice or by clicking on the banner on their invoice in OpenERP. This module
303+ changes the way payment terms are defined. Check the ‘Supports Paypal Installment Plan’
304+ box on the payment term form view to activate the feature for this payment term.
305+ """,
306+ 'author': 'OpenERP SA',
307+ 'website': 'http://www.openerp.com',
308+ 'depends': ['account','sale'],
309+ 'data': [
310+ 'paypal_installment_plan_view.xml'
311+ ],
312+ 'installable': True,
313+ 'auto_install': False,
314+}
315+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
316
317=== added file 'paypal_installment_plan/paypal_installment_plan.py'
318--- paypal_installment_plan/paypal_installment_plan.py 1970-01-01 00:00:00 +0000
319+++ paypal_installment_plan/paypal_installment_plan.py 2013-10-24 15:18:27 +0000
320@@ -0,0 +1,151 @@
321+# -*- coding: utf-8 -*-
322+##############################################################################
323+#
324+# OpenERP, Open Source Management Solution
325+# Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
326+#
327+# This program is free software: you can redistribute it and/or modify
328+# it under the terms of the GNU Affero General Public License as
329+# published by the Free Software Foundation, either version 3 of the
330+# License, or (at your option) any later version.
331+#
332+# This program is distributed in the hope that it will be useful,
333+# but WITHOUT ANY WARRANTY; without even the implied warranty of
334+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
335+# GNU Affero General Public License for more details.
336+#
337+# You should have received a copy of the GNU Affero General Public License
338+# along with this program. If not, see <http://www.gnu.org/licenses/>.
339+#
340+##############################################################################
341+
342+from datetime import datetime
343+from dateutil.relativedelta import relativedelta
344+
345+from openerp.osv import fields, osv
346+
347+from urllib import urlencode
348+from openerp.addons.account import account as apt
349+apt.COMPUTE_METHOD.append(('variable_amount', 'Variable Amounts'))
350+
351+class account_payment_term(osv.Model):
352+ _inherit = "account.payment.term"
353+ _columns = {
354+ 'allow_installments': fields.boolean("Supports Paypal Recurring Payments"),
355+ 'unit_of_time': fields.selection([('weeks', 'Week(s)'), ('months', 'Month(s)')], 'Installment Plan', help="Paypal Installment Plans only support weeks or months as unit of time and a single unit of time for all lines of a payment term."),
356+ 'compute_method': fields.selection (apt.COMPUTE_METHOD, "Compute Method")
357+ }
358+
359+ def _get_next_date(self, date_ref, term_line):
360+ if not term_line.payment_id.allow_installments:
361+ return super(account_payment_term, self)._get_next_date(date_ref, term_line)
362+ if term_line.payment_id.unit_of_time == "weeks":
363+ next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(weeks=term_line.installment_interval))
364+ else:
365+ next_date = (datetime.strptime(date_rhef, '%Y-%m-%d') + relativedelta(months=term_line.installment_interval))
366+ return next_date
367+
368+ def compute_lines(self, cr, uid, ids, value, date_ref=False, context=None):
369+ res = {}
370+ for term_id in ids:
371+ res[term_id] = self.compute(cr, uid, term_id, value, date_ref=date_ref, context=context)
372+ return res
373+
374+ def _check_line_ids(self, cr, uid, ids, context=None):
375+ for payment_term in self.browse(cr, uid, ids, context=context):
376+ if len(payment_term.line_ids) > 4 and payment_term.allow_installments:
377+ return False
378+ return True
379+
380+ def _check_installment_interval(self, cr, uid, ids, context=None):
381+ for payment_term in self.browse(cr, uid, ids, context=context):
382+ for lines in payment_term.line_ids:
383+ if payment_term.unit_of_time == 'weeks' and (lines.installment_interval < 0 or lines.installment_interval > 52):
384+ return False
385+ elif payment_term.unit_of_time == 'months' and (lines.installment_interval < 0 or lines.installment_interval > 12):
386+ return False
387+ return True
388+
389+ _constraints = [
390+ (_check_line_ids, 'You Can not pay more than 4 installments !', ['line_ids']),
391+ (_check_installment_interval, "‘Number of periods’ must be an integer between 0 and 52 if ‘Unit of time’ is ‘Week(s)’ and an integer between 0 and 12 if ‘Unit of time’ is ‘Month(s)’", ['installment_interval']),
392+ ]
393+
394+
395+class account_payment_term_line(osv.Model):
396+ _inherit = "account.payment.term.line"
397+ _columns = {
398+ 'installment_interval': fields.selection([(x,x) for x in range(1,53)], string="Installment Internal"),
399+ 'unit_of_time': fields.selection([('weeks', 'Week(s)'), ('months', 'Month(s)')], 'After', readonly=True),
400+ }
401+
402+class sale_order(osv.Model):
403+ _inherit = 'sale.order'
404+
405+ def _prepare_paypal_params(self, sale):
406+ if not sale.payment_term.allow_installments:
407+ return super(sale_order, self)._prepare_paypal_params(sale)
408+ params = {
409+ "cmd": "_xclick-payment-plan",
410+ "business": sale.company_id.paypal_account,
411+ "item_name": sale.company_id.name + " Sale Order " + sale.name,
412+ "lc": sale.partner_id.country_id.code,
413+ "no_note": 1,
414+ "no_shipping": 1,
415+ "disp_tot": "Y",
416+ "currency_code": sale.currency_id.name,
417+ "on0": "plan",
418+ "os0": "option_0",
419+ "option_select0": "option_0",
420+ "option_select0_name": sale.payment_term.name.replace(" ","+"),
421+ "option_select0_type": "V",
422+ }
423+ count = 0
424+ totlines = sale.payment_term.compute_lines(sale.amount_total, sale.date_order or {}).get(sale.payment_term.id)
425+ for line in sale.payment_term.line_ids:
426+ params.update({"option_select0_a"+str(count): totlines[count][1],
427+ "option_select0_p"+str(count): line.installment_interval,
428+ "option_select0_n"+str(count): 1})
429+ if sale.payment_term.unit_of_time == "weeks":
430+ params.update({"option_select0_t"+str(count): "W"})
431+ else:
432+ params.update({"option_select0_t"+str(count): "M"})
433+ count += 1
434+ return params
435+
436+
437+class account_invoice(osv.Model):
438+ _inherit = 'account.invoice'
439+
440+ def _prepare_paypal_params(self, inv):
441+ if not inv.payment_term.allow_installments:
442+ return super(account_invoice, self)._prepare_paypal_params(inv)
443+ params = {
444+ "cmd": "_xclick-payment-plan",
445+ "business": inv.company_id.paypal_account,
446+ "item_name": inv.company_id.name + " Invoice " + inv.number,
447+ "lc": inv.partner_id.country_id.code,
448+ "no_note": 1,
449+ "no_shipping": 1,
450+ "disp_tot": "Y",
451+ "currency_code": inv.currency_id.name,
452+ "on0": "plan",
453+ "os0": "option_0",
454+ "option_select0": "option_0",
455+ "option_select0_name": inv.payment_term.name.replace(" ","+"),
456+ "option_select0_type": "V",
457+ }
458+ count = 0
459+ totlines = inv.payment_term.compute_lines(inv.amount_total, inv.date_invoice or {}).get(inv.payment_term.id)
460+ for line in inv.payment_term.line_ids:
461+ params.update({"option_select0_a"+str(count): totlines[count][1],
462+ "option_select0_p"+str(count): line.installment_interval,
463+ "option_select0_n"+str(count): 1})
464+ if inv.payment_term.unit_of_time == "weeks":
465+ params.update({"option_select0_t"+str(count): "W"})
466+ else:
467+ params.update({"option_select0_t"+str(count): "M"})
468+ count += 1
469+ return params
470+
471+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
472
473=== added file 'paypal_installment_plan/paypal_installment_plan_view.xml'
474--- paypal_installment_plan/paypal_installment_plan_view.xml 1970-01-01 00:00:00 +0000
475+++ paypal_installment_plan/paypal_installment_plan_view.xml 2013-10-24 15:18:27 +0000
476@@ -0,0 +1,78 @@
477+<?xml version="1.0" encoding="utf-8"?>
478+<openerp>
479+ <data>
480+ <record id="view_payment_term_form_inherit" model="ir.ui.view">
481+ <field name="name">account.payment.term.form</field>
482+ <field name="model">account.payment.term</field>
483+ <field name="inherit_id" ref="account.view_payment_term_form"/>
484+ <field name="arch" type="xml">
485+ <group col="4" position="attributes">
486+ <attribute name="col">6</attribute>
487+ </group>
488+ <field name="active" position="after">
489+ <field name="allow_installments" class="oe_inline"/>
490+ </field>
491+ <field name="note" position="replace">
492+ <group>
493+ <field name="note" nolabel="1" placeholder="Payment term explanation for the customer..."/>
494+ <p class="oe_grey" attrs="{'invisible':[('allow_installments','=',False)]}">
495+ Paypal supports a maximum of four payments for a given payment term.
496+ This means that this payment term should not include more than four
497+ lines.Any line after the fourth one will be ignored by Paypal.
498+ The customer will be able to sign up for an Installment Plan in
499+ Paypal by clicking on the ‘Pay Now’ button in the email they receive
500+ from OpenERP for the invoice or by clicking on the banner on
501+ their invoice.To correctly trigger the Installment Plan in Paypal,
502+ the customer needs to click on ‘Pay Now’ and sign up for the plan
503+ in Paypal on the same day they receive the email
504+ (even if the first payment is due in the future).
505+ </p>
506+ </group>
507+ </field>
508+ <field name="line_ids" position="before">
509+ <group attrs="{'invisible':[('allow_installments','=',False)]}">
510+ <field name="unit_of_time" class="oe_inline" attrs="{'required':[('allow_installments','=',True)]}"/>
511+ </group>
512+ </field>
513+ <field name="line_ids" position="attributes">
514+ <attribute name="context">{'allow_installments': allow_installments, 'unit_of_time': unit_of_time}</attribute>
515+ </field>
516+ </field>
517+ </record>
518+
519+ <record id="view_payment_term_line_form_inherit" model="ir.ui.view">
520+ <field name="name">account.payment.term.line.form</field>
521+ <field name="model">account.payment.term.line</field>
522+ <field name="inherit_id" ref="account.view_payment_term_line_form"/>
523+ <field name="arch" type="xml">
524+ <xpath expr="//group[@name='Due Date Computation']" position="inside">
525+ <field name="installment_interval" invisible="not context.get('allow_installments', False)"/>
526+ <field name="unit_of_time" invisible="not context.get('allow_installments', False)"/>
527+ </xpath>
528+ <field name="days" position="attributes">
529+ <attribute name="invisible">context.get('allow_installments', False)</attribute>
530+ </field>
531+ <field name="days2" position="attributes">
532+ <attribute name="invisible">context.get('allow_installments', False)</attribute>
533+ </field>
534+ </field>
535+ </record>
536+
537+ <record id="view_payment_term_line_tree_inherit" model="ir.ui.view">
538+ <field name="name">account.payment.term.line.tree</field>
539+ <field name="model">account.payment.term.line</field>
540+ <field name="inherit_id" ref="account.view_payment_term_line_tree"/>
541+ <field name="arch" type="xml">
542+ <field name="days" position="after">
543+ <field name="installment_interval" invisible="not context.get('allow_installments', False)"/>
544+ </field>
545+ <field name="days" position="attributes">
546+ <attribute name="invisible">context.get('allow_installments', False)</attribute>
547+ </field>
548+ <field name="days2" position="attributes">
549+ <attribute name="invisible">context.get('allow_installments', False)</attribute>
550+ </field>
551+ </field>
552+ </record>
553+ </data>
554+</openerp>
555
556=== added directory 'paypal_installment_plan/static'
557=== added directory 'paypal_installment_plan/static/description'
558=== added file 'paypal_installment_plan/static/description/icon.png'
559Binary files paypal_installment_plan/static/description/icon.png 1970-01-01 00:00:00 +0000 and paypal_installment_plan/static/description/icon.png 2013-10-24 15:18:27 +0000 differ
560=== modified file 'portal/portal_data.xml'
561--- portal/portal_data.xml 2013-10-01 15:59:01 +0000
562+++ portal/portal_data.xml 2013-10-24 15:18:27 +0000
563@@ -90,12 +90,7 @@
564 <field name="name">Paypal</field>
565 <field name="form_template"><![CDATA[
566 % if object.company_id.paypal_account:
567-<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
568- <input type="hidden" name="cmd" value="_xclick"/>
569- <input type="hidden" name="business" value="${object.company_id.paypal_account}"/>
570- <input type="hidden" name="item_name" value="${object.company_id.name} ${kind.title()} ${reference}"/>
571- <input type="hidden" name="amount" value="${amount}"/>
572- <input type="hidden" name="currency_code" value="${currency.name}"/>
573+<form action="${object.paypal_url}" method="post" target="_blank">
574 <input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
575 </form>
576 % endif
577
578=== modified file 'sale/edi/sale_order.py'
579--- sale/edi/sale_order.py 2012-12-17 14:43:06 +0000
580+++ sale/edi/sale_order.py 2013-10-24 15:18:27 +0000
581@@ -181,22 +181,28 @@
582 order_line.pop('price_subtotal', None)
583 return super(sale_order,self).edi_import(cr, uid, edi_document, context=context)
584
585+
586+ def _prepare_paypal_params(self, sale):
587+ params = {
588+ "cmd": "_xclick",
589+ "business": sale.company_id.paypal_account,
590+ "item_name": sale.company_id.name + " Sale Order " + sale.name,
591+ "invoice": sale.name,
592+ "amount": sale.amount_total,
593+ "currency_code": sale.currency_id.name,
594+ "button_subtype": "services",
595+ "no_note": "1",
596+ "bn": "OpenERP_Invoice_PayNow_" + sale.currency_id.name,
597+ }
598+ return params
599+
600+
601 def _edi_paypal_url(self, cr, uid, ids, field, arg, context=None):
602 res = dict.fromkeys(ids, False)
603 for order in self.browse(cr, uid, ids, context=context):
604 if order.order_policy in ('prepaid', 'manual') and \
605 order.company_id.paypal_account and order.state != 'draft':
606- params = {
607- "cmd": "_xclick",
608- "business": order.company_id.paypal_account,
609- "item_name": order.company_id.name + " Order " + order.name,
610- "invoice": order.name,
611- "amount": order.amount_total,
612- "currency_code": order.pricelist_id.currency_id.name,
613- "button_subtype": "services",
614- "no_note": "1",
615- "bn": "OpenERP_Order_PayNow_" + order.pricelist_id.currency_id.name,
616- }
617+ params = self._prepare_paypal_params(order)
618 res[order.id] = "https://www.paypal.com/cgi-bin/webscr?" + urlencode(params)
619 return res
620

Subscribers

People subscribed via source and target branches

to all changes: