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

Proposed by gpa(OpenERP)
Status: Superseded
Proposed branch: lp:~openbig/bigconsulting/improvement_changes_milestone1
Merge into: lp:bigconsulting
Diff against target: 603 lines (+259/-80)
4 files modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+82/-10)
account_invoice_cash_discount/account_invoice_cash_discount_view.xml (+17/-0)
account_invoice_cash_discount/wizard/account_pay_invoice.py (+146/-69)
account_invoice_cash_discount/wizard/account_pay_invoice_view.xml (+14/-1)
To merge this branch: bzr merge lp:~openbig/bigconsulting/improvement_changes_milestone1
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+29277@code.launchpad.net

This proposal has been superseded by a proposal from 2010-07-06.

Description of the change

added new changes in milestone1

To post a comment you must log in.
45. By gpa(OpenERP)

removeline

46. By gpa(OpenERP)

remove unwanted line which generated during the calulation button clock

47. By gpa(OpenERP)

changes in wocheck context

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py'
2--- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-07-01 14:49:31 +0000
3+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-07-06 13:02:24 +0000
4@@ -44,17 +44,88 @@
5 'payment_id': fields.many2one('account.payment.term','Associated Payment Term'),
6 'credit_account_id': fields.many2one('account.account', 'Credit Account'),
7 'debit_account_id': fields.many2one('account.account', 'Debit Account'),
8+ 'payment_term_ids': fields.one2many('account.payment.term.line', 'cash_account_discount_id', 'Payment Term Lines'),
9 }
10 account_cash_discount()
11
12+class account_payment_term_line(osv.osv):
13+ _inherit = "account.payment.term.line"
14+ _columns = {
15+ 'cash_account_discount_id': fields.many2one('account.cash.discount', 'Discount Lines',),
16+ 'payment_id': fields.many2one('account.payment.term', 'Payment Term', required=False, select=True),
17+ 'compl_cash_discount':fields.boolean('Use Complete Cash Discount'),
18+ }
19+account_payment_term_line()
20+
21 class account_invoice(osv.osv):
22 _inherit = "account.invoice"
23
24+ def _get_amount(self, cr, uid, ids, resudial_amonut, payment_term, context=None):
25+
26+ """
27+ This function return the Amount to paid according to the payment term cash discount payment term lines
28+ """
29+
30+ if context is None:
31+ context = {}
32+
33+ tax_obj = self.pool.get('account.tax')
34+ invoice = self.browse(cr, uid, ids[0], context=context)
35+
36+ if invoice.date_invoice:
37+ date1 = invoice.date_invoice
38+ else:
39+ date1 = time.strftime('%Y-%m-%d')
40+
41+ if 'date_p' in context and context['date_p']:
42+ date2 = context['date_p']
43+ else:
44+ date2 = time.strftime('%Y-%m-%d')
45+
46+ if date1 >= date2:
47+ from_dt = time.mktime(time.strptime(date1,'%Y-%m-%d'))
48+ to_dt = time.mktime(time.strptime(date2,'%Y-%m-%d'))
49+ diff_day = (from_dt-to_dt)/(3600*24)
50+ else:
51+ from_dt = time.mktime(time.strptime(date2,'%Y-%m-%d'))
52+ to_dt = time.mktime(time.strptime(date1,'%Y-%m-%d'))
53+ diff_day = (from_dt-to_dt)/(3600*24)
54+
55+ discount = 0.0
56+ amount = 0.0
57+ payment_line_found = False
58+ if payment_term:
59+ payment_term_lines = self.pool.get('account.payment.term').browse(cr, uid, payment_term, context=context)
60+ for payment_term_line_id in payment_term_lines.line_ids:
61+ payment_use_complete = payment_term_line_id.compl_cash_discount
62+ if payment_use_complete:
63+ if payment_term_lines.cash_discount_ids:
64+ dis = 0
65+ for discount_line in payment_term_lines.cash_discount_ids:
66+ if diff_day >= dis and diff_day <= discount_line.delay:
67+ if resudial_amonut:
68+ dis1 = 0
69+ if discount_line.payment_term_ids:
70+ payment_line_found = True
71+ for dis_payment_id in discount_line.payment_term_ids:
72+ if diff_day >= dis1 and diff_day<= dis_payment_id.days:
73+ if dis_payment_id.value == 'procent':
74+ amount = resudial_amonut * dis_payment_id.value_amount
75+ elif dis_payment_id.value == 'fixed':
76+ amount = dis_payment_id.value_amount
77+ else:
78+ amount = resudial_amonut
79+ dis1 = dis_payment_id.days
80+ dis = discount_line.delay
81+ else:
82+ amount = resudial_amonut
83+
84+ return {'amount':amount,'found':payment_line_found}
85+
86 def _get_payment(self, cr, uid, ids, resudial_amonut, payment_term, context=None):
87 """
88 This function return the Discount according to the payment term cash discount term
89 """
90-
91 if context is None:
92 context = {}
93
94@@ -79,6 +150,7 @@
95 from_dt = time.mktime(time.strptime(date2,'%Y-%m-%d'))
96 to_dt = time.mktime(time.strptime(date1,'%Y-%m-%d'))
97 diff_day = (from_dt-to_dt)/(3600*24)
98+
99 discount = 0.0
100 if payment_term:
101 payment_term_lines = self.pool.get('account.payment.term').browse(cr, uid, payment_term, context=context)
102@@ -92,7 +164,7 @@
103 discount = res
104 dis = discount_line.delay
105 return discount
106-
107+
108 def _get_account(self, cr, uid, ids, resudial_amonut, payment_term, context=None):
109 """
110 This function return the Account according to the payment term cash discount term
111@@ -136,6 +208,7 @@
112 return account_id
113
114 def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''):
115+
116 if context is None:
117 context = {}
118 #TODO check if we can use different period for payment and the writeoff line
119@@ -222,7 +295,7 @@
120 if 'tax_move_ids' in context and context['tax_move_ids']:
121 move_line = context['tax_move_ids']
122 for move_line_id in move_line:
123- move_line_data = self.pool.get('account.move.line').browse(cr, uid,move_line_id)
124+ move_line_data = move_line_obj.browse(cr, uid,move_line_id)
125 l3 = {
126 'debit': move_line_data.debit,
127 'credit': move_line_data.credit,
128@@ -237,8 +310,8 @@
129 'tax_amount':move_line_data.tax_amount,
130 }
131 lines.append((0, 0, l3))
132- self.pool.get('account.move.line').unlink(cr, uid,[move_line_id])
133- self.pool.get('account.move').unlink(cr, uid,[move_line_data.move_id.id])
134+ move_line_obj.unlink(cr, uid,[move_line_id])
135+ move_obj.unlink(cr, uid,[move_line_data.move_id.id])
136 else:
137 if amount_discount>0.0:
138 for line in invoice.invoice_line:
139@@ -267,8 +340,8 @@
140
141 if 'discount_move_ids' in context and context['discount_move_ids']:
142 dis_move_id = context['discount_move_ids'][0]
143- move_id = self.pool.get('account.move.line').search(cr, uid,[('move_id','=',dis_move_id)])
144- move_line_data = self.pool.get('account.move.line').browse(cr, uid, move_id[0])
145+ move_id = move_line_obj.search(cr, uid,[('move_id','=',dis_move_id)])
146+ move_line_data = move_line_obj.browse(cr, uid, move_id[0])
147 l4 = {
148 'debit': move_line_data.debit,
149 'credit':move_line_data.credit,
150@@ -282,7 +355,7 @@
151 }
152 lines.append((0, 0, l4))
153
154- self.pool.get('account.move').unlink(cr, uid, context['discount_move_ids'])
155+ move_obj.unlink(cr, uid, context['discount_move_ids'])
156 else:
157 if amount_discount>0:
158 if 'account_id' in context and context['account_id']:
159@@ -305,7 +378,7 @@
160 lines.append((0, 0, l4))
161
162 move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
163- move_id = self.pool.get('account.move').create(cr, uid, move, context=context)
164+ move_id = move_obj.create(cr, uid, move, context=context)
165
166 line_ids = []
167 total = 0.0
168@@ -317,7 +390,6 @@
169 if l.account_id.id==src_account_id:
170 line_ids.append(l.id)
171 total += (l.debit or 0.0) - (l.credit or 0.0)
172-
173 if (not round(total,int(config['price_accuracy']))) or writeoff_acc_id:
174 self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context)
175 else:
176
177=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount_view.xml'
178--- account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-06-29 13:22:59 +0000
179+++ account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-07-06 13:02:24 +0000
180@@ -15,6 +15,10 @@
181 <field name="delay" select="1"/>
182 <field name="discount" select="1"/>
183 <field name="discount_account_id" />
184+ <group colspan="4">
185+ <separator string="Related Payment Terms Lines" colspan="4"/>
186+ <field name="payment_term_ids" widget="one2many_list" nolabel="1"/>
187+ </group>
188 </form>
189 </field>
190 </record>
191@@ -84,6 +88,19 @@
192 </xpath>
193 </field>
194 </record>
195+
196+ <record id="account_payment_term_line_view1" model="ir.ui.view">
197+ <field name="name">account.payment.term.line.form</field>
198+ <field name="model">account.payment.term.line</field>
199+ <field name="type">form</field>
200+ <field name="inherit_id" ref="account.view_payment_term_line_form"/>
201+ <field name="arch" type="xml">
202+ <field name="days2" position="after">
203+ <label string="" colspan="2"/>
204+ <field name="compl_cash_discount"/>
205+ </field>
206+ </field>
207+ </record>
208
209 </data>
210 </openerp>
211
212=== modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py'
213--- account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-07-01 14:49:31 +0000
214+++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-07-06 13:02:24 +0000
215@@ -22,7 +22,6 @@
216 from lxml import etree
217 from osv import fields, osv
218 from tools.translate import _
219-#import decimal_precision as dp
220
221 class account_invoice_pay_writeoff(osv.osv_memory):
222 """
223@@ -41,6 +40,7 @@
224 }
225
226 def pay_and_reconcile_writeoff(self, cr, uid, ids, context=None):
227+ pay_invoice = self.pool.get('account.invoice.pay')
228 data = self.read(cr, uid, ids,context=context)[0]
229 context.update({'write_off':data})
230 self.pool.get('account.invoice.pay').pay_and_reconcile(cr, uid, ids, context=context)
231@@ -58,7 +58,7 @@
232 'amount': fields.float('Amount paid', required=True),
233 'name': fields.char('Entry Name', size=64, required=True),
234 'date': fields.date('Date payment', required=True),
235- 'cash_residual_amount': fields.float('Residual Amount', readonly=True),
236+ 'cash_residual_amount': fields.float('Residual Amount'),
237 'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True),
238 'period_id': fields.many2one('account.period', 'Period', required=True),
239 'cash_amount':fields.float('Cash Discount Amount',),
240@@ -69,7 +69,7 @@
241 'discount_move_ids': fields.many2many('account.move', 'account_discount_move_rel', 'discount_account_id', 'discount_move_id', 'Account Discount Moves'),
242 'tax_move_ids': fields.many2many('account.move.line', 'account_tax_move_rel', 'tax_account_id', 'tax_move_id', 'Account Taxes Moves'),
243 }
244-
245+
246 def _get_period(self, cr, uid, context=None):
247 ids = self.pool.get('account.period').find(cr, uid, context=context)
248 period_id = False
249@@ -80,34 +80,19 @@
250 def _get_amount(self, cr, uid, context=None):
251 obj_inv = self.pool.get('account.invoice')
252 invoice = obj_inv.browse(cr, uid, context['id'], context=context)
253- discount = obj_inv._get_payment(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context)
254- residual_amount = invoice.residual - discount
255+ amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context)
256+ context.update({'found':amount['found']})
257+ amount = amount['amount']
258+ discount = obj_inv._get_payment(cr, uid, [context['id']] ,amount, invoice.payment_term.id, context=context)
259+ residual_amount = amount - discount
260 return residual_amount
261
262- def on_change_ammount(self, cr, uid, ids, amount, context=None):
263- """
264- Function return the Discount according to the Amount paid and Payment Term Cash Discount
265- """
266- res = {}
267- obj_inv = self.pool.get('account.invoice')
268- invoice = obj_inv.browse(cr, uid, context['id'], context=context)
269- discount = obj_inv._get_payment(cr, uid, [context['id']] , invoice.residual, invoice.payment_term.id, context=context)
270- diff_amount = round(invoice.residual - (amount + discount),2)
271- return {'value' : {'cash_residual_amount':diff_amount}}
272-
273- def on_change_cash_discount_amount(self, cr, uid, ids, discount_amount, amount, context=None):
274- ### Return discount amount
275- res = {}
276- obj_inv = self.pool.get('account.invoice')
277- invoice = obj_inv.browse(cr, uid, context['id'], context=context)
278- diff_amount = 0.0
279- diff_amount = round(invoice.residual - (amount + discount_amount),2)
280- return {'value' : {'cash_amount':discount_amount,'cash_residual_amount':diff_amount}}
281-
282 def _get_discount(self, cr, uid, context=None):
283 obj_inv = self.pool.get('account.invoice')
284 invoice = obj_inv.browse(cr, uid, context['id'], context=context)
285- discount = obj_inv._get_payment(cr, uid, [context['id']] , invoice.residual, invoice.payment_term.id, context=context)
286+ amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context)
287+ amount = amount['amount']
288+ discount = obj_inv._get_payment(cr, uid, [context['id']] , amount, invoice.payment_term.id, context=context)
289 return discount
290
291 def _get_account(self, cr, uid, context=None):
292@@ -122,13 +107,47 @@
293 account = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, account)
294 return account
295
296- def default_get(self, cr, uid, fields, context=None):
297- res = super(account_invoice_pay, self).default_get(cr, uid, fields, context=context)
298- invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context)
299- if invoice.state in ['draft', 'proforma2', 'cancel']:
300- raise osv.except_osv(_('Error !'), _('Can not pay draft/proforma/cancel invoice.'))
301- return res
302-
303+ _defaults = {
304+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
305+ 'period_id': _get_period,
306+ 'amount': _get_amount,
307+ 'cash_amount':_get_discount,
308+ 'account_id':_get_account,
309+ 'cash_residual_amount': lambda *a:0.0,
310+ 'cal_method_selection':lambda *a :'method_gross_methodology',
311+ }
312+
313+ def on_change_ammount(self, cr, uid, ids, amount, context=None):
314+ """
315+ Function return the Discount according to the Amount paid and Payment Term Cash Discount
316+ """
317+ res = {}
318+ obj_inv = self.pool.get('account.invoice')
319+ invoice = obj_inv.browse(cr, uid, context['id'], context=context)
320+ cal_amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context)
321+
322+ old_cal_amount = cal_amount['amount']
323+ discount = obj_inv._get_payment(cr, uid, [context['id']] , old_cal_amount, invoice.payment_term.id, context=context)
324+ old_amount = old_cal_amount
325+ diff_amount = round(old_amount - (amount + discount),2)
326+
327+ return {'value' : {'cash_residual_amount':diff_amount}}
328+
329+ def on_change_cash_discount_amount(self, cr, uid, ids, discount_amount, amount, context=None):
330+ ### Return discount amount
331+ res = {}
332+ obj_inv = self.pool.get('account.invoice')
333+ invoice = obj_inv.browse(cr, uid, context['id'], context=context)
334+ cal_amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context)
335+ old_cal_amount = cal_amount['amount']
336+ discount = obj_inv._get_payment(cr, uid, [context['id']] , amount, invoice.payment_term.id, context=context)
337+ old_amount = old_cal_amount
338+
339+ diff_amount = 0.0
340+ diff_amount = old_amount - (amount + discount_amount)
341+
342+ return {'value' : {'cash_amount':discount_amount,'cash_residual_amount':diff_amount}}
343+
344 def _calculation(self, cr, uid, ids, context=None):
345 invoice_obj = self.pool.get('account.invoice')
346 data = self.read(cr, uid, ids,context=context)[0]
347@@ -137,7 +156,7 @@
348 invoice_tax_obj = self.pool.get("account.invoice.tax")
349 move_obj = self.pool.get('account.move')
350 move_line_obj = self.pool.get('account.move.line')
351-
352+
353 ######## to get ref
354 if invoice.type in ('in_invoice', 'in_refund'):
355 ref = invoice.reference
356@@ -153,7 +172,6 @@
357 name = invoice.invoice_line and invoice.invoice_line[0].name or invoice.number
358
359 ##### Entry in the discount account moves and entry in the tax account moves
360-
361 ### Entry for taxes in the line of wizard tax
362 if data.get('cash_amount',0.0)>0.0:
363 lines3 = []
364@@ -202,7 +220,7 @@
365 discount_account_id = self.pool.get('account.journal').browse(cr, uid, journal_id).default_credit_account_id.id
366 else:
367 discount_account_id = data['account_id']
368- ###############################################3
369+ ###############################################
370
371 l4 = {
372 'debit': direction * data.get('cash_amount',0.0)<0 and - direction * data.get('cash_amount',0.0),
373@@ -218,27 +236,57 @@
374 move = {'ref': ref, 'line_id': lines4, 'journal_id': data['journal_id'], 'period_id': data['period_id'], }
375 move_id = move_obj.create(cr, uid, move, context=context)
376 self.write(cr, uid, ids, {'discount_move_ids':[(6,0,[move_id])]}, context)
377+
378 return True
379
380- _defaults = {
381- 'date': lambda *a: time.strftime('%Y-%m-%d'),
382- 'period_id': _get_period,
383- 'amount': _get_amount,
384- 'cash_amount':_get_discount,
385- 'account_id':_get_account,
386- 'cash_residual_amount': lambda *a:0.0,
387- 'cal_method_selection':lambda *a :'method_gross_methodology',
388- }
389+ def default_get(self, cr, uid, fields, context=None):
390+ res = super(account_invoice_pay, self).default_get(cr, uid, fields, context=context)
391+ invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context)
392+ if invoice.state in ['draft', 'proforma2', 'cancel','paid']:
393+ raise osv.except_osv(_('Error !'), _('Can not pay draft/proforma/cancel/Done invoice.'))
394+ return res
395+
396+ def _message(self, cr, uid, ids, context=None):
397+ mod_obj = self.pool.get('ir.model.data')
398+ data = self.read(cr, uid, ids,context=context)[0]
399
400+ if data['discount_move_ids']:
401+ context.update({'discount_move_ids':data['discount_move_ids']})
402+
403+ if data['tax_move_ids']:
404+ context.update({'tax_move_ids':data['tax_move_ids']})
405+
406+ if data['amount']:
407+ context.update({'amount':data['amount']})
408+
409+ if data['cash_amount']:
410+ context.update({'cash_amount':data['cash_amount']})
411+
412+ model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_message')], context=context)
413+ resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
414+
415+ return {
416+ 'name': _('Message'),
417+ 'context': context,
418+ 'view_type': 'form',
419+ 'view_mode': 'form',
420+ 'res_model': 'account.message',
421+ 'views': [(resource_id,'form')],
422+ 'type': 'ir.actions.act_window',
423+ 'target': 'new',
424+ }
425+
426 def wo_check(self, cr, uid, ids, context=None):
427 cur_obj = self.pool.get('res.currency')
428 mod_obj = self.pool.get('ir.model.data')
429+ obj_inv = self.pool.get('account.invoice')
430+
431 if context is None:
432 context = {}
433 data = self.read(cr, uid, ids,context=context)[0]
434+
435 invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context)
436 journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context)
437-
438 # Here we need that:
439 # The invoice total amount in company's currency <> paid amount in company currency
440 # (according to the correct day rate, invoicing rate and payment rate are may be different)
441@@ -251,13 +299,13 @@
442 inv_amount_company_currency += aml.debit
443 inv_amount_company_currency -= aml.credit
444 inv_amount_company_currency = abs(inv_amount_company_currency)
445-
446 # Get the current amount paid in company currency
447 if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
448 ctx = {'date':data['date']}
449 amount_paid = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, data['amount'], round=True, context=ctx)
450 else:
451- amount_paid = data['amount']
452+ amount_paid = data['amount'] + data['cash_amount']
453+
454 # Get the old payment if there are some
455 if invoice.payment_ids:
456 debit=credit=0.0
457@@ -267,27 +315,42 @@
458 amount_paid+=abs(debit-credit)
459
460 # Test if there is a difference according to currency rouding setting
461- if self.pool.get('res.currency').is_zero(cr, uid, invoice.company_id.currency_id,
462- (amount_paid - inv_amount_company_currency)):
463+ amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context)
464+ found_h = amount['found']
465+
466+ if found_h:
467+ if context['discount_move_ids']:
468+ context.update({'discount_move_ids':context['discount_move_ids']})
469+
470+ if context['tax_move_ids']:
471+ context.update({'tax_move_ids':context['tax_move_ids']})
472+
473 return self.pay_and_reconcile(cr, uid, ids, context=context)
474 else:
475- model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_invoice_pay_writeoff')], context=context)
476- resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
477- return {
478- 'name': _('Information addendum'),
479- 'context': context,
480- 'view_type': 'form',
481- 'view_mode': 'form',
482- 'res_model': 'account.invoice.pay.writeoff',
483- 'views': [(resource_id,'form')],
484- 'type': 'ir.actions.act_window',
485- 'target': 'new',
486- }
487-
488+
489+ if self.pool.get('res.currency').is_zero(cr, uid, invoice.company_id.currency_id,
490+ (amount_paid - inv_amount_company_currency)):
491+ return self.pay_and_reconcile(cr, uid, ids, context=context)
492+
493+ else:
494+ model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_invoice_pay_writeoff')], context=context)
495+ resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
496+ return {
497+ 'name': _('Information addendum'),
498+ 'context': context,
499+ 'view_type': 'form',
500+ 'view_mode': 'form',
501+ 'res_model': 'account.invoice.pay.writeoff',
502+ 'views': [(resource_id,'form')],
503+ 'type': 'ir.actions.act_window',
504+ 'target': 'new',
505+ }
506+
507 def pay_and_reconcile(self, cr, uid, ids, context=None):
508 cur_obj = self.pool.get('res.currency')
509 if context is None:
510 context = {}
511+
512 data = self.read(cr, uid, ids,context=context)[0]
513 writeoff_account_id = False
514 writeoff_journal_id = False
515@@ -297,9 +360,9 @@
516 writeoff_account_id = context['write_off']['writeoff_acc_id']
517 writeoff_journal_id = context['write_off']['writeoff_journal_id']
518 comment = context['write_off']['comment']
519-
520+
521 amount = data['amount'] + data['cash_amount']
522-
523+
524 invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context)
525 journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context=context)
526 # Compute the amount in company's currency, with the journal currency (which is equal to payment currency)
527@@ -326,12 +389,16 @@
528
529 context.update({'account_id':data['account_id'],'cash_amount':data['cash_amount'],'amount_currency':data['amount'] + data['cash_amount']})
530
531- if data['discount_move_ids']:
532- context.update({'discount_move_ids':data['discount_move_ids']})
533+ if context.get('discount_move_ids',False):
534+ context = context
535+ else:
536+ context.update({'discount_move_ids':data['discount_move_ids']})
537
538- if data['tax_move_ids']:
539+ if context.get('tax_move_ids',False):
540+ context = context
541+ else:
542 context.update({'tax_move_ids':data['tax_move_ids']})
543-
544+
545 if data['cash_amount']:
546 context.update({'cash_amount':data['cash_amount']})
547
548@@ -344,6 +411,7 @@
549 return {}
550
551 def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False):
552+
553 res = super(account_invoice_pay,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar)
554 fields=res.get('fields',{})
555 word = "Supplier Cash Discount Account"
556@@ -358,4 +426,13 @@
557
558 account_invoice_pay()
559
560+class account_message(osv.osv_memory):
561+ _name = "account.message"
562+ def _check(self, cr, uid, ids, context=None):
563+ data = self.read(cr, uid, ids,context=context)[0]
564+ result = self.pool.get('account.invoice.pay').wo_check(cr, uid, ids, context=context)
565+ return result
566+
567+account_message()
568+
569 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
570\ No newline at end of file
571
572=== modified file 'account_invoice_cash_discount/wizard/account_pay_invoice_view.xml'
573--- account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-07-01 12:19:51 +0000
574+++ account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-07-06 13:02:24 +0000
575@@ -34,7 +34,7 @@
576 <label string ="" colspan="2"/>
577 <button icon="gtk-cancel" special="cancel" string="Cancel"/>
578 <button icon="gtk-execute" string="Partial Payment" name="pay_and_reconcile" type="object"/>
579- <button icon="gtk-execute" string="Full Payment" name="wo_check" type="object"/>
580+ <button icon="gtk-execute" string="Full-Payment" name="_message" type="object"/>
581 </group>
582 </form>
583 </field>
584@@ -70,5 +70,18 @@
585 </form>
586 </field>
587 </record>
588+
589+ <record id="view_account_message" model="ir.ui.view">
590+ <field name="name">account.message.form</field>
591+ <field name="model">account.message</field>
592+ <field name="type">form</field>
593+ <field name="arch" type="xml">
594+ <form string="Your Messages">
595+ <label colspan="8" string="Are you really want to reconcile this invoice" />
596+ <button icon="gtk-execute" string="OK" name="_check" type="object"/>
597+ </form>
598+ </field>
599+ </record>
600+
601 </data>
602 </openerp>
603\ No newline at end of file

Subscribers

People subscribed via source and target branches