Merge lp:~openbig/bigconsulting/account_payment_discount_ext into lp:bigconsulting

Proposed by gpa(OpenERP)
Status: Merged
Merged at revision: 81
Proposed branch: lp:~openbig/bigconsulting/account_payment_discount_ext
Merge into: lp:bigconsulting
Diff against target: 612 lines (+323/-211)
7 files modified
account_payment_discount_extension/account_payment_discount.py (+8/-1)
account_payment_discount_extension/account_payment_discount_view.xml (+14/-3)
account_payment_discount_extension/account_payment_disocunt_wizard.xml (+2/-1)
account_payment_discount_extension/wizard/__init__.py (+2/-1)
account_payment_discount_extension/wizard/wizard_discount_pay.py (+80/-0)
account_payment_discount_extension/wizard/wizard_payment_discount_order.py (+217/-0)
account_payment_discount_extension/wizard/wizard_payment_order1.py (+0/-205)
To merge this branch: bzr merge lp:~openbig/bigconsulting/account_payment_discount_ext
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+33763@code.launchpad.net

This proposal supersedes a proposal from 2010-08-26.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_payment_discount_extension/account_payment_discount.py'
--- account_payment_discount_extension/account_payment_discount.py 2010-08-23 08:21:01 +0000
+++ account_payment_discount_extension/account_payment_discount.py 2010-08-26 12:51:47 +0000
@@ -48,7 +48,14 @@
48 delay = payment_data[0].delay48 delay = payment_data[0].delay
49 self.write(cr, uid, [inv.id], {'next_payment_date':(datetime.now() + relativedelta(days=delay)).strftime('%Y-%m-%d')})49 self.write(cr, uid, [inv.id], {'next_payment_date':(datetime.now() + relativedelta(days=delay)).strftime('%Y-%m-%d')})
50 return data50 return data
51 51
52 def copy(self, cr, uid, id, default=None, context=None):
53 if default is None:
54 default = {}
55 default = default.copy()
56 default.update({'next_payment_date':False})
57 return super(account_invoice, self).copy(cr, uid, id, default, context)
58
52account_invoice()59account_invoice()
5360
54class payment_line(osv.osv):61class payment_line(osv.osv):
5562
=== modified file 'account_payment_discount_extension/account_payment_discount_view.xml'
--- account_payment_discount_extension/account_payment_discount_view.xml 2010-08-23 07:25:41 +0000
+++ account_payment_discount_extension/account_payment_discount_view.xml 2010-08-26 12:51:47 +0000
@@ -34,7 +34,7 @@
34 <field name="inherit_id" ref="account_payment_extension.view_payment_order_form_ext1"/>34 <field name="inherit_id" ref="account_payment_extension.view_payment_order_form_ext1"/>
35 <field name="arch" type="xml">35 <field name="arch" type="xml">
36 <xpath expr="//button[@string='Select invoices to pay/receive payment']" position="replace">36 <xpath expr="//button[@string='Select invoices to pay/receive payment']" position="replace">
37 <button name="%(wizard_populate_payment_ext111)d" string="Select invoices to pay/receive payment" type="action" attrs="{'invisible':[('state','=','done')]}"/>37 <button name="%(wizard_populate_payment_discount_ext)d" string="Select invoices to pay/receive payment" type="action" attrs="{'invisible':[('state','=','done')]}"/>
38 </xpath>38 </xpath>
39 </field>39 </field>
40 </record>40 </record>
@@ -49,7 +49,6 @@
49 <field name="cash_discount" />49 <field name="cash_discount" />
50 <field name="discount_date" />50 <field name="discount_date" />
51 <field name="pay_amount" />51 <field name="pay_amount" />
52 <label stirng=""/>
53 </xpath>52 </xpath>
54 </field>53 </field>
55 </record>54 </record>
@@ -58,7 +57,7 @@
58 <field name="name">payment.order.form1</field>57 <field name="name">payment.order.form1</field>
59 <field name="model">payment.order</field>58 <field name="model">payment.order</field>
60 <field name="inherit_id" ref="account_payment.view_payment_order_form"/>59 <field name="inherit_id" ref="account_payment.view_payment_order_form"/>
61 <field name="type">form</field>60 <field name="type">tree</field>
62 <field name="arch" type="xml">61 <field name="arch" type="xml">
63 <xpath expr="//tree/field[@name='amount']" position="after">62 <xpath expr="//tree/field[@name='amount']" position="after">
64 <field name="cash_discount" />63 <field name="cash_discount" />
@@ -81,5 +80,17 @@
81 </field>80 </field>
82 </record>81 </record>
83 82
83 <record id="view_payment_order_wizard_form" model="ir.ui.view">
84 <field name="name">payment.order.form1</field>
85 <field name="model">payment.order</field>
86 <field name="type">form</field>
87 <field name="inherit_id" ref="account_payment.view_payment_order_form"/>
88 <field name="arch" type="xml">
89 <xpath expr="//button[@string='Make Payments']" position="replace">
90 <button name="%(wizard_pay_discount_payment)d" states="open" string="Make Payments" type="action" />
91 </xpath>
92 </field>
93 </record>
94
84 </data>95 </data>
85</openerp>96</openerp>
8697
=== modified file 'account_payment_discount_extension/account_payment_disocunt_wizard.xml'
--- account_payment_discount_extension/account_payment_disocunt_wizard.xml 2010-08-23 08:19:07 +0000
+++ account_payment_discount_extension/account_payment_disocunt_wizard.xml 2010-08-26 12:51:47 +0000
@@ -1,6 +1,7 @@
1<?xml version="1.0" encoding="utf-8"?>1<?xml version="1.0" encoding="utf-8"?>
2<openerp>2<openerp>
3 <data>3 <data>
4 <wizard id="wizard_populate_payment_ext111" menu="True" model="payment.order" name="populate_payment_ext_filter" string="Populate payment to pay"/>4 <wizard id="wizard_populate_payment_discount_ext" menu="False" model="payment.order" name="populate_payment_discount_ext" string="Populate payment to pay"/>
5 <wizard id="wizard_pay_discount_payment" menu="False" model="payment.order" name="pay_discount_payment" string="Pay"/>
5 </data>6 </data>
6</openerp>7</openerp>
78
=== modified file 'account_payment_discount_extension/wizard/__init__.py'
--- account_payment_discount_extension/wizard/__init__.py 2010-08-20 12:17:29 +0000
+++ account_payment_discount_extension/wizard/__init__.py 2010-08-26 12:51:47 +0000
@@ -20,7 +20,8 @@
20#20#
21##############################################################################21##############################################################################
2222
23import wizard_payment_order123import wizard_payment_discount_order
24import wizard_discount_pay
2425
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:26# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2627
2728
=== added file 'account_payment_discount_extension/wizard/wizard_discount_pay.py'
--- account_payment_discount_extension/wizard/wizard_discount_pay.py 1970-01-01 00:00:00 +0000
+++ account_payment_discount_extension/wizard/wizard_discount_pay.py 2010-08-26 12:51:47 +0000
@@ -0,0 +1,80 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import wizard
24from osv import osv
25import pooler
26from osv import fields
27import time
28
29
30def _launch_wizard(self, cr, uid, data, context):
31 """
32 Search for a wizard to launch according to the type.
33 If type is manual. just confirm the order.
34 """
35 pool = pooler.get_pool(cr.dbname)
36 order_ref = pool.get('payment.order')
37 order_line = pool.get('payment.line')
38 order = order_ref.browse(cr,uid,data['id'],context)
39 invoice_obj = pool.get('account.invoice')
40
41 t= order.mode and order.mode.type.code or 'manual'
42 if t == 'manual' :
43 order_ref.set_done(cr,uid,data['id'],context)
44 return {}
45
46 journal_id = order.mode.journal.id
47 period_ids = pool.get('account.period').find(cr, uid, context=context)
48
49 for pay_line in order.line_ids:
50 invoice_data = invoice_obj.browse(cr, uid, pay_line.move_line_id.invoice.id, context=context)
51 account_id = order.mode.journal.default_credit_account_id and order.mode.journal.default_credit_account_id.id #invoice_data.partner_id.property_account_payable.id
52 invoice_obj.pay_and_reconcile(cr, uid, [invoice_data.id],
53 pay_line.amount_currency, account_id, period_ids[0], journal_id, False,
54 period_ids[0], journal_id, context, pay_line.name)
55
56 gw = order_ref.get_wizard(t)
57 if not gw:
58 order_ref.set_done(cr,uid,data['id'],context)
59 return {}
60
61 mod_obj = pool.get('ir.model.data')
62 act_obj = pool.get('ir.actions.wizard')
63 module, wizard= gw
64 result = mod_obj._get_id(cr, uid, module, wizard)
65 id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
66 result = act_obj.read(cr, uid, [id])[0]
67 #result['context'] = str({'fiscalyear': data['form']['fiscalyear']})
68 return result
69
70class wizard_pay(wizard.interface):
71
72 states= {'init' : {'actions': [],
73 'result':{'type':'action',
74 'action':_launch_wizard,
75 'state':'end'}
76 }
77 }
78wizard_pay('pay_discount_payment')
79
80# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
081
=== added file 'account_payment_discount_extension/wizard/wizard_payment_discount_order.py'
--- account_payment_discount_extension/wizard/wizard_payment_discount_order.py 1970-01-01 00:00:00 +0000
+++ account_payment_discount_extension/wizard/wizard_payment_discount_order.py 2010-08-26 12:51:47 +0000
@@ -0,0 +1,217 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import wizard
24import pooler
25from tools.misc import UpdateableStr
26import time
27
28
29FORM = UpdateableStr()
30
31FIELDS = {
32 'entries': {'string':'Entries', 'type':'many2many', 'relation':'account.move.line',},
33 'communication2': {'string':'Communication 2', 'type':'char', 'size': 64, 'help':'The successor message of payment communication.'},
34}
35
36field_duedate={
37 'duedate': {'string':'Due Date', 'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d'),},
38 'amount': {'string':'Amount', 'type':'float', 'help': 'Next step will automatically select payments up to this amount.'}
39 }
40arch_duedate='''<?xml version="1.0" encoding="utf-8"?>
41<form string="Search Payment lines" col="2">
42 <field name="duedate" />
43 <field name="amount" />
44</form>'''
45
46
47def search_entries(self, cr, uid, data, context):
48
49 search_due_date = data['form']['duedate']
50 pool = pooler.get_pool(cr.dbname)
51 order_obj = pool.get('payment.order')
52 line_obj = pool.get('account.move.line')
53 invoice_obj = pool.get('account.invoice')
54 payment = order_obj.browse(cr, uid, data['id'],
55 context=context)
56 ctx = ''
57 if payment.mode:
58 ctx = '''context="{'journal_id': %d}"''' % payment.mode.journal.id
59
60 # Search for move line to pay:
61 domain = [('reconcile_id', '=', False),('account_id.type', '=', payment.type)]#,('account_id.type', '=', payment.type),('amount_to_pay', '<>', 0)]
62# domain = domain + ['|',('date_maturity','<',search_due_date),('date_maturity','=',False)]
63 #if payment.mode:
64 # domain = [('payment_type','=',payment.mode.type.id)] + domain
65 sel_line_ids = line_obj.search(cr, uid, domain, order='date_maturity', context=context)
66 line_ids = []
67
68 for line in line_obj.browse(cr, uid, sel_line_ids, context):
69 if line.invoice.id:
70 invoice_data = invoice_obj.browse(cr, uid, line.invoice.id, context=context)
71 if invoice_data.next_payment_date:
72 if invoice_data.next_payment_date >=search_due_date:
73 line_ids.append(line.id)
74
75 FORM.string = '''<?xml version="1.0" encoding="utf-8"?>
76<form string="Populate Payment:">
77 <field name="entries" colspan="4" height="300" width="800" nolabel="1"
78 domain="[('id', 'in', [%s])]" %s/>
79 <separator string="Extra message of payment communication" colspan="4"/>
80 <field name="communication2" colspan="4"/>
81</form>''' % (','.join([str(x) for x in line_ids]), ctx)
82
83 selected_ids = []
84 amount = data['form']['amount']
85 if amount:
86 if payment.mode and payment.mode.require_bank_account:
87 line2bank = line_obj.line2bank(cr, uid, line_ids, payment.mode.id, context)
88 else:
89 line2bank = None
90 # If user specified an amount, search what moves match the criteria taking into account
91 # if payment mode allows bank account to be null.
92 for line in line_obj.browse(cr, uid, line_ids, context):
93 if abs(line.amount_to_pay) <= amount:
94 if line2bank and not line2bank.get(line.id):
95 continue
96 amount -= abs(line.amount_to_pay)
97 selected_ids.append(line.id)
98 return {
99 'entries': selected_ids,
100 }
101
102def create_payment(self, cr, uid, data, context):
103 line_ids= data['form']['entries'][0][2]
104 if not line_ids: return {}
105
106 pool= pooler.get_pool(cr.dbname)
107 order_obj = pool.get('payment.order')
108 order_line_obj = pool.get('payment.line')
109 line_obj = pool.get('account.move.line')
110 invoice_obj = pool.get('account.invoice')
111 payment_term_obj = pool.get('account.payment.term')
112
113 tax_obj = pool.get('account.tax')
114 invoice_tax_obj = pool.get("account.invoice.tax")
115
116 payment = order_obj.browse(cr, uid, data['id'],
117 context=context)
118 t = payment.mode and payment.mode.type.id or None
119 line2bank = pool.get('account.move.line').line2bank(cr, uid,
120 line_ids, t, context)
121
122 ## Finally populate the current payment with new lines:
123
124 for line in line_obj.browse(cr, uid, line_ids, context=context):
125 invoice_data = invoice_obj.browse(cr, uid, line.invoice.id, context=context)
126 discount = 0.0
127 account = False
128 payment_data = payment_term_obj.browse(cr, uid, invoice_data.payment_term.id).cash_discount_ids
129
130 if payment_data:
131 cash_discount = payment_data[0].discount
132 discount = invoice_data.amount_total * cash_discount /100
133 account =payment_data[0].sup_discount_account_id.id
134 dis_next_date = invoice_data.next_payment_date
135
136 if payment.date_prefered == "now":
137 #no payment date => immediate payment
138 date_to_pay = False
139 elif payment.date_prefered == 'due':
140 date_to_pay = line.date_maturity
141 elif payment.date_prefered == 'fixed':
142 date_to_pay = payment.date_planned
143
144 order_line_obj.create(cr,uid,{
145 'move_line_id': line.id,
146 'amount_currency': line.amount_to_pay,
147 'bank_id': line2bank.get(line.id),
148 'order_id': payment.id,
149 'partner_id': line.partner_id and line.partner_id.id or False,
150 'communication': (line.ref and line.name!='/' and line.ref+'. '+line.name) or line.ref or line.name or '/',
151 'communication2': data['form']['communication2'],
152 'date': date_to_pay,
153 'currency': line.invoice and line.invoice.currency_id.id or False,
154 'account_id': line.account_id.id,
155 'cash_discount':discount,
156 'discount_date':dis_next_date,
157 'pay_amount':(line.amount_to_pay-discount),
158 }, context=context)
159
160 return {}
161
162def _get_defaults(self, cr, uid, data, context):
163 pool= pooler.get_pool(cr.dbname)
164 order_obj = pool.get('payment.order')
165 plan_date = order_obj.browse(cr, uid, data['id'], context=context).date_planned
166 data['form']['duedate'] = plan_date
167 return data['form']
168
169class wizard_payment_order(wizard.interface):
170 """
171 Create a payment object with lines corresponding to the account move line
172 to pay according to the date provided by the user and the mode-type payment of the order.
173 Hypothesis:
174 - Small number of non-reconcilied move line , payment mode and bank account type,
175 - Big number of partner and bank account.
176
177 If a type is given, unsuitable account move lines are ignored.
178 """
179 states = {
180
181 'init': {
182 'actions': [_get_defaults],
183 'result': {
184 'type': 'form',
185 'arch': arch_duedate,
186 'fields':field_duedate,
187 'state': [
188 ('end','_Cancel'),
189 ('search','_Search', '', True)
190 ]
191 },
192 },
193
194 'search': {
195 'actions': [search_entries],
196 'result': {
197 'type': 'form',
198 'arch': FORM,
199 'fields': FIELDS,
200 'state': [
201 ('end','_Cancel'),
202 ('create','_Add to payment order', '', True)
203 ]
204 },
205 },
206 'create': {
207 'actions': [],
208 'result': {
209 'type': 'action',
210 'action': create_payment,
211 'state': 'end'}
212 },
213 }
214
215wizard_payment_order('populate_payment_discount_ext')
216
217# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file218\ No newline at end of file
1219
=== removed file 'account_payment_discount_extension/wizard/wizard_payment_order1.py'
--- account_payment_discount_extension/wizard/wizard_payment_order1.py 2010-08-23 08:19:07 +0000
+++ account_payment_discount_extension/wizard/wizard_payment_order1.py 1970-01-01 00:00:00 +0000
@@ -1,205 +0,0 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import wizard
24import pooler
25from tools.misc import UpdateableStr
26import time
27
28
29FORM = UpdateableStr()
30
31FIELDS = {
32 'entries': {'string':'Entries', 'type':'many2many', 'relation':'account.move.line',},
33 'communication2': {'string':'Communication 2', 'type':'char', 'size': 64, 'help':'The successor message of payment communication.'},
34}
35
36field_duedate={
37 'duedate': {'string':'Due Date', 'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d'),},
38 'amount': {'string':'Amount', 'type':'float', 'help': 'Next step will automatically select payments up to this amount.'}
39 }
40arch_duedate='''<?xml version="1.0" encoding="utf-8"?>
41<form string="Search Payment lines" col="2">
42 <field name="duedate" />
43 <field name="amount" />
44</form>'''
45
46
47def search_entries(self, cr, uid, data, context):
48
49 search_due_date = data['form']['duedate']
50 pool = pooler.get_pool(cr.dbname)
51 order_obj = pool.get('payment.order')
52 line_obj = pool.get('account.move.line')
53 invoice_obj = pool.get('account.invoice')
54 payment = order_obj.browse(cr, uid, data['id'],
55 context=context)
56 ctx = ''
57 if payment.mode:
58 ctx = '''context="{'journal_id': %d}"''' % payment.mode.journal.id
59
60 # Search for move line to pay:
61 domain = [('reconcile_id', '=', False)]#,('account_id.type', '=', payment.type),('amount_to_pay', '<>', 0)]
62# domain = domain + ['|',('date_maturity','<',search_due_date),('date_maturity','=',False)]
63 #if payment.mode:
64 # domain = [('payment_type','=',payment.mode.type.id)] + domain
65 sel_line_ids = line_obj.search(cr, uid, domain, order='date_maturity', context=context)
66 line_ids = []
67
68 for line in line_obj.browse(cr, uid, sel_line_ids, context):
69 if line.invoice.id:
70 invoice_data = invoice_obj.browse(cr, uid, line.invoice.id, context=context)
71 if invoice_data.next_payment_date:
72 if invoice_data.next_payment_date >=search_due_date:
73 line_ids.append(line.id)
74
75 FORM.string = '''<?xml version="1.0" encoding="utf-8"?>
76 <form string="Populate Payment:">
77 <field name="entries" colspan="4" height="300" width="800" nolabel="1"
78 domain="[('id', 'in', [%s])]" %s/>
79 <separator string="Extra message of payment communication" colspan="4"/>
80 <field name="communication2" colspan="4"/>
81 </form>''' % (','.join([str(x) for x in line_ids]), ctx)
82
83 selected_ids = []
84 amount = data['form']['amount']
85 if amount:
86 if payment.mode and payment.mode.require_bank_account:
87 line2bank = line_obj.line2bank(cr, uid, line_ids, payment.mode.id, context)
88 else:
89 line2bank = None
90 # If user specified an amount, search what moves match the criteria taking into account
91 # if payment mode allows bank account to be null.
92 for line in line_obj.browse(cr, uid, line_ids, context):
93 if abs(line.amount_to_pay) <= amount:
94 if line2bank and not line2bank.get(line.id):
95 continue
96 amount -= abs(line.amount_to_pay)
97 selected_ids.append(line.id)
98 return {
99 'entries': selected_ids,
100 }
101
102def create_payment(self, cr, uid, data, context):
103 line_ids= data['form']['entries'][0][2]
104 if not line_ids: return {}
105
106 pool= pooler.get_pool(cr.dbname)
107 order_obj = pool.get('payment.order')
108 line_obj = pool.get('account.move.line')
109 invoice_obj = pool.get('account.invoice')
110 payment_term_obj = pool.get('account.payment.term')
111 payment_line = pool.get('payment.line')
112 payment = order_obj.browse(cr, uid, data['id'],
113 context=context)
114 t = payment.mode and payment.mode.type.id or None
115 line2bank = line_obj.line2bank(cr, uid,
116 line_ids, t, context)
117
118 ## Finally populate the current payment with new lines:
119
120 for line in line_obj.browse(cr, uid, line_ids, context=context):
121
122 invoice_data = invoice_obj.browse(cr, uid, line.invoice.id, context=context)
123 discount = 0.0
124 payment_data = payment_term_obj.browse(cr, uid, invoice_data.payment_term.id).cash_discount_ids
125 if payment_data:
126 cash_discount = payment_data[0].discount
127 discount = invoice_data.amount_total * cash_discount /100
128 dis_next_date = invoice_data.next_payment_date
129
130 if payment.date_prefered == "now":
131 #no payment date => immediate payment
132 date_to_pay = False
133 elif payment.date_prefered == 'due':
134 date_to_pay = line.date_maturity
135 elif payment.date_prefered == 'fixed':
136 date_to_pay = payment.date_planned
137
138 payment_line.create(cr,uid,{
139 'move_line_id': line.id,
140 'amount_currency': line.amount_to_pay,
141 'bank_id': line2bank.get(line.id),
142 'order_id': payment.id,
143 'partner_id': line.partner_id and line.partner_id.id or False,
144 'communication': (line.ref and line.name!='/' and line.ref+'. '+line.name) or line.ref or line.name or '/',
145 'communication2': data['form']['communication2'],
146 'date': date_to_pay,
147 'currency': line.invoice and line.invoice.currency_id.id or False,
148 'account_id': line.account_id.id,
149 'cash_discount':discount,
150 'discount_date':dis_next_date,
151 'pay_amount':(line.amount_to_pay+discount),
152 }, context=context)
153
154 return {}
155
156
157class wizard_payment_order(wizard.interface):
158 """
159 Create a payment object with lines corresponding to the account move line
160 to pay according to the date provided by the user and the mode-type payment of the order.
161 Hypothesis:
162 - Small number of non-reconcilied move line , payment mode and bank account type,
163 - Big number of partner and bank account.
164
165 If a type is given, unsuitable account move lines are ignored.
166 """
167 states = {
168
169 'init': {
170 'actions': [],
171 'result': {
172 'type': 'form',
173 'arch': arch_duedate,
174 'fields':field_duedate,
175 'state': [
176 ('end','_Cancel'),
177 ('search','_Search', '', True)
178 ]
179 },
180 },
181
182 'search': {
183 'actions': [search_entries],
184 'result': {
185 'type': 'form',
186 'arch': FORM,
187 'fields': FIELDS,
188 'state': [
189 ('end','_Cancel'),
190 ('create','_Add to payment order', '', True)
191 ]
192 },
193 },
194 'create': {
195 'actions': [],
196 'result': {
197 'type': 'action',
198 'action': create_payment,
199 'state': 'end'}
200 },
201 }
202
203wizard_payment_order('populate_payment_ext_filter')
204
205# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches