'balance': fields.function(__compute, digits_compute=dp.get_precision('Account'), string='Balance', multi='balance'),
'credit': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Credit', multi='balance'),
'debit': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Debit', multi='balance'),
+# 'foreign_balance': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Debit', multi='balance'),
+ 'foreign_balance': fields.char('Foreign Balance', size=10),
+ 'adjusted_balance': fields.char('Adjusted Balance', size=10),
+ 'gain_loss_unrealized_balance':fields.char('Unrealized Gain Loss Balance', size=10),
+# 'adjusted_balance': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Debit', multi='balance'),
+# 'gain_loss_unrealized_balance': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Debit', multi='balance'),
'reconcile': fields.boolean('Allow Reconciliation', help="Check this box if this account allows reconciliation of journal items."),
'shortcut': fields.char('Shortcut', size=12),
'tax_ids': fields.many2many('account.tax', 'account_account_tax_default_rel',
return False
def find(self, cr, uid, dt=None, context=None):
+ if context is None: context = {}
if not dt:
dt = time.strftime('%Y-%m-%d')
#CHECKME: shouldn't we check the state of the period?
- ids = self.search(cr, uid, [('date_start','<=',dt),('date_stop','>=',dt)])
+ args = [('date_start', '<=' ,dt), ('date_stop', '>=', dt)]
+ if context.get('company_id', False):
+ args.append(('company_id', '=', context['company_id']))
+ else:
+ company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
+ args.append(('company_id', '=', company_id))
+ ids = self.search(cr, uid, args, context=context)
if not ids:
raise osv.except_osv(_('Error !'), _('No period defined for this date: %s !\nPlease create one.')%dt)
return ids
raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
period_id = period_id[0]
+ move_date = context.get('date', time.strftime('%Y-%m-%d'))
+ move_date = datetime.strptime(move_date,"%Y-%m-%d")
for model in self.browse(cr, uid, ids, context=context):
try:
- entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')}
+ entry['name'] = model.name%{'year': move_date.strftime('%Y'), 'month': move_date.strftime('%m'), 'date': move_date.strftime('%Y-%m')}
except:
raise osv.except_osv(_('Wrong model !'), _('You have a wrong expression "%(...)s" in your model !'))
-
move_id = account_move_obj.create(cr, uid, {
'ref': entry['name'],
'period_id': period_id,
'analytic_account_id': analytic_account_id
}
- date_maturity = time.strftime('%Y-%m-%d')
+ date_maturity = context.get('date',time.strftime('%Y-%m-%d'))
if line.date_maturity == 'partner':
if not line.partner_id:
raise osv.except_osv(_('Error !'), _("Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!" \