summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarshad Modi <hmo@tinyerp.com>2008-08-25 17:55:04 +0530
committerHarshad Modi <hmo@tinyerp.com>2008-08-25 17:55:04 +0530
commitd9b9b08a210eeb089ba041743b59cb0ceed3eb4d (patch)
tree560a9788cabcf993ceffd99a2adb36f7f4f4d2ae
parent78f828620bb7aaf283e825258d08ac9f32a0f69c (diff)
In invoices, if we do not specify the period (force period) it must take the period relative to the date of the invoice, not the current period.
bzr revid: hmo@tinyerp.com-20080825122504-9g3lxashtn3100zx
-rw-r--r--addons/account/invoice.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/addons/account/invoice.py b/addons/account/invoice.py
index 9a49a871f42..7dabe6fe88d 100644
--- a/addons/account/invoice.py
+++ b/addons/account/invoice.py
@@ -499,14 +499,18 @@ class account_invoice(osv.osv):
_('Can not create invoice move on centralized journal'))
move = {'name': name, 'line_id': line, 'journal_id': journal_id}
- if inv.period_id:
- move['period_id'] = inv.period_id.id
+ period_id=inv.period_id and inv.period_id.id or False
+ if not period_id:
+ period_ids= self.pool.get('account.period').search(cr,uid,[('date_start','<=',inv.date_invoice),('date_stop','>=',inv.date_invoice)])
+ if len(period_ids):
+ period_id=period_ids[0]
+ if period_id:
+ move['period_id'] = period_id
for i in line:
- i[2]['period_id'] = inv.period_id.id
-
+ i[2]['period_id'] = period_id
move_id = self.pool.get('account.move').create(cr, uid, move)
# make the invoice point to that move
- self.write(cr, uid, [inv.id], {'move_id': move_id})
+ self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id})
self.pool.get('account.move').post(cr, uid, [move_id])
self._log_event(cr, uid, ids)
return True