=== modified file 'account/invoice.py' --- account/invoice.py 2010-04-19 21:48:13 +0000 +++ account/invoice.py 2010-04-29 08:50:23 +0000 @@ -289,7 +289,7 @@ 'invoice_line': fields.one2many('account.invoice.line', 'invoice_id', 'Invoice Lines', readonly=True, states={'draft':[('readonly',False)]}), 'tax_line': fields.one2many('account.invoice.tax', 'invoice_id', 'Tax Lines', readonly=True, states={'draft':[('readonly',False)]}), - 'move_id': fields.many2one('account.move', 'Invoice Movement', readonly=True, help="Link to the automatically generated account moves."), + 'move_id': fields.many2one('account.move', 'Invoice Movement', readonly=True, help="Link to the automatically generated account moves.", select=1), 'amount_untaxed': fields.function(_amount_all, method=True, digits=(16, int(config['price_accuracy'])),string='Untaxed', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20), @@ -710,18 +710,19 @@ _('Cannot create invoice move on centralised journal')) move = {'ref': inv.number, 'line_id': line, 'journal_id': journal_id, 'date': date} period_id=inv.period_id and inv.period_id.id or False + if not period_id: date_to_check = inv.date_invoice or time.strftime('%Y-%m-%d') period_ids= self.pool.get('account.period').search(cr,uid,[('state','=','draft'),('date_start','<=',date_to_check),('date_stop','>=',date_to_check)]) if len(period_ids): period_id=period_ids[0] - period_id_name = self.pool.get('account.period').browse(cr,uid,period_id).name else: raise osv.except_osv(_('UserError'), _('No open period found for this date %s.' % date_to_check)) # FIXME check against res_user.period_id + period_id_name = self.pool.get('account.period').browse(cr,uid,period_id).name user_period_id = self.pool.get('res.users').browse(cr, uid, uid).period_id - if user_period_id and user_period_id.id != period_id: + if user_period_id and period_id and user_period_id.id != period_id: raise osv.except_osv(_('Error !'), _('Accounting period in user preferences (%s) does not match period of invoice date(%s).' % (user_period_id.name,period_id_name) )) if period_id: