[REF] cleaning code of account

bzr revid: ara@tinyerp.com-20101011060340-v55iqbqk378atwnq
This commit is contained in:
ARA (OpenERP) 2010-10-11 11:33:40 +05:30
parent 685489a172
commit d10e1e83af
10 changed files with 43 additions and 42 deletions

View File

@ -31,12 +31,12 @@ class account_analytic_line(osv.osv):
_inherit = 'account.analytic.line'
_description = 'Analytic Line'
_columns = {
'product_uom_id' : fields.many2one('product.uom', 'UoM'),
'product_id' : fields.many2one('product.product', 'Product'),
'general_account_id' : fields.many2one('account.account', 'General Account', required=True, ondelete='cascade'),
'move_id' : fields.many2one('account.move.line', 'Move Line', ondelete='cascade', select=True),
'journal_id' : fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='cascade', select=True),
'code' : fields.char('Code', size=8),
'product_uom_id': fields.many2one('product.uom', 'UoM'),
'product_id': fields.many2one('product.product', 'Product'),
'general_account_id': fields.many2one('account.account', 'General Account', required=True, ondelete='cascade'),
'move_id': fields.many2one('account.move.line', 'Move Line', ondelete='cascade', select=True),
'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='cascade', select=True),
'code': fields.char('Code', size=8),
'ref': fields.char('Ref.', size=64),
'currency_id': fields.related('move_id', 'currency_id', type='many2one', relation='res.currency', string='Account currency', store=True, help="The related account currency if not equal to the company one.", readonly=True),
'amount_currency': fields.related('move_id', 'amount_currency', type='float', string='Amount currency', store=True, help="The amount expressed in the related account currency if not equal to the company one.", readonly=True),
@ -88,7 +88,7 @@ class account_analytic_line(osv.osv):
company_id = j_id.company_id.id
result = 0.0
is_purchase = False
if j_id.type <> 'sale':
a = prod.product_tmpl_id.property_account_expense.id
if not a:

View File

@ -229,7 +229,7 @@ class account_cash_statement(osv.osv):
'balance_end_cash': fields.function(_balance_end_cash, method=True, store=True, string='Balance', help="Closing balance based on cashBox"),
'starting_details_ids': fields.one2many('account.cashbox.line', 'starting_id', string='Opening Cashbox'),
'ending_details_ids': fields.one2many('account.cashbox.line', 'ending_id', string='Closing Cashbox'),
'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then / , its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'),
'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'),
'user_id':fields.many2one('res.users', 'Responsible', required=False),
}
_defaults = {

View File

@ -71,7 +71,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
AND (l.partner_id=res_partner.id)\
AND ' + self.query + ' \
ORDER BY res_partner.name' , (self.date_from,))
ORDER BY res_partner.name', (self.date_from,))
partners = self.cr.dictfetchall()
## mise a 0 du total
for i in range(7):
@ -95,7 +95,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
AND ' + self.query + '\
AND account_account.active\
GROUP BY partner_id ' , (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from))
GROUP BY partner_id ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from))
t = self.cr.fetchall()
for i in t:
totals[i[0]] = i[1]
@ -130,7 +130,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
AND '+ self.query + '\
AND account_account.active\
GROUP BY l.partner_id' , (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids), self.date_from))
GROUP BY l.partner_id', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids), self.date_from))
t = self.cr.fetchall()
for i in t:
future_past[i[0]] = i[1]
@ -139,7 +139,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
# Each history will contain : history[1] = {'<partner_id>': <partner_debit-credit>}
history = []
for i in range(5):
args_list = (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids) ,self.date_from,)
args_list = (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids),self.date_from,)
dates_query = '(COALESCE(l.date_maturity,l.date)'
if form[str(i)]['start'] and form[str(i)]['stop']:
dates_query += ' BETWEEN %s AND %s)'
@ -152,7 +152,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
args_list += (form[str(i)]['stop'],)
self.cr.execute('SELECT l.partner_id, SUM(l.debit-l.credit)\
FROM account_move_line AS l, account_account , account_move am \
FROM account_move_line AS l, account_account, account_move am \
WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)\
AND (am.state IN %s)\
AND (account_account.type IN %s)\
@ -162,7 +162,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
AND '+ self.query + '\
AND account_account.active\
AND ' + dates_query + '\
GROUP BY l.partner_id' , args_list)
GROUP BY l.partner_id', args_list)
t = self.cr.fetchall()
d = {}
for i in t:
@ -227,7 +227,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
self.total_account.append(0)
totals = {}
self.cr.execute('SELECT SUM(l.debit-l.credit) \
FROM account_move_line AS l, account_account , account_move am \
FROM account_move_line AS l, account_account, account_move am \
WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)\
AND (am.state IN %s)\
AND (l.partner_id IS NULL)\
@ -235,7 +235,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
AND ((l.reconcile_id IS NULL) \
OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
AND ' + self.query + '\
AND account_account.active ' ,(tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from))
AND account_account.active ',(tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from))
t = self.cr.fetchall()
for i in t:
totals['Unknown Partner'] = i[0]
@ -266,7 +266,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
AND ((l.reconcile_id IS NULL)\
OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
AND '+ self.query + '\
AND account_account.active ' , (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from))
AND account_account.active ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from))
t = self.cr.fetchall()
for i in t:
future_past['Unknown Partner'] = i[0]
@ -286,7 +286,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
args_list += (form[str(i)]['stop'],)
self.cr.execute('SELECT SUM(l.debit-l.credit)\
FROM account_move_line AS l, account_account , account_move am \
FROM account_move_line AS l, account_account, account_move am \
WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)\
AND (am.state IN %s)\
AND (account_account.type IN %s)\
@ -296,7 +296,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
AND '+ self.query + '\
AND account_account.active\
AND ' + dates_query + '\
GROUP BY l.partner_id' , args_list)
GROUP BY l.partner_id', args_list)
t = self.cr.fetchall()
d = {}
for i in t:

View File

@ -33,7 +33,7 @@ class analytic_entries_report(osv.osv):
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
'user_id' : fields.many2one('res.users', 'User',readonly=True),
'user_id': fields.many2one('res.users', 'User',readonly=True),
'name': fields.char('Description', size=64, readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner'),
'company_id': fields.many2one('res.company', 'Company', required=True),

View File

@ -71,11 +71,12 @@ class journal_print(report_sxw.rml_parse, common_report_header):
move_state = ['draft','posted']
if self.target_move == 'posted':
move_state = ['posted']
self.cr.execute('SELECT a.currency_id ,a.code, a.name, c.code AS currency_code, l.currency_id, l.amount_currency, SUM(debit) AS debit, SUM(credit) AS credit \
from account_move_line l \
LEFT JOIN account_move am ON (l.move_id=am.id) \
LEFT JOIN account_account a ON (l.account_id=a.id) \
LEFT JOIN res_currency c on (l.currency_id=c.id) WHERE am.state IN %s AND l.period_id=%s AND l.journal_id=%s '+self.query_get_clause+' GROUP BY a.id, a.code, a.name,l.amount_currency,c.code , a.currency_id,l.currency_id', (tuple(move_state), period_id, journal_id))
LEFT JOIN res_currency c on (l.currency_id=c.id) WHERE am.state IN %s AND l.period_id=%s AND l.journal_id=%s '+self.query_get_clause+' GROUP BY a.id, a.code, a.name,l.amount_currency,c.code, a.currency_id,l.currency_id', (tuple(move_state), period_id, journal_id))
return self.cr.dictfetchall()
def _set_get_account_currency_code(self, account_id):
@ -91,12 +92,12 @@ class journal_print(report_sxw.rml_parse, common_report_header):
def _get_account(self, data):
if data['model'] == 'account.journal.period':
return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).company_id.name
return super(journal_print ,self)._get_account(data)
return super(journal_print,self)._get_account(data)
def _get_fiscalyear(self, data):
if data['model'] == 'account.journal.period':
return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).fiscalyear_id.name
return super(journal_print ,self)._get_fiscalyear(data)
return super(journal_print,self)._get_fiscalyear(data)
def _display_currency(self, data):
if data['model'] == 'account.journal.period':

View File

@ -170,7 +170,7 @@ class account_automatic_reconcile(osv.osv_memory):
"AND reconcile_id IS NULL",
(account_id, partner_id))
line_ids = [id for (id,) in cr.fetchall()]
if len(line_ids):
if line_ids:
reconciled += len(line_ids)
if allow_write_off:
move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)

View File

@ -100,7 +100,7 @@ class account_invoice_refund(osv.osv_memory):
raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
if inv.reconciled and mode in ('cancel', 'modify'):
raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice') % (mode))
if form['period'] :
if form['period']:
period = form['period']
else:
period = inv.period_id and inv.period_id.id or False
@ -108,9 +108,9 @@ class account_invoice_refund(osv.osv_memory):
if not journal_id:
journal_id = inv.journal_id.id
if form['date'] :
if form['date']:
date = form['date']
if not form['period'] :
if not form['period']:
cr.execute("select name from ir_model_fields \
where model = 'account.period' \
and name = 'company_id'")
@ -128,7 +128,7 @@ class account_invoice_refund(osv.osv_memory):
period = res[0]
else:
date = inv.date_invoice
if form['description'] :
if form['description']:
description = form['description']
else:
description = inv.name
@ -147,18 +147,18 @@ class account_invoice_refund(osv.osv_memory):
if mode in ('cancel', 'modify'):
movelines = inv.move_id.line_id
to_reconcile_ids = {}
for line in movelines :
if line.account_id.id == inv.account_id.id :
for line in movelines:
if line.account_id.id == inv.account_id.id:
to_reconcile_ids[line.account_id.id] = [line.id]
if type(line.reconcile_id) != osv.orm.browse_null :
if type(line.reconcile_id) != osv.orm.browse_null:
reconcile_obj.unlink(cr, uid, line.reconcile_id.id)
wf_service.trg_validate(uid, 'account.invoice', \
refund.id, 'invoice_open', cr)
refund = inv_obj.browse(cr, uid, refund_id[0], context=context)
for tmpline in refund.move_id.line_id :
if tmpline.account_id.id == inv.account_id.id :
for tmpline in refund.move_id.line_id:
if tmpline.account_id.id == inv.account_id.id:
to_reconcile_ids[tmpline.account_id.id].append(tmpline.id)
for account in to_reconcile_ids :
for account in to_reconcile_ids:
account_m_line_obj.reconcile(cr, uid, to_reconcile_ids[account],
writeoff_period_id=period,
writeoff_journal_id = inv.journal_id.id,
@ -214,7 +214,7 @@ class account_invoice_refund(osv.osv_memory):
return result
def invoice_refund(self, cr, uid, ids, context=None):
data_refund = self.read(cr, uid, ids, [] ,context=context)[0]['filter_refund']
data_refund = self.read(cr, uid, ids, [],context=context)[0]['filter_refund']
return self.compute_refund(cr, uid, ids, data_refund, context=context)
account_invoice_refund()

View File

@ -46,7 +46,7 @@ class account_move_line_select(osv.osv_memory):
fiscalyears = fiscalyear_obj.browse(cr, uid, fiscalyear_ids)
period_ids = []
if fiscalyears :
if fiscalyears:
for fiscalyear in fiscalyears:
for period in fiscalyear.period_ids:
period_ids.append(period.id)
@ -56,7 +56,7 @@ class account_move_line_select(osv.osv_memory):
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
result['context'] = {
'fiscalyear': False ,
'fiscalyear': False,
'account_id': context['active_id'],
'active_id': context['active_id'],
}

View File

@ -83,7 +83,7 @@ class account_move_line_reconcile(osv.osv_memory):
data = self.read(cr, uid, ids, context=context)
date = time.strftime('%Y-%m-%d')
ids = self.pool.get('account.period').find(cr, uid, dt=date, context=context)
if len(ids):
if ids:
period_id = ids[0]
#stop the reconciliation process by partner (manual reconciliation) only if there is nothing more to reconcile for this partner
if 'active_ids' in context and context['active_ids']:
@ -93,10 +93,10 @@ class account_move_line_reconcile(osv.osv_memory):
credit_ml_ids = account_move_line_obj.search(cr, uid, [('partner_id', '=', partner_id), ('account_id.reconcile', '=', True), ('reconcile_id', '=', False), ('credit', '>', 0)], context=context)
for ml_id in context['active_ids']:
if ml_id in debit_ml_ids:
debit_ml_ids.remove(ml_id)
debit_ml_ids.remove(ml_id)
if ml_id in credit_ml_ids:
credit_ml_ids.remove(ml_id)
if not (len(debit_ml_ids) and len(credit_ml_ids)):
if not debit_ml_ids and credit_ml_ids:
context.update({'stop_reconcile': True})
account_move_line_obj.reconcile(cr, uid, context['active_ids'], 'manual', account_id,
period_id, journal_id, context=context)
@ -161,7 +161,7 @@ class account_move_line_reconcile_writeoff(osv.osv_memory):
date = context['date_p']
ids = self.pool.get('account.period').find(cr, uid, dt=date, context=context)
if len(ids):
if ids:
period_id = ids[0]
context.update({'stop_reconcile': True})

View File

@ -44,7 +44,7 @@ class account_unreconcile_reconcile(osv.osv_memory):
rec_ids = context['active_ids']
if context is None:
context = {}
if len(rec_ids):
if rec_ids:
obj_move_reconcile.unlink(cr, uid, rec_ids)
return {}