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

Proposed by Atik Agewan(OpenERP)
Status: Merged
Merged at revision: 53
Proposed branch: lp:~openbig/bigconsulting/multi_currency_milestone2
Merge into: lp:bigconsulting
Diff against target: 748 lines (+408/-68)
2 files modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+353/-58)
account_invoice_cash_discount/account_invoice_cash_discount_view.xml (+55/-10)
To merge this branch: bzr merge lp:~openbig/bigconsulting/multi_currency_milestone2
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+31034@code.launchpad.net

Description of the change

changes in milestone2 multicurrency

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
1=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py'
2--- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-07-23 11:30:07 +0000
3+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-07-27 10:15:58 +0000
4@@ -1,7 +1,7 @@
5 # -*- encoding: utf-8 -*-
6 ##############################################################################
7 #
8-# OpenERP, Open Source Management Solution
9+# OpenERP, Open Source Management Solution
10 # Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
11 # $Id$
12 #
13@@ -63,7 +63,7 @@
14
15 class account_invoice(osv.osv):
16 _inherit = "account.invoice"
17-
18+
19 def _get_amount(self, cr, uid, ids, resudial_amonut, payment_term, context=None):
20 """
21 This function return the Amount to paid according to the payment term cash discount payment term lines
22@@ -72,16 +72,16 @@
23 context = {}
24 tax_obj = self.pool.get('account.tax')
25 invoice = self.browse(cr, uid, ids[0], context=context)
26-
27+
28 if invoice.date_invoice:
29 date1 = invoice.date_invoice
30 else:
31 date1 = time.strftime('%Y-%m-%d')
32-
33- if 'date_p' in context and context['date_p']:
34+
35+ if 'date_p' in context and context['date_p']:
36 date2 = context['date_p']
37 else:
38- date2 = time.strftime('%Y-%m-%d')
39+ date2 = time.strftime('%Y-%m-%d')
40
41 if date1 >= date2:
42 from_dt = time.mktime(time.strptime(date1,'%Y-%m-%d'))
43@@ -91,12 +91,12 @@
44 from_dt = time.mktime(time.strptime(date2,'%Y-%m-%d'))
45 to_dt = time.mktime(time.strptime(date1,'%Y-%m-%d'))
46 diff_day = (from_dt-to_dt)/(3600*24)
47-
48+
49 discount = 0.0
50 amount = 0.0
51 tol_days = 0.0
52 payment_line_found = False
53-
54+
55 if payment_term:
56 payment_term_lines = self.pool.get('account.payment.term').browse(cr, uid, payment_term, context=context)
57 if payment_term_lines.line_ids:
58@@ -115,28 +115,28 @@
59 res = resudial_amonut
60 amount = res
61 dis = payment_line.days
62-
63+
64 return {'amount':amount,'tol_days':tol_days,'found':payment_line_found}
65-
66+
67 def _get_payment(self, cr, uid, ids, resudial_amonut, payment_term, context=None):
68 """
69 This function return the Discount according to the payment term cash discount term
70 """
71 if context is None:
72 context = {}
73-
74+
75 tax_obj = self.pool.get('account.tax')
76 invoice = self.browse(cr, uid, ids[0], context=context)
77-
78+
79 if invoice.date_invoice:
80 date1 = invoice.date_invoice
81 else:
82 date1 = time.strftime('%Y-%m-%d')
83-
84- if 'date_p' in context and context['date_p']:
85+
86+ if 'date_p' in context and context['date_p']:
87 date2 = context['date_p']
88 else:
89- date2 = time.strftime('%Y-%m-%d')
90+ date2 = time.strftime('%Y-%m-%d')
91
92 if date1 >= date2:
93 from_dt = time.mktime(time.strptime(date1,'%Y-%m-%d'))
94@@ -146,10 +146,10 @@
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+
100 tolerance = self._get_amount(cr, uid, ids, resudial_amonut, payment_term, context)
101 tolerance_days = tolerance['tol_days']
102-
103+
104 discount = 0.0
105 if payment_term:
106 payment_term_lines = self.pool.get('account.payment.term').browse(cr, uid, payment_term, context=context)
107@@ -163,29 +163,29 @@
108 discount = res
109 dis = discount_line.delay + tolerance_days
110 return discount
111-
112+
113 def _get_account(self, cr, uid, ids, resudial_amonut, payment_term, context=None):
114 """
115 This function return the Account according to the payment term cash discount term
116 """
117 if context is None:
118 context = {}
119-
120+
121 account_id = False
122-
123+
124 tax_obj = self.pool.get('account.tax')
125 invoice = self.browse(cr, uid, ids[0], context=context)
126-
127+
128 if invoice.date_invoice:
129 date1 = invoice.date_invoice
130- else:
131+ else:
132 date1 = time.strftime('%Y-%m-%d')
133-
134- if 'date_p' in context and context['date_p']:
135+
136+ if 'date_p' in context and context['date_p']:
137 date2 = context['date_p']
138 else:
139- date2 = time.strftime('%Y-%m-%d')
140-
141+ date2 = time.strftime('%Y-%m-%d')
142+
143 if date1 > date2:
144 from_dt = time.mktime(time.strptime(date1,'%Y-%m-%d'))
145 to_dt = time.mktime(time.strptime(date2,'%Y-%m-%d'))
146@@ -193,11 +193,11 @@
147 else:
148 from_dt = time.mktime(time.strptime(date2,'%Y-%m-%d'))
149 to_dt = time.mktime(time.strptime(date1,'%Y-%m-%d'))
150- diff_day = (from_dt-to_dt)/(3600*24)
151-
152+ diff_day = (from_dt-to_dt)/(3600*24)
153+
154 tolerance = self._get_amount(cr, uid, ids, resudial_amonut, payment_term, context)
155 tolerance_days = tolerance['tol_days']
156-
157+
158 if payment_term:
159 payment_term_lines = self.pool.get('account.payment.term').browse(cr, uid, payment_term, context=context)
160 if payment_term_lines.cash_discount_ids:
161@@ -207,29 +207,29 @@
162 if diff_day >= dis and diff_day <= discount_line.delay + tolerance_days:
163 if invoice.type in ('in_invoice', 'in_refund'):
164 account_id = discount_line.sup_discount_account_id.id
165- else:
166+ else:
167 account_id = discount_line.discount_account_id.id
168 dis = discount_line.delay + tolerance_days
169- return account_id
170-
171+ return account_id
172+
173 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=''):
174 if context is None:
175 context = {}
176 #TODO check if we can use different period for payment and the writeoff line
177 assert len(ids)==1, "Can only pay one invoice at a time"
178 invoice = self.browse(cr, uid, ids[0])
179-
180+
181 tax_obj = self.pool.get('account.tax')
182 invoice_tax_obj = self.pool.get("account.invoice.tax")
183 move_line_obj = self.pool.get('account.move.line')
184 move_obj = self.pool.get('account.move')
185-
186- amount_discount = 0.0
187+
188+ amount_discount = 0.0
189 if invoice.payment_term:
190 # Return the discount on for the payment term
191 amount_discount = self._get_payment(cr, uid, ids, pay_amount, invoice.payment_term.id, context=context)
192
193-
194+
195 src_account_id = invoice.account_id.id
196 # Take the seq as name for move
197 types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
198@@ -239,7 +239,7 @@
199 date=context['date_p']
200 else:
201 date=time.strftime('%Y-%m-%d')
202-
203+
204 # Take the amount in currency and the currency of the payment
205 if 'amount_currency' in context and context['amount_currency'] and 'currency_id' in context and context['currency_id']:
206 amount_currency = context['amount_currency']
207@@ -247,18 +247,18 @@
208 else:
209 amount_currency = False
210 currency_id = False
211-
212+
213 if invoice.type in ('in_invoice', 'in_refund'):
214 ref = invoice.reference
215 else:
216 ref = self._convert_ref(cr, uid, invoice.number)
217-
218+
219 discount_amount = 0.0
220 tax_total_amount = 0.0
221-
222+
223 if 'cash_amount' in context and context['cash_amount']:
224 discount_amount = context['cash_amount']
225-
226+
227 # Pay attention to the sign for both debit/credit AND amount_currency
228 l1 = {
229 'debit': direction * (pay_amount)>0 and direction * (pay_amount),
230@@ -270,12 +270,12 @@
231 'currency_id':currency_id,
232 'amount_currency':amount_currency and direction * amount_currency or 0.0,
233 }
234-
235+
236 ### if we change the amount paid and in the disocunt then it used the changes discount
237-
238+
239 if amount_discount != discount_amount and discount_amount>0.0:
240 amount_discount = discount_amount
241-
242+
243 l2 = {
244 'debit': direction * (pay_amount-amount_discount)<0 and - direction * (pay_amount-amount_discount),
245 'credit': direction * (pay_amount-amount_discount)>0 and direction * (pay_amount-amount_discount),
246@@ -289,12 +289,12 @@
247
248 if not name:
249 name = invoice.invoice_line and invoice.invoice_line[0].name or invoice.number
250-
251+
252 l1['name'] = name
253 l2['name'] = name
254 lines = [(0, 0, l1), (0, 0, l2)]
255-
256- ### When we make payment by pay invoice wizard and if found the taxes move then directly take the entry from the wizard
257+
258+ ### When we make payment by pay invoice wizard and if found the taxes move then directly take the entry from the wizard
259 if 'tax_move_ids' in context and context['tax_move_ids']:
260 move_line = context['tax_move_ids']
261 for move_line_id in move_line:
262@@ -316,7 +316,7 @@
263 move_line_obj.unlink(cr, uid,[move_line_id])
264 move_obj.unlink(cr, uid,[move_line_data.move_id.id])
265 else:
266- if amount_discount>0.0:
267+ if amount_discount>0.0:
268 for line in invoice.invoice_line:
269 if line.invoice_line_tax_id:
270 for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, amount_discount, line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id):
271@@ -340,9 +340,9 @@
272 }
273 l3['name'] = name
274 lines.append((0, 0, l3))
275-
276+
277 ### When we make payment by pay invoice wizard and if found the discount moves in wizard discount move then directly take the entry from the wizard
278- if 'discount_move_ids' in context and context['discount_move_ids']:
279+ if 'discount_move_ids' in context and context['discount_move_ids']:
280 move_line = context['discount_move_ids']
281 for move_line_id in move_line:
282 move_line_data = move_line_obj.browse(cr, uid,move_line_id)
283@@ -365,7 +365,7 @@
284 else:
285 if amount_discount>0:
286 if 'account_id' in context and context['account_id']:
287- account_id = context['account_id']
288+ account_id = context['account_id']
289 if tax_total_amount>0:
290 amount_discount = (amount_discount - tax_total_amount)
291 else:
292@@ -382,15 +382,15 @@
293 }
294 l4['name'] = name
295 lines.append((0, 0, l4))
296-
297+
298 move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
299 move_id = move_obj.create(cr, uid, move, context=context)
300-
301+
302 line_ids = []
303 total = 0.0
304 line = self.pool.get('account.move.line')
305 cr.execute('select id from account_move_line where move_id in ('+str(move_id)+','+str(invoice.move_id.id)+')')
306-
307+
308 lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) )
309 for l in lines+invoice.payment_ids:
310 if l.account_id.id==src_account_id:
311@@ -404,28 +404,323 @@
312 # Update the stored value (fields.function), so we write to trigger recompute
313 self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context)
314 return True
315-
316+
317 account_invoice()
318
319 class account_move_line(osv.osv):
320 _name = 'account.move.line'
321 _inherit = 'account.move.line'
322-
323+
324 def _invoice(self, cr, uid, ids, name, arg, context=None):
325 res = {}
326 if ids:
327 return super(account_move_line, self)._invoice(cr, uid, ids, name, arg, context)
328 else:
329 return res
330-
331+
332 def _invoice_search(self, cr, uid, obj, name, args, context={}):
333 return super(account_move_line, self)._invoice_search(cr, uid, obj, name, args, context=context)
334-
335+
336 _columns = {
337 'invoice': fields.function(_invoice, method=True, string='Invoice',
338 type='many2one', relation='account.invoice', fnct_search=_invoice_search),
339 }
340 account_move_line()
341
342+class res_company(osv.osv):
343+ _inherit = "res.company"
344+
345+ _columns = {
346+ 'expense_account_id': fields.many2one('account.account', 'Expenses',required=True),
347+ 'revenue_account_id': fields.many2one('account.account', 'Revenues',required=True),
348+ }
349+res_company()
350+
351+class res_company_wizard(osv.osv_memory):
352+ _name = 'res.company.wizard'
353+ _columns = {
354+ 'expense_account_id': fields.many2one('account.account', 'Expenses',required=True),
355+ 'revenue_account_id': fields.many2one('account.account', 'Revenues',required=True),
356+ }
357+ _defaults = {
358+ 'expense_account_id': lambda *a: 2,
359+ 'revenue_account_id': lambda *a: 3,
360+ }
361+
362+ def set_default(self, cr, uid, ids, context=None):
363+ company_id =self.pool.get('res.users').browse(cr,uid,[uid],context)[0].company_id
364+ for o in self.browse(cr, uid, ids, context=context):
365+ self.pool.get('res.company').write(cr, uid, [company_id.id], {'expense_account_id':o.expense_account_id.id,'revenue_account_id':o.revenue_account_id.id})
366+ return {
367+ 'view_type': 'form',
368+ "view_mode": 'form',
369+ 'res_model': 'ir.actions.configuration.wizard',
370+ 'type': 'ir.actions.act_window',
371+ 'target': 'new',
372+ }
373+
374+ def action_cancel(self,cr,uid,ids,conect=None):
375+ return {
376+ 'view_type': 'form',
377+ "view_mode": 'form',
378+ 'res_model': 'ir.actions.configuration.wizard',
379+ 'type': 'ir.actions.act_window',
380+ 'target':'new',
381+ }
382+
383+res_company_wizard()
384+
385+class account_bank_statement(osv.osv):
386+ _inherit="account.bank.statement"
387+
388+ def button_confirm(self, cr, uid, ids, context={}):
389+ done = []
390+ res_currency_obj = self.pool.get('res.currency')
391+ res_users_obj = self.pool.get('res.users')
392+ account_move_obj = self.pool.get('account.move')
393+ account_move_line_obj = self.pool.get('account.move.line')
394+ cur_obj = self.pool.get('res.currency')
395+ account_bank_statement_line_obj = \
396+ self.pool.get('account.bank.statement.line')
397+ account_bank_reconcil = self.pool.get('account.bank.statement.reconcile')
398+ company_currency_id = res_users_obj.browse(cr, uid, uid,
399+ context=context).company_id.currency_id.id
400+ for st in self.browse(cr, uid, ids, context):
401+ if not st.state=='draft':
402+ continue
403+ if not (abs(st.balance_end - st.balance_end_real) < 0.0001):
404+ raise osv.except_osv(_('Error !'),
405+ _('The statement balance is incorrect !\n') +
406+ _('The expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end))
407+ if (not st.journal_id.default_credit_account_id) \
408+ or (not st.journal_id.default_debit_account_id):
409+ raise osv.except_osv(_('Configuration Error !'),
410+ _('Please verify that an account is defined in the journal.'))
411+
412+ for line in st.move_line_ids:
413+ if line.state <> 'valid':
414+ raise osv.except_osv(_('Error !'),
415+ _('The account entries lines are not in valid state.'))
416+ # for bank.statement.lines
417+ # In line we get reconcile_id on bank.ste.rec.
418+ # in bank stat.rec we get line_new_ids on bank.stat.rec.line
419+ for move in st.line_ids:
420+ context.update({'date':move.date})
421+ move_id = account_move_obj.create(cr, uid, {
422+ 'journal_id': st.journal_id.id,
423+ 'period_id': st.period_id.id,
424+ 'date': move.date,
425+ }, context=context)
426+ account_bank_statement_line_obj.write(cr, uid, [move.id], {
427+ 'move_ids': [(4,move_id, False)]
428+ })
429+ if not move.amount:
430+ continue
431+ torec = []
432+ if move.amount >= 0:
433+ account_id = st.journal_id.default_credit_account_id.id
434+ else:
435+ account_id = st.journal_id.default_debit_account_id.id
436+ acc_cur = ((move.amount<=0) and st.journal_id.default_debit_account_id) or move.account_id
437+ amount = res_currency_obj.compute(cr, uid, st.currency.id,
438+ company_currency_id, move.amount, context=context,
439+ account=acc_cur)
440+ if move.reconcile_id and move.reconcile_id.line_new_ids:
441+ for newline in move.reconcile_id.line_new_ids:
442+ amount += newline.amount
443+
444+ val = {
445+ 'name': move.name,
446+ 'date': move.date,
447+ 'ref': move.ref,
448+ 'move_id': move_id,
449+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
450+ 'account_id': (move.account_id) and move.account_id.id,
451+ 'credit': ((amount>0) and amount) or 0.0,
452+ 'debit': ((amount<0) and -amount) or 0.0,
453+ 'statement_id': st.id,
454+ 'journal_id': st.journal_id.id,
455+ 'period_id': st.period_id.id,
456+ 'currency_id': st.currency.id,
457+ }
458+
459+ amount = res_currency_obj.compute(cr, uid, st.currency.id,
460+ company_currency_id, move.amount, context=context,
461+ account=acc_cur)
462+ if st.currency.id <> company_currency_id:
463+ amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
464+ st.currency.id, amount, context=context,
465+ account=acc_cur)
466+ val['amount_currency'] = -amount_cur
467+
468+ if move.account_id and move.account_id.currency_id and move.account_id.currency_id.id <> company_currency_id:
469+ val['currency_id'] = move.account_id.currency_id.id
470+ if company_currency_id==move.account_id.currency_id.id:
471+ amount_cur = move.amount
472+ else:
473+ amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
474+ move.account_id.currency_id.id, amount, context=context,
475+ account=acc_cur)
476+ val['amount_currency'] = amount_cur
477+
478+ torec.append(account_move_line_obj.create(cr, uid, val , context=context))
479+
480+ if move.reconcile_id and move.reconcile_id.line_new_ids:
481+ for newline in move.reconcile_id.line_new_ids:
482+ account_move_line_obj.create(cr, uid, {
483+ 'name': newline.name or move.name,
484+ 'date': move.date,
485+ 'ref': move.ref,
486+ 'move_id': move_id,
487+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
488+ 'account_id': (newline.account_id) and newline.account_id.id,
489+ 'debit': newline.amount>0 and newline.amount or 0.0,
490+ 'credit': newline.amount<0 and -newline.amount or 0.0,
491+ 'statement_id': st.id,
492+ 'journal_id': st.journal_id.id,
493+ 'period_id': st.period_id.id,
494+
495+ }, context=context)
496+
497+ amount_currency = False
498+ currency_id = False
499+ partner_acc_id = False
500+
501+ if st.currency.id <> company_currency_id:
502+ amount_currency = move.amount
503+ expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id
504+ revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id
505+ currency_id = st.currency.id
506+
507+ if move.type=='customer':
508+ partner_acc_id = move.partner_id.property_account_receivable.id
509+ elif move.type=='supplier':
510+ partner_acc_id = move.partner_id.property_account_payable.id
511+
512+ for line in move.reconcile_id.line_ids:
513+ balance = 0.0
514+ move_line_data = self.pool.get('account.move.line').browse(cr, uid, line.id, context=context)
515+ context.update({'amount': move_line_data.amount_currency, 'currency_id': move_line_data.currency_id.id})
516+ balance = self.pool.get("account.bank.statement.reconcile").browse(cr, uid, move.reconcile_id.id, context=context).total_balance
517+
518+ if balance < 0.00:
519+ account_move_line_obj.create(cr, uid, {
520+ 'name': move.name,
521+ 'date': move.date,
522+ 'ref': move.ref,
523+ 'move_id': move_id,
524+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
525+ 'account_id': expense_acc.id,
526+ 'credit': abs(balance),
527+ 'debit': 0.0,
528+ 'statement_id': st.id,
529+ 'journal_id': st.journal_id.id,
530+ 'period_id': st.period_id.id,
531+ 'amount_currency': amount_currency,
532+ 'currency_id': currency_id,
533+ }, context=context)
534+
535+ account_move_line_obj.create(cr, uid, {
536+ 'name': move.name,
537+ 'date': move.date,
538+ 'ref': move.ref,
539+ 'move_id': move_id,
540+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
541+ 'account_id': partner_acc_id,
542+ 'credit': 0.0,
543+ 'debit': abs(balance),
544+ 'statement_id': st.id,
545+ 'journal_id': st.journal_id.id,
546+ 'period_id': st.period_id.id,
547+ 'amount_currency': amount_currency,
548+ 'currency_id': currency_id,
549+ }, context=context)
550+
551+ elif balance > 0.00:
552+ account_move_line_obj.create(cr, uid, {
553+ 'name': move.name,
554+ 'date': move.date,
555+ 'ref': move.ref,
556+ 'move_id': move_id,
557+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
558+ 'account_id':revene_acc.id,
559+ 'credit': abs(balance),
560+ 'debit': 0.0,
561+ 'statement_id': st.id,
562+ 'journal_id': st.journal_id.id,
563+ 'period_id': st.period_id.id,
564+ 'amount_currency': amount_currency,
565+ 'currency_id': currency_id,
566+ }, context=context)
567+
568+ account_move_line_obj.create(cr, uid, {
569+ 'name': move.name,
570+ 'date': move.date,
571+ 'ref': move.ref,
572+ 'move_id': move_id,
573+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
574+ 'account_id': partner_acc_id,
575+ 'credit': 0.0,
576+ 'debit': abs(balance),
577+ 'statement_id': st.id,
578+ 'journal_id': st.journal_id.id,
579+ 'period_id': st.period_id.id,
580+ 'amount_currency': amount_currency,
581+ 'currency_id': currency_id,
582+ }, context=context)
583+ else:
584+ continue
585+
586+ account_move_line_obj.create(cr, uid, {
587+ 'name': move.name,
588+ 'date': move.date,
589+ 'ref': move.ref,
590+ 'move_id': move_id,
591+ 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
592+ 'account_id': account_id,
593+ 'credit': ((amount < 0) and -amount) or 0.0,
594+ 'debit': ((amount > 0) and amount) or 0.0,
595+ 'statement_id': st.id,
596+ 'journal_id': st.journal_id.id,
597+ 'period_id': st.period_id.id,
598+ 'amount_currency': amount_currency,
599+ 'currency_id': currency_id,
600+ }, context=context)
601+
602+ for line in account_move_line_obj.browse(cr, uid, [x.id for x in
603+ account_move_obj.browse(cr, uid, move_id,
604+ context=context).line_id],
605+ context=context):
606+ if line.state <> 'valid':
607+ raise osv.except_osv(_('Error !'),
608+ _('Account move line "%s" is not valid') % line.name)
609+
610+ if move.reconcile_id and move.reconcile_id.line_ids:
611+ torec += map(lambda x: x.id, move.reconcile_id.line_ids)
612+ #try:
613+ if abs(move.reconcile_amount-move.amount)<0.0001:
614+
615+ writeoff_acc_id = False
616+ #There should only be one write-off account!
617+ for entry in move.reconcile_id.line_new_ids:
618+ writeoff_acc_id = entry.account_id.id
619+ break
620+
621+ account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context)
622+ else:
623+ account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context)
624+ #except:
625+ # raise osv.except_osv(_('Error !'), _('Unable to reconcile entry "%s": %.2f') % (move.name, move.amount))
626+
627+ if st.journal_id.entry_posted:
628+ account_move_obj.write(cr, uid, [move_id], {'state':'posted'})
629+ done.append(st.id)
630+ self.write(cr, uid, done, {'state':'confirm'}, context=context)
631+
632+ return True
633+
634+account_bank_statement()
635+
636+
637 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
638
639
640=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount_view.xml'
641--- account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-08-23 12:13:39 +0000
642+++ account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-07-27 10:15:58 +0000
643@@ -47,7 +47,7 @@
644 </field>
645 </field>
646 </record>
647-
648+
649 <record id="bank_statement_form_view1" model="ir.ui.view">
650 <field name="name">account.bank.statement.form</field>
651 <field name="model">account.bank.statement</field>
652@@ -56,10 +56,10 @@
653 <field name="arch" type="xml">
654 <xpath expr="//button[@string='Import Invoice']" position="replace">
655 <button name="%(wizard_populate_statement_from_inv1)d" type="action" string="Import Invoice" attrs="{'invisible':[('state','=','confirm')]}"/>
656- </xpath>
657+ </xpath>
658 </field>
659 </record>
660-
661+
662 <record id="bank_statement_reconcile_form_view1" model="ir.ui.view">
663 <field name="name">account.bank.statement.reconcile.form</field>
664 <field name="model">account.bank.statement.reconcile</field>
665@@ -68,10 +68,10 @@
666 <field name="arch" type="xml">
667 <field name="total_new" position="replace">
668 <field name="total_new" string="Total Write Off / Cash Discount"/>
669- </field>
670+ </field>
671 </field>
672 </record>
673-
674+
675 <record id="bank_statement_reconcile_form_view2" model="ir.ui.view">
676 <field name="name">account.bank.statement.reconcile.form</field>
677 <field name="model">account.bank.statement.reconcile</field>
678@@ -84,10 +84,10 @@
679 <field name="amount"/>
680 <field name="name"/>
681 </tree>
682- </xpath>
683+ </xpath>
684 </field>
685 </record>
686-
687+
688 <record id="account_payment_term_line_view1" model="ir.ui.view">
689 <field name="name">account.payment.term.line.form</field>
690 <field name="model">account.payment.term.line</field>
691@@ -97,9 +97,54 @@
692 <field name="days2" position="after">
693 <field name="compl_cash_discount"/>
694 <field name="day_tolerance"/>
695- </field>
696- </field>
697- </record>
698+ </field>
699+ </field>
700+ </record>
701+
702+ <record id="view_res_company_inherit_form" model="ir.ui.view">
703+ <field name="name">res.company.inherit.form</field>
704+ <field name="model">res.company</field>
705+ <field name="type">form</field>
706+ <field name="inherit_id" ref="base.view_company_form"/>
707+ <field name="arch" type="xml">
708+ <field name="currency_id" position="after">
709+ <field name="expense_account_id"/>
710+ <field name="revenue_account_id"/>
711+ </field>
712+ </field>
713+ </record>
714+
715+ <record id="view_res_company_wizard" model="ir.ui.view">
716+ <field name="name">Account set in Company</field>
717+ <field name="model">res.company.wizard</field>
718+ <field name="type">form</field>
719+ <field name="arch" type="xml">
720+ <form string="Account Configuration">
721+ <field name="expense_account_id"/>
722+ <field name="revenue_account_id"/>
723+ <newline/>
724+ <group col="4" colspan="4">
725+ <button icon="gtk-cancel" name="action_cancel" type="object" special="cancel" string="Cancel"/>
726+ <button icon="gtk-ok" name="set_default" string="Set Default" type="object"/>
727+ </group>
728+ </form>
729+ </field>
730+ </record>
731+
732+ <record id="action_res_company_wizard" model="ir.actions.act_window">
733+ <field name="name">Account set in Company</field>
734+ <field name="type">ir.actions.act_window</field>
735+ <field name="res_model">res.company.wizard</field>
736+ <field name="view_type">form</field>
737+ <field name="view_mode">form</field>
738+ <field name="target">new</field>
739+ </record>
740+
741+ <record id="config_wizard_res_company_wizard" model="ir.actions.todo">
742+ <field name="name">Account set in Company</field>
743+ <field name="note">This Configuration step use to set default Account</field>
744+ <field name="action_id" ref="action_res_company_wizard"/>
745+ </record>
746
747 </data>
748 </openerp>

Subscribers

People subscribed via source and target branches