[MERGE] merge with trunk addons and remove conficts

bzr revid: mra@mra-laptop-20100618083859-5jbrk4u9l2vojxu6
This commit is contained in:
Mustufa Rangwala 2010-06-18 14:08:59 +05:30
commit 3be7801205
182 changed files with 1366 additions and 1529 deletions

View File

@ -30,6 +30,25 @@ from tools.misc import currency
from tools.translate import _
from tools import config
def check_cycle(self, cr, uid, ids):
""" climbs the ``self._table.parent_id`` chains for 100 levels or
until it can't find any more parent(s)
Returns true if it runs out of parents (no cycle), false if
it can recurse 100 times without ending all chains
"""
level = 100
while len(ids):
cr.execute('SELECT DISTINCT parent_id '\
'FROM '+self._table+' '\
'WHERE id IN %s '\
'AND parent_id IS NOT NULL',(tuple(ids),))
ids = map(itemgetter(0), cr.fetchall())
if not level:
return False
level -= 1
return True
class account_payment_term(osv.osv):
_name = "account.payment.term"
_description = "Payment Term"
@ -167,6 +186,7 @@ class account_account(osv.osv):
_name = "account.account"
_description = "Account"
_parent_store = True
logger = netsvc.Logger()
def _get_children_and_consol(self, cr, uid, ids, context={}):
ids2=[]
@ -226,65 +246,87 @@ class account_account(osv.osv):
ids3 = self._get_children_and_consol(cr, uid, ids3, context)
return ids2 + ids3
def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''):
#compute the balance/debit/credit accordingly to the value of field_name for the given account ids
mapping = {
'balance': "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance ",
'debit': "COALESCE(SUM(l.debit), 0) as debit ",
'credit': "COALESCE(SUM(l.credit), 0) as credit "
}
#get all the necessary accounts
ids2 = self._get_children_and_consol(cr, uid, ids, context)
#compute for each account the balance/debit/credit from the move lines
accounts = {}
if ids2:
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
def __compute(self, cr, uid, ids, field_names, arg=None, context=None,
query='', query_params=()):
""" compute the balance, debit and/or credit for the provided
account ids
Arguments:
`ids`: account ids
`field_names`: the fields to compute (a list of any of
'balance', 'debit' and 'credit')
`arg`: unused fields.function stuff
`query`: additional query filter (as a string)
`query_params`: parameters for the provided query string
(__compute will handle their escaping) as a
tuple
"""
mapping = {
'balance': "COALESCE(SUM(l.debit),0) " \
"- COALESCE(SUM(l.credit), 0) as balance",
'debit': "COALESCE(SUM(l.debit), 0) as debit",
'credit': "COALESCE(SUM(l.credit), 0) as credit"
}
#get all the necessary accounts
children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context)
#compute for each account the balance/debit/credit from the move lines
accounts = {}
if children_and_consolidated:
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
wheres = [""]
if query.strip():
wheres.append(query.strip())
if aml_query.strip():
wheres.append(aml_query.strip())
query = " AND ".join(wheres)
wheres = [""]
if query.strip():
wheres.append(query.strip())
if aml_query.strip():
wheres.append(aml_query.strip())
filters = " AND ".join(wheres)
self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
'Filters: %s'%filters)
# IN might not work ideally in case there are too many
# children_and_consolidated, in that case join on a
# values() e.g.:
# SELECT l.account_id as id FROM account_move_line l
# INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id)
# ON l.account_id = tmp.id
# or make _get_children_and_consol return a query and join on that
request = ("SELECT l.account_id as id, " +\
' , '.join(map(mapping.__getitem__, field_names)) +
" FROM account_move_line l" \
" WHERE l.account_id IN %s " \
+ filters +
" GROUP BY l.account_id")
params = (tuple(children_and_consolidated),) + query_params
cr.execute(request, params)
self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
'Status: %s'%cr.statusmessage)
cr.execute("SELECT l.account_id as id, " +\
' , '.join(map(lambda x: mapping[x], field_names)) +
"FROM " \
"account_move_line l " \
"WHERE " \
"l.account_id =ANY(%s) " \
+ query +
" GROUP BY l.account_id",(ids2,))
for res in cr.dictfetchall():
accounts[res['id']] = res
for res in cr.dictfetchall():
accounts[res['id']] = res
# consolidate accounts with direct children
ids2.reverse()
brs = list(self.browse(cr, uid, ids2, context=context))
sums = {}
while brs:
current = brs[0]
can_compute = True
for child in current.child_id:
if child.id not in sums:
can_compute = False
try:
brs.insert(0, brs.pop(brs.index(child)))
except ValueError:
brs.insert(0, child)
if can_compute:
brs.pop(0)
for fn in field_names:
sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0)
if current.child_id:
sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id)
res = {}
null_result = dict((fn, 0.0) for fn in field_names)
for id in ids:
res[id] = sums.get(id, null_result)
return res
# consolidate accounts with direct children
children_and_consolidated.reverse()
brs = list(self.browse(cr, uid, children_and_consolidated, context=context))
sums = {}
while brs:
current = brs[0]
can_compute = True
for child in current.child_id:
if child.id not in sums:
can_compute = False
try:
brs.insert(0, brs.pop(brs.index(child)))
except ValueError:
brs.insert(0, child)
if can_compute:
brs.pop(0)
for fn in field_names:
sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0)
if current.child_id:
sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id)
res = {}
null_result = dict((fn, 0.0) for fn in field_names)
for id in ids:
res[id] = sums.get(id, null_result)
return res
def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}):
result = {}
@ -389,8 +431,10 @@ class account_account(osv.osv):
if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)):
return False
while(ids):
cr.execute('select distinct child_id from account_account_consol_rel where parent_id =ANY(%s)',(ids,))
child_ids = filter(None, map(lambda x: x[0], cr.fetchall()))
cr.execute('SELECT DISTINCT child_id '\
'FROM account_account_consol_rel '\
'WHERE parent_id IN %s', (tuple(ids),))
child_ids = map(itemgetter(0), cr.fetchall())
c_ids = child_ids
if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids):
return False
@ -907,7 +951,10 @@ class account_move(osv.osv):
def _amount_compute(self, cr, uid, ids, name, args, context, where =''):
if not ids: return {}
cr.execute('select move_id,sum(debit) from account_move_line where move_id =ANY(%s) group by move_id',(ids,))
cr.execute( 'SELECT move_id, SUM(debit) '\
'FROM account_move_line '\
'WHERE move_id IN %s '\
'GROUP BY move_id', (tuple(ids),))
result = dict(cr.fetchall())
for id in ids:
result.setdefault(id, 0.0)
@ -1006,7 +1053,10 @@ class account_move(osv.osv):
if new_name:
self.write(cr, uid, [move.id], {'name':new_name})
cr.execute('update account_move set state=%s where id =ANY(%s) ',('posted',ids,))
cr.execute('UPDATE account_move '\
'SET state=%s '\
'WHERE id IN %s',
('posted', tuple(ids),))
else:
raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !'))
return True
@ -1019,7 +1069,9 @@ class account_move(osv.osv):
if not line.journal_id.update_posted:
raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.'))
if len(ids):
cr.execute('update account_move set state=%s where id =ANY(%s)',('draft',ids,))
cr.execute('UPDATE account_move '\
'SET state=%s '\
'WHERE id IN %s', ('draft', tuple(ids),))
return True
def write(self, cr, uid, ids, vals, context={}):
@ -1138,7 +1190,10 @@ class account_move(osv.osv):
else:
line_id2 = 0
cr.execute('select sum('+mode+') from account_move_line where move_id=%s and id<>%s', (move.id, line_id2))
cr.execute('SELECT SUM(%s) '\
'FROM account_move_line '\
'WHERE move_id=%s AND id<>%s',
(mode, move.id, line_id2))
result = cr.fetchone()[0] or 0.0
cr.execute('update account_move_line set '+mode2+'=%s where id=%s', (result, line_id))
return True
@ -1292,24 +1347,26 @@ class account_tax_code(osv.osv):
This code is used for some tax declarations.
"""
def _sum(self, cr, uid, ids, name, args, context, where =''):
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
def _sum(self, cr, uid, ids, name, args, context,where ='', where_params=()):
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if context.get('based_on', 'invoices') == 'payments':
cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \
FROM account_move_line AS line, \
account_move AS move \
LEFT JOIN account_invoice invoice ON \
(invoice.move_id = move.id) \
WHERE line.tax_code_id =ANY(%s) '+where+' \
WHERE line.tax_code_id IN %s '+where+' \
AND move.id = line.move_id \
AND ((invoice.state = \'paid\') \
OR (invoice.id IS NULL)) \
GROUP BY line.tax_code_id',(ids2,))
GROUP BY line.tax_code_id',
(parent_ids,)+where_params)
else:
cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \
FROM account_move_line AS line \
WHERE line.tax_code_id =ANY(%s) '+where+' \
GROUP BY line.tax_code_id',(ids2,))
WHERE line.tax_code_id IN %s '+where+' \
GROUP BY line.tax_code_id',
(parent_ids,)+where_params)
res=dict(cr.fetchall())
for record in self.browse(cr, uid, ids, context):
def _rec_get(record):
@ -1326,12 +1383,14 @@ class account_tax_code(osv.osv):
else:
fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False)
where = ''
where_params = ()
if fiscalyear_id:
pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids)
if pids:
where = ' and period_id in (' + (','.join(pids))+')'
where = ' and period_id IN %s'
where_params = (tuple(pids),)
return self._sum(cr, uid, ids, name, args, context,
where=where)
where=where, where_params=where_params)
def _sum_period(self, cr, uid, ids, name, args, context):
if 'period_id' in context and context['period_id']:
@ -1342,7 +1401,7 @@ class account_tax_code(osv.osv):
return dict.fromkeys(ids, 0.0)
period_id = period_id[0]
return self._sum(cr, uid, ids, name, args, context,
where=' and line.period_id='+str(period_id))
where=' and line.period_id=%s', where_params=(period_id,))
_name = 'account.tax.code'
_description = 'Tax Code'
@ -1390,16 +1449,6 @@ class account_tax_code(osv.osv):
'sign': lambda *args: 1.0,
'notprintable': lambda *a: False,
}
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
cr.execute('select distinct parent_id from account_tax_code where id =ANY(%s)',(ids,))
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
level -= 1
return True
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
@ -1408,6 +1457,7 @@ class account_tax_code(osv.osv):
default.update({'line_ids': []})
return super(account_tax_code, self).copy(cr, uid, id, default, context)
_check_recursion = check_cycle
_constraints = [
(_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id'])
]
@ -1755,7 +1805,7 @@ class account_model(osv.osv):
'ref': fields.char('Reference', size=64),
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'),
'legend' :fields.text('Legend',readonly=True,size=100),
'legend' :fields.text('Legend', readonly=True, size=100),
}
_defaults = {
@ -1765,7 +1815,7 @@ class account_model(osv.osv):
move_ids = []
for model in self.browse(cr, uid, ids, context):
context.update({'date':datas['date']})
period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date',False))
period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
if not period_id:
raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
period_id = period_id[0]
@ -1967,9 +2017,9 @@ class account_account_template(osv.osv):
'reconcile': fields.boolean('Allow Reconciliation', help="Check this option if you want the user to reconcile entries in this account."),
'shortcut': fields.char('Shortcut', size=12),
'note': fields.text('Note'),
'parent_id': fields.many2one('account.account.template','Parent Account Template', ondelete='cascade'),
'child_parent_ids':fields.one2many('account.account.template','parent_id','Children'),
'tax_ids': fields.many2many('account.tax.template', 'account_account_template_tax_rel','account_id','tax_id', 'Default Taxes'),
'parent_id': fields.many2one('account.account.template', 'Parent Account Template', ondelete='cascade'),
'child_parent_ids':fields.one2many('account.account.template', 'parent_id', 'Children'),
'tax_ids': fields.many2many('account.tax.template', 'account_account_template_tax_rel', 'account_id', 'tax_id', 'Default Taxes'),
'nocreate': fields.boolean('Optional create', help="If checked, the new chart of accounts will not contain this by default."),
}
@ -1979,16 +2029,7 @@ class account_account_template(osv.osv):
'nocreate': lambda *a: False,
}
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
cr.execute('select parent_id from account_account_template where id =ANY(%s)',(ids,))
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
level -= 1
return True
_check_recursion = check_cycle
_constraints = [
(_check_recursion, 'Error ! You can not create recursive account templates.', ['parent_id'])
]
@ -2018,14 +2059,14 @@ class account_add_tmpl_wizard(osv.osv_memory):
acc_obj=self.pool.get('account.account')
tmpl_obj=self.pool.get('account.account.template')
#print "Searching for ",context
tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']],['parent_id'])
tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id'])
if not tids or not tids[0]['parent_id']:
return False
ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]],['code'])
ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]], ['code'])
res = None
if not ptids or not ptids[0]['code']:
raise osv.except_osv(_('Error !'), _('Cannot locate parent code for template account!'))
res = acc_obj.search(cr,uid,[('code','=',ptids[0]['code'])])
res = acc_obj.search(cr, uid, [('code','=',ptids[0]['code'])])
return res and res[0] or False
@ -2039,9 +2080,9 @@ class account_add_tmpl_wizard(osv.osv_memory):
def action_create(self,cr,uid,ids,context=None):
acc_obj=self.pool.get('account.account')
tmpl_obj=self.pool.get('account.account.template')
data= self.read(cr,uid,ids)
company_id = acc_obj.read(cr,uid,[data[0]['cparent_id']],['company_id'])[0]['company_id'][0]
account_template = tmpl_obj.browse(cr,uid,context['tmpl_ids'])
data= self.read(cr, uid, ids)
company_id = acc_obj.read(cr, uid, [data[0]['cparent_id']], ['company_id'])[0]['company_id'][0]
account_template = tmpl_obj.browse(cr, uid, context['tmpl_ids'])
#tax_ids = []
#for tax in account_template.tax_ids:
# tax_ids.append(tax_template_ref[tax.id])
@ -2060,10 +2101,10 @@ class account_add_tmpl_wizard(osv.osv_memory):
'company_id': company_id,
}
# print "Creating:", vals
new_account = acc_obj.create(cr,uid,vals)
new_account = acc_obj.create(cr, uid, vals)
return {'type':'state', 'state': 'end' }
def action_cancel(self,cr,uid,ids,context=None):
def action_cancel(self, cr, uid, ids, context=None):
return { 'type': 'state', 'state': 'end' }
account_add_tmpl_wizard()
@ -2098,16 +2139,7 @@ class account_tax_code_template(osv.osv):
return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \
for x in reads]
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
cr.execute('select distinct parent_id from account_tax_code_template where id =ANY(%s)',(ids,))
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
level -= 1
return True
_check_recursion = check_cycle
_constraints = [
(_check_recursion, 'Error ! You can not create recursive Tax Codes.', ['parent_id'])
]
@ -2270,11 +2302,11 @@ class wizard_multi_charts_accounts(osv.osv_memory):
_inherit = 'res.config'
_columns = {
'company_id':fields.many2one('res.company','Company',required=True),
'chart_template_id': fields.many2one('account.chart.template','Chart Template',required=True),
'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Bank Accounts',required=True),
'code_digits':fields.integer('# of Digits',required=True,help="No. of Digits to use for account code"),
'seq_journal':fields.boolean('Separated Journal Sequences',help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."),
'company_id':fields.many2one('res.company', 'Company', required=True),
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Bank Accounts', required=True),
'code_digits':fields.integer('# of Digits', required=True, help="No. of Digits to use for account code"),
'seq_journal':fields.boolean('Separated Journal Sequences', help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."),
}
def _get_chart(self, cr, uid, context={}):
@ -2283,14 +2315,14 @@ class wizard_multi_charts_accounts(osv.osv_memory):
return ids[0]
return False
_defaults = {
'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr,uid,[uid],c)[0].company_id.id,
'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, [uid], c)[0].company_id.id,
'chart_template_id': _get_chart,
'code_digits': lambda *a:6,
'seq_journal': True
}
def execute(self, cr, uid, ids, context=None):
obj_multi = self.browse(cr,uid,ids[0])
obj_multi = self.browse(cr, uid, ids[0])
obj_acc = self.pool.get('account.account')
obj_acc_tax = self.pool.get('account.tax')
obj_journal = self.pool.get('account.journal')
@ -2322,7 +2354,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'company_id': company_id,
'sign': tax_code_template.sign,
}
new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals)
new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals)
#recording the new tax code to do the mapping
tax_code_template_ref[tax_code_template.id] = new_tax_code
@ -2355,7 +2387,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'company_id': company_id,
'type_tax_use': tax.type_tax_use
}
new_tax = obj_acc_tax.create(cr,uid,vals_tax)
new_tax = obj_acc_tax.create(cr, uid, vals_tax)
#as the accounts have not been created yet, we have to wait before filling these fields
todo_dict[new_tax] = {
'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False,
@ -2393,7 +2425,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'tax_ids': [(6,0,tax_ids)],
'company_id': company_id,
}
new_account = obj_acc.create(cr,uid,vals)
new_account = obj_acc.create(cr, uid, vals)
acc_template_ref[account_template.id] = new_account
#reactivate the parent_store functionnality on account_account
self.pool._init = False
@ -2409,11 +2441,11 @@ class wizard_multi_charts_accounts(osv.osv_memory):
# Creating Journals
vals_journal={}
view_id = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Journal View')])[0]
seq_id = obj_sequence.search(cr,uid,[('name','=','Account Journal')])[0]
seq_id = obj_sequence.search(cr, uid, [('name','=','Account Journal')])[0]
if obj_multi.seq_journal:
seq_id_sale = obj_sequence.search(cr,uid,[('name','=','Sale Journal')])[0]
seq_id_purchase = obj_sequence.search(cr,uid,[('name','=','Purchase Journal')])[0]
seq_id_sale = obj_sequence.search(cr, uid, [('name','=','Sale Journal')])[0]
seq_id_purchase = obj_sequence.search(cr, uid, [('name','=','Purchase Journal')])[0]
else:
seq_id_sale = seq_id
seq_id_purchase = seq_id
@ -2445,8 +2477,8 @@ class wizard_multi_charts_accounts(osv.osv_memory):
obj_journal.create(cr,uid,vals_journal)
# Bank Journals
view_id_cash = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Cash Journal View')])[0]
view_id_cur = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Multi-Currency Cash Journal View')])[0]
view_id_cash = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Cash Journal View')])[0]
view_id_cur = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Multi-Currency Cash Journal View')])[0]
ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id
current_num = 1
@ -2524,7 +2556,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
#create the property
property_obj.create(cr, uid, vals)
fp_ids = obj_fiscal_position_template.search(cr, uid,[('chart_template_id', '=', obj_multi.chart_template_id.id)])
fp_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.chart_template_id.id)])
if fp_ids:
for position in obj_fiscal_position_template.browse(cr, uid, fp_ids):

View File

@ -92,9 +92,9 @@ class account_analytic_line(osv.osv):
company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context)
# Compute based on pricetype
pricetype=self.pool.get('product.price.type').browse(cr,uid,company_obj.browse(cr,uid,company_id).property_valuation_price_type.id)
pricetype=self.pool.get('product.price.type').browse(cr, uid, company_obj.browse(cr,uid,company_id).property_valuation_price_type.id)
# Take the company currency as the reference one
context['currency_id']=company_obj.browse(cr,uid,company_id).currency_id.id
context['currency_id']=company_obj.browse(cr, uid, company_id).currency_id.id
amount_unit=prod.price_get(pricetype.field, context)[prod.id]
amount=amount_unit*unit_amount or 1.0
return {'value': {

View File

@ -32,7 +32,7 @@ class account_bank_statement(osv.osv):
mod_obj = self.pool.get('ir.model.data')
if context is None:
context = {}
model_data_ids = mod_obj.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_account_statement_from_invoice')], context=context)
model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_statement_from_invoice')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
context.update({'statement_id': ids[0]})
return {

View File

@ -65,9 +65,9 @@ class account_move_line(osv.osv):
#the query have to be build with no reference to periods but thanks to the creation date
if context.get('periods',False):
#if one or more period are given, use them
fiscalperiod_ids = fiscalperiod_obj.search(cr,uid,[('id','in',context['periods'])])
fiscalperiod_ids = fiscalperiod_obj.search(cr, uid, [('id','in',context['periods'])])
else:
fiscalperiod_ids = self.pool.get('account.period').search(cr,uid,[('fiscalyear_id','in',fiscalyear_ids)])
fiscalperiod_ids = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id','in',fiscalyear_ids)])
@ -86,7 +86,7 @@ class account_move_line(osv.osv):
#add to 'res' a new clause containing the creation date criterion
count = 1
res += " AND ("
periods = self.pool.get('account.period').read(cr,uid,p_ids,['date_start','date_stop'])
periods = self.pool.get('account.period').read(cr, uid, p_ids, ['date_start','date_stop'])
for period in periods:
if count != 1:
res += " OR "
@ -149,7 +149,7 @@ class account_move_line(osv.osv):
for item in i[2]:
data[item]=i[2][item]
if context['journal']:
journal_obj=self.pool.get('account.journal').browse(cr,uid,context['journal'])
journal_obj=self.pool.get('account.journal').browse(cr, uid, context['journal'])
if journal_obj.type == 'purchase':
if total_new>0:
account = journal_obj.default_credit_account_id
@ -297,9 +297,10 @@ class account_move_line(osv.osv):
for line_id in ids:
res[line_id] = False
cursor.execute('SELECT l.id, i.id ' \
'FROM account_move_line l, account_invoice i ' \
'WHERE l.move_id = i.move_id ' \
'AND l.id =ANY(%s)',(ids,))
'FROM account_move_line l, account_invoice i ' \
'WHERE l.move_id = i.move_id ' \
'AND l.id IN %s',
(tuple(ids),))
invoice_ids = []
for line_id, invoice_id in cursor.fetchall():
res[line_id] = invoice_id
@ -332,7 +333,7 @@ class account_move_line(osv.osv):
return []
where = ' and '.join(map(lambda x: '(abs(sum(debit-credit))'+x[1]+str(x[2])+')',args))
cursor.execute('select id, sum(debit-credit) from account_move_line \
group by id,debit,credit having '+where)
group by id, debit, credit having '+where)
res = cursor.fetchall()
if not len(res):
return [('id', '=', '0')]
@ -432,8 +433,8 @@ class account_move_line(osv.osv):
'account_tax_id':fields.many2one('account.tax', 'Tax'),
'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'),
#TODO: remove this
'amount_taxed':fields.float("Taxed Amount",digits_compute=dp.get_precision('Account')),
'company_id': fields.related('account_id','company_id',type='many2one',relation='res.company',string='Company',store=True)
'amount_taxed':fields.float("Taxed Amount", digits_compute=dp.get_precision('Account')),
'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True)
}
@ -468,7 +469,7 @@ class account_move_line(osv.osv):
'currency_id': _get_currency,
'journal_id': lambda self, cr, uid, c: c.get('journal_id', False),
'period_id': lambda self, cr, uid, c: c.get('period_id', False),
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c)
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c)
}
_order = "date desc,id desc"
_sql_constraints = [
@ -647,10 +648,11 @@ class account_move_line(osv.osv):
else:
date = time.strftime('%Y-%m-%d')
cr.execute('SELECT account_id, reconcile_id \
FROM account_move_line \
WHERE id =ANY(%s) \
GROUP BY account_id,reconcile_id',(ids,))
cr.execute('SELECT account_id, reconcile_id '\
'FROM account_move_line '\
'WHERE id IN %s '\
'GROUP BY account_id,reconcile_id',
(tuple(ids),))
r = cr.fetchall()
#TODO: move this check to a constraint in the account_move_reconcile object
if (len(r) != 1) and not context.get('fy_closing', False):
@ -838,9 +840,9 @@ class account_move_line(osv.osv):
else:
journal_id = context['journal_id']
period_id = context['period_id']
journal = self.pool.get('account.journal').browse(cr,uid,[journal_id])[0]
journal = self.pool.get('account.journal').browse(cr, uid, [journal_id])[0]
if journal.allow_date:
period = self.pool.get('account.period').browse(cr,uid,[period_id])[0]
period = self.pool.get('account.period').browse(cr, uid, [period_id])[0]
if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'):
raise osv.except_osv(_('Error'),_('The date of your Ledger Posting is not in the defined period !'))
else:

View File

@ -100,7 +100,7 @@ class account_installer(osv.osv_memory):
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'configurable_chart_template')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
obj_multi = self.pool.get('account.chart.template').browse(cr,uid, id)
obj_multi = self.pool.get('account.chart.template').browse(cr, uid, id)
obj_acc = self.pool.get('account.account')
obj_acc_tax = self.pool.get('account.tax')
@ -109,7 +109,7 @@ class account_installer(osv.osv_memory):
obj_acc_template = self.pool.get('account.account.template')
obj_fiscal_position_template = self.pool.get('account.fiscal.position.template')
obj_fiscal_position = self.pool.get('account.fiscal.position')
company_id = self.pool.get('res.users').browse(cr,uid,[uid],context)[0].company_id
company_id = self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id
seq_journal = True
# Creating Account
@ -134,7 +134,7 @@ class account_installer(osv.osv_memory):
'company_id': company_id.id,
'sign': tax_code_template.sign,
}
new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals)
new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals)
#recording the new tax code to do the mapping
tax_code_template_ref[tax_code_template.id] = new_tax_code
@ -167,7 +167,7 @@ class account_installer(osv.osv_memory):
'company_id': company_id.id,
'type_tax_use': tax.type_tax_use
}
new_tax = obj_acc_tax.create(cr,uid,vals_tax)
new_tax = obj_acc_tax.create(cr, uid, vals_tax)
#as the accounts have not been created yet, we have to wait before filling these fields
todo_dict[new_tax] = {
'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False,
@ -205,7 +205,7 @@ class account_installer(osv.osv_memory):
'tax_ids': [(6,0,tax_ids)],
'company_id': company_id.id,
}
new_account = obj_acc.create(cr,uid,vals)
new_account = obj_acc.create(cr, uid, vals)
acc_template_ref[account_template.id] = new_account
if account_template.name == 'Bank Current Account':
view_id_cash = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Cash Journal View')])[0]
@ -329,8 +329,8 @@ class account_installer(osv.osv_memory):
obj_journal.create(cr,uid,vals_journal)
# Bank Journals
view_id_cash = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Cash Journal View')])[0]
view_id_cur = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Multi-Currency Cash Journal View')])[0]
view_id_cash = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Cash Journal View')])[0]
view_id_cur = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Multi-Currency Cash Journal View')])[0]
ref_acc_bank = obj_multi.bank_account_view_id
@ -427,7 +427,7 @@ class account_installer(osv.osv_memory):
'sign': 1,
'parent_id':sal_tax_parent_id
}
new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals_tax_code)
new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_tax_code)
sales_tax = obj_tax.create(cr, uid,
{'name':'VAT%s%%'%(s_tax*100),
'description':'VAT%s%%'%(s_tax*100),
@ -446,7 +446,7 @@ class account_installer(osv.osv_memory):
'sign': 1,
'parent_id':pur_tax_parent_id
}
new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals_tax_code)
new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_tax_code)
purchase_tax = obj_tax.create(cr, uid,
{'name':'VAT%s%%'%(p_tax*100),
'description':'VAT%s%%'%(p_tax*100),
@ -458,7 +458,7 @@ class account_installer(osv.osv_memory):
tax_val.update({'supplier_taxes_id':[(6,0,[purchase_tax])]})
default_tax.append(('supplier_taxes_id',purchase_tax))
if len(tax_val):
product_ids = obj_product.search(cr,uid, [])
product_ids = obj_product.search(cr, uid, [])
for product in obj_product.browse(cr, uid, product_ids):
obj_product.write(cr, uid, product.id, tax_val)
for name, value in default_tax:

View File

@ -20,6 +20,7 @@
##############################################################################
import time
from operator import itemgetter
import decimal_precision as dp
import netsvc
@ -31,7 +32,7 @@ from tools.translate import _
class account_invoice(osv.osv):
def _amount_all(self, cr, uid, ids, name, args, context=None):
res = {}
for invoice in self.browse(cr,uid,ids, context=context):
for invoice in self.browse(cr, uid, ids, context=context):
res[invoice.id] = {
'amount_untaxed': 0.0,
'amount_tax': 0.0,
@ -111,12 +112,12 @@ class account_invoice(osv.osv):
context_unreconciled.update({'date':lines.date})
# If amount currency setted, compute for debit and credit in company currency
if lines.amount_currency < 0:
credit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False,context=context_unreconciled))
credit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False, context=context_unreconciled))
elif lines.amount_currency > 0:
debit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False,context=context_unreconciled))
debit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False, context=context_unreconciled))
# Then, recomput into invoice currency to avoid rounding trouble !
debit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, debit_tmp, round=False,context=context)
credit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, credit_tmp, round=False,context=context)
debit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, debit_tmp, round=False, context=context)
credit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, credit_tmp, round=False, context=context)
else:
debit+=debit_tmp
credit+=credit_tmp
@ -130,19 +131,19 @@ class account_invoice(osv.osv):
amount = debit-credit
result = inv.amount_total - amount
# Use is_zero function to avoid rounding trouble => should be fixed into ORM
res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_id.currency_id,result) and result or 0.0
res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_id.currency_id, result) and result or 0.0
return res
def _get_lines(self, cr, uid, ids, name, arg, context=None):
res = {}
for id in ids:
move_lines = self.move_line_id_payment_get(cr,uid,[id])
move_lines = self.move_line_id_payment_get(cr, uid, [id])
if not move_lines:
res[id] = []
continue
res[id] = []
data_lines = self.pool.get('account.move.line').browse(cr,uid,move_lines)
data_lines = self.pool.get('account.move.line').browse(cr, uid, move_lines)
partial_ids = []# Keeps the track of ids where partial payments are done with payment terms
for line in data_lines:
ids_line = []
@ -218,7 +219,7 @@ class account_invoice(osv.osv):
_order = "number"
_log_create = True
_columns = {
'name': fields.char('Description', size=64, select=True,readonly=True, states={'draft':[('readonly',False)]}),
'name': fields.char('Description', size=64, select=True, readonly=True, states={'draft':[('readonly',False)]}),
'origin': fields.char('Source Document', size=64, help="Reference of the document that produced this invoice."),
'type': fields.selection([
('out_invoice','Customer Invoice'),
@ -246,8 +247,8 @@ class account_invoice(osv.osv):
\n* The \'Open\' state is used when user create invoice,a invoice number is generated.Its in open state till user does not pay invoice. \
\n* The \'Done\' state is set automatically when invoice is paid.\
\n* The \'Cancelled\' state is used when user cancel invoice.'),
'date_invoice': fields.date('Date Invoiced', states={'open':[('readonly',True)],'close':[('readonly',True)]}, help="Keep empty to use the current date"),
'date_due': fields.date('Due Date', states={'open':[('readonly',True)],'close':[('readonly',True)]},
'date_invoice': fields.date('Date Invoiced', states={'open':[('readonly',True)], 'close':[('readonly',True)]}, help="Keep empty to use the current date"),
'date_due': fields.date('Due Date', states={'open':[('readonly',True)], 'close':[('readonly',True)]},
help="If you use payment terms, the due date will be computed automatically at the generation "\
"of accounting entries. If you keep the payment term and the due date empty, it means direct payment. The payment term may compute several due dates, for example 50% now, 50% in one month."),
'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}),
@ -264,7 +265,7 @@ class account_invoice(osv.osv):
'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="Links to the automatically generated Ledger Postings."),
'amount_untaxed': fields.function(_amount_all, method=True, digits_compute=dp.get_precision('Account'),string='Untaxed',
'amount_untaxed': fields.function(_amount_all, method=True, digits_compute=dp.get_precision('Account'), string='Untaxed',
store={
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20),
'account.invoice.tax': (_get_invoice_tax, None, 20),
@ -286,7 +287,7 @@ class account_invoice(osv.osv):
},
multi='all'),
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'journal_id': fields.many2one('account.journal', 'Journal', required=True,readonly=True, states={'draft':[('readonly',False)]}),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True),
'check_total': fields.float('Total', digits_compute=dp.get_precision('Account'), states={'open':[('readonly',True)],'close':[('readonly',True)]}),
'reconciled': fields.function(_reconciled, method=True, string='Paid/Reconciled', type='boolean',
@ -297,8 +298,8 @@ class account_invoice(osv.osv):
}, help="The Ledger Postings of the invoice have been reconciled with Ledger Postings of the payment(s)."),
'partner_bank': fields.many2one('res.partner.bank', 'Bank Account',
help='The bank account to pay to or to be paid from'),
'move_lines':fields.function(_get_lines , method=True,type='many2many' , relation='account.move.line',string='Entry Lines'),
'residual': fields.function(_amount_residual, method=True, digits_compute=dp.get_precision('Account'),string='Residual',
'move_lines':fields.function(_get_lines , method=True, type='many2many', relation='account.move.line', string='Entry Lines'),
'residual': fields.function(_amount_residual, method=True, digits_compute=dp.get_precision('Account'), string='Residual',
store={
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 50),
'account.invoice.tax': (_get_invoice_tax, None, 50),
@ -321,7 +322,7 @@ class account_invoice(osv.osv):
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
'reference_type': lambda *a: 'none',
'check_total': lambda *a: 0.0,
'user_id': lambda s,cr,u,c: u,
'user_id': lambda s, cr, u, c: u,
}
def create(self, cr, uid, vals, context={}):
@ -338,7 +339,7 @@ class account_invoice(osv.osv):
def confirm_paid(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state':'paid'}, context=context)
for (id,name) in self.name_get(cr, uid, ids):
for (id, name) in self.name_get(cr, uid, ids):
message = _('Document ') + " '" + name + "' "+ _("has been paid.")
self.log(cr, uid, id, message)
return True
@ -389,8 +390,8 @@ class account_invoice(osv.osv):
if not rec_res_id and not pay_res_id:
raise osv.except_osv(_('Configration Error !'),
_('Can not find account chart for this company, Please Create account.'))
rec_obj_acc=self.pool.get('account.account').browse(cr,uid,[rec_res_id])
pay_obj_acc=self.pool.get('account.account').browse(cr,uid,[pay_res_id])
rec_obj_acc=self.pool.get('account.account').browse(cr, uid, [rec_res_id])
pay_obj_acc=self.pool.get('account.account').browse(cr, uid, [pay_res_id])
p.property_account_receivable = rec_obj_acc[0]
p.property_account_payable = pay_obj_acc[0]
@ -418,7 +419,7 @@ class account_invoice(osv.osv):
if payment_term != partner_payment_term:
if partner_payment_term:
to_update = self.onchange_payment_term_date_invoice(
cr,uid,ids,partner_payment_term,date_invoice)
cr, uid, ids, partner_payment_term, date_invoice)
result['value'].update(to_update['value'])
else:
result['value']['date_due'] = False
@ -470,14 +471,14 @@ class account_invoice(osv.osv):
partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id)
if partner_obj.property_account_payable and partner_obj.property_account_receivable:
if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id:
rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
if not rec_pro_id:
rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)])
rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)])
if not pay_pro_id:
pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)])
rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id'])
pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id'])
pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)])
rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id'])
pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id'])
rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False
pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False
if not rec_res_id and not rec_res_id:
@ -494,15 +495,15 @@ class account_invoice(osv.osv):
for line in inv_obj[0].invoice_line:
if line.account_id:
if line.account_id.company_id.id != company_id:
result_id = self.pool.get('account.account').search(cr,uid,[('name','=',line.account_id.name),('company_id','=',company_id)])
result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)])
if not result_id:
raise osv.except_osv(_('Configration Error !'),
_('Can not find account chart for this company in invoice line account, Please Create account.'))
r_id = self.pool.get('account.invoice.line').write(cr,uid,[line.id],{'account_id': result_id[0]})
r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]})
else:
if invoice_line:
for inv_line in invoice_line:
obj_l = self.pool.get('account.account').browse(cr,uid,inv_line[2]['account_id'])
obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id'])
if obj_l.company_id.id != company_id:
raise osv.except_osv(_('Configration Error !'),
_('invoice line account company is not match with invoice company.'))
@ -565,12 +566,13 @@ class account_invoice(osv.osv):
def move_line_id_payment_get(self, cr, uid, ids, *args):
res = []
if not ids: return res
cr.execute('select \
l.id \
from account_move_line l \
left join account_invoice i on (i.move_id=l.move_id) \
where i.id in ('+','.join(map(str,map(int, ids)))+') and l.account_id=i.account_id')
res = map(lambda x: x[0], cr.fetchall())
cr.execute('SELECT l.id '\
'FROM account_move_line l '\
'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\
'WHERE i.id IN %s '\
'AND l.account_id=i.account_id',
(tuple(ids),))
res = map(itemgetter(0), cr.fetchall())
return res
def copy(self, cr, uid, id, default=None, context=None):
@ -600,7 +602,7 @@ class account_invoice(osv.osv):
ait_obj = self.pool.get('account.invoice.tax')
for id in ids:
cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,))
partner = self.browse(cr, uid, id,context=context).partner_id
partner = self.browse(cr, uid, id, context=context).partner_id
if partner.lang:
context.update({'lang': partner.lang})
for taxe in ait_obj.compute(cr, uid, id, context=context).values():
@ -856,7 +858,7 @@ class account_invoice(osv.osv):
move = {'ref': inv.number, 'line_id': line, 'journal_id': journal_id, 'date': date, 'type': entry_type}
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 or time.strftime('%Y-%m-%d')),('date_stop','>=',inv.date_invoice or time.strftime('%Y-%m-%d'))])
period_ids= self.pool.get('account.period').search(cr, uid, [('date_start','<=',inv.date_invoice or time.strftime('%Y-%m-%d')),('date_stop','>=',inv.date_invoice or time.strftime('%Y-%m-%d'))])
if len(period_ids):
period_id=period_ids[0]
if period_id:
@ -895,8 +897,9 @@ class account_invoice(osv.osv):
def action_number(self, cr, uid, ids, *args):
cr.execute('SELECT id, type, number, move_id, reference ' \
'FROM account_invoice ' \
'WHERE id IN ('+','.join(map(str, ids))+')')
'FROM account_invoice ' \
'WHERE id IN %s',
(tuple(ids),))
obj_inv = self.browse(cr, uid, ids)[0]
for (id, invtype, number, move_id, reference) in cr.fetchall():
if not number:
@ -943,7 +946,7 @@ class account_invoice(osv.osv):
raise osv.except_osv(_('Error !'), _('You cannot cancel the Invoice which is Partially Paid! You need to unreconcile concerned payment entries!'))
self.write(cr, uid, ids, {'state':'cancel', 'move_id':False})
self._log_event(cr, uid, ids,-1.0, 'Cancel Invoice')
self._log_event(cr, uid, ids, -1.0, 'Cancel Invoice')
return True
###################
@ -1129,7 +1132,9 @@ class account_invoice(osv.osv):
move_ids = [move_id,]
if invoice.move_id:
move_ids.append(invoice.move_id.id)
cr.execute('SELECT id FROM account_move_line WHERE move_id = ANY(%s)',(move_ids,))
cr.execute('SELECT id FROM account_move_line '\
'WHERE move_id IN %s',
((move_id, invoice.move_id.id),))
lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) )
for l in lines+invoice.payment_ids:
if l.account_id.id==src_account_id:
@ -1146,7 +1151,7 @@ class account_invoice(osv.osv):
account_invoice()
class account_invoice_line(osv.osv):
def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict):
def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict):
res = {}
tax_obj = self.pool.get('account.tax')
cur_obj = self.pool.get('res.currency')
@ -1231,12 +1236,12 @@ class account_invoice_line(osv.osv):
res = self.pool.get('product.product').browse(cr, uid, product, context=context)
if company_id:
in_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
if not in_pro_id:
in_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
exp_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
if not exp_pro_id:
exp_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
if not in_pro_id:
in_acc = res.product_tmpl_id.property_account_income
@ -1246,7 +1251,7 @@ class account_invoice_line(osv.osv):
else:
app_acc_in = in_acc_cate
else:
app_acc_in = self.pool.get('account.account').browse(cr,uid,in_pro_id)[0]
app_acc_in = self.pool.get('account.account').browse(cr, uid, in_pro_id)[0]
if not exp_pro_id:
ex_acc = res.product_tmpl_id.property_account_expense
ex_acc_cate = res.categ_id.property_account_expense_categ
@ -1255,7 +1260,7 @@ class account_invoice_line(osv.osv):
else:
app_acc_exp = ex_acc_cate
else:
app_acc_exp = self.pool.get('account.account').browse(cr,uid,exp_pro_id)[0]
app_acc_exp = self.pool.get('account.account').browse(cr, uid, exp_pro_id)[0]
if not in_pro_id and not exp_pro_id:
in_acc = res.product_tmpl_id.property_account_income
in_acc_cate = res.categ_id.property_account_income_categ
@ -1271,13 +1276,13 @@ class account_invoice_line(osv.osv):
# app_acc_in = self.pool.get('account.account').browse(cr,uid,in_pro_id)[0]
# app_acc_exp = self.pool.get('account.account').browse(cr,uid,exp_pro_id)[0]
if app_acc_in.company_id.id != company_id and app_acc_exp.company_id.id != company_id:
in_res_id=self.pool.get('account.account').search(cr,uid,[('name','=',app_acc_in.name),('company_id','=',company_id)])
exp_res_id=self.pool.get('account.account').search(cr,uid,[('name','=',app_acc_exp.name),('company_id','=',company_id)])
in_res_id=self.pool.get('account.account').search(cr, uid, [('name','=',app_acc_in.name),('company_id','=',company_id)])
exp_res_id=self.pool.get('account.account').search(cr, uid, [('name','=',app_acc_exp.name),('company_id','=',company_id)])
if not in_res_id and not exp_res_id:
raise osv.except_osv(_('Configration Error !'),
_('Can not find account chart for this company, Please Create account.'))
in_obj_acc=self.pool.get('account.account').browse(cr,uid,in_res_id)
exp_obj_acc=self.pool.get('account.account').browse(cr,uid,exp_res_id)
in_obj_acc=self.pool.get('account.account').browse(cr, uid, in_res_id)
exp_obj_acc=self.pool.get('account.account').browse(cr, uid, exp_res_id)
if in_acc or ex_acc:
res.product_tmpl_id.property_account_income = in_obj_acc[0]
res.product_tmpl_id.property_account_expense = exp_obj_acc[0]
@ -1301,10 +1306,10 @@ class account_invoice_line(osv.osv):
taxep=None
tax_obj = self.pool.get('account.tax')
if type in ('out_invoice', 'out_refund'):
taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid,a).tax_ids or False)
taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
else:
taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid,a).tax_ids or False)
taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
if type in ('in_invoice', 'in_refund'):
to_update = self.product_id_change_unit_price_inv(cr, uid, tax_id, price_unit or res.standard_price, qty, address_invoice_id, product, partner_id, context=context)
@ -1439,25 +1444,25 @@ class account_invoice_tax(osv.osv):
'base_amount': fields.float('Base Code Amount', digits_compute=dp.get_precision('Account')),
'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="The tax basis of the tax declaration."),
'tax_amount': fields.float('Tax Code Amount', digits_compute=dp.get_precision('Account')),
'company_id': fields.related('account_id','company_id',type='many2one',relation='res.company',string='Company',store=True),
'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True),
}
def base_change(self, cr, uid, ids, base,currency_id=False,company_id=False,date_invoice=False):
def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, date_invoice=False):
cur_obj = self.pool.get('res.currency')
company_obj = self.pool.get('res.company')
company_currency=False
if company_id:
company_currency = company_obj.read(cr,uid,[company_id],['currency_id'])[0]['currency_id'][0]
company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0]
if currency_id and company_currency:
base = cur_obj.compute(cr, uid, currency_id, company_currency, base, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False)
return {'value': {'base_amount':base}}
def amount_change(self, cr, uid, ids, amount,currency_id=False,company_id=False,date_invoice=False):
def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False):
cur_obj = self.pool.get('res.currency')
company_obj = self.pool.get('res.company')
company_currency=False
if company_id:
company_currency = company_obj.read(cr,uid,[company_id],['currency_id'])[0]['currency_id'][0]
company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0]
if currency_id and company_currency:
amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False)
return {'value': {'tax_amount':amount}}

View File

@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from operator import itemgetter
from osv import fields, osv
import ir
@ -88,22 +89,19 @@ class res_partner(osv.osv):
_name = 'res.partner'
_inherit = 'res.partner'
_description = 'Partner'
def _credit_debit_get(self, cr, uid, ids, field_names, arg, context):
query = self.pool.get('account.move.line')._query_get(cr, 1, context=context)
cr.execute("""select
l.partner_id, a.type, sum(l.debit-l.credit)
from
account_move_line l
left join
account_account a on (l.account_id=a.id)
where
a.type =ANY(%s) and
l.partner_id =ANY(%s) and
l.reconcile_id is null and
"""+query+"""
group by
l.partner_id, a.type
""",(['receivable','payable'],ids,))
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
cr.execute("""SELECT l.partner_id, a.type, SUM(l.debit-l.credit)
FROM account_move_line l
LEFT JOIN account_account a ON (l.account_id=a.id)
WHERE a.type IN ('receivable','payable')
AND l.partner_id IN %s
AND l.reconcile_id IS NULL
AND """ + query + """
GROUP BY l.partner_id, a.type
""",
(tuple(ids),))
tinvert = {
'credit': 'receivable',
'debit': 'payable'
@ -116,28 +114,34 @@ class res_partner(osv.osv):
if val is None: val=0
res[pid][maps[type]] = (type=='receivable') and val or -val
return res
def _credit_search(self, cr, uid, obj, name, args, context):
def _asset_difference_search(self, cr, uid, obj, name, type, args, context=None):
if not len(args):
return []
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('receivable',) )
having_values = tuple(map(itemgetter(2), args))
where = ' AND '.join(
map(lambda x: '(SUM(debit-credit) %(operator)s %%s)' % {
'operator':x[1]},args))
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
cr.execute(('SELECT partner_id FROM account_move_line l '\
'WHERE account_id IN '\
'(SELECT id FROM account_account '\
'WHERE type=%s AND active) '\
'AND reconcile_id IS NULL '\
'AND '+query+' '\
'AND partner_id IS NOT NULL '\
'GROUP BY partner_id HAVING '+where),
(type,) + having_values)
res = cr.fetchall()
if not len(res):
return [('id','=','0')]
return [('id','in',map(lambda x:x[0], res))]
return [('id','in',map(itemgetter(0), res))]
def _credit_search(self, cr, uid, obj, name, args, context):
return self._asset_difference_search(cr, uid, obj, name, 'receivable', args, context=context)
def _debit_search(self, cr, uid, obj, name, args, context):
if not len(args):
return []
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('payable',) )
res = cr.fetchall()
if not len(res):
return [('id','=','0')]
return [('id','in',map(lambda x:x[0], res))]
return self._asset_difference_search(cr, uid, obj, name, 'payable', args, context=context)
_columns = {
'credit': fields.function(_credit_debit_get,

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

View File

@ -32,15 +32,9 @@ class account_analytic_balance(report_sxw.rml_parse):
'get_objects': self._get_objects,
'lines_g': self._lines_g,
'move_sum': self._move_sum,
# 'move_sum_debit': self._move_sum_debit,
# 'move_sum_credit': self._move_sum_credit,
'sum_all': self._sum_all,
# 'sum_debit': self._sum_debit,
# 'sum_credit': self._sum_credit,
'sum_balance': self._sum_balance,
# 'sum_quantity': self._sum_quantity,
'move_sum_balance': self._move_sum_balance,
# 'move_sum_quantity': self._move_sum_quantity,
})
self.acc_ids = []
self.read_data = []
@ -81,10 +75,10 @@ class account_analytic_balance(report_sxw.rml_parse):
sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \
FROM account_analytic_line AS aal, account_account AS aa \
WHERE (aal.general_account_id=aa.id) \
AND (aal.account_id in (" + ','.join(map(str, ids)) + "))\
AND (aal.account_id IN aal.account_id IN %s)\
AND (date>=%s) AND (date<=%s) AND aa.active \
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \
ORDER BY aal.code", (date1, date2))
ORDER BY aal.code", (tuple(ids), date1, date2))
res = self.cr.dictfetchall()
for r in res:
@ -107,62 +101,26 @@ class account_analytic_balance(report_sxw.rml_parse):
self.acc_data_dict[account_id] = ids
else:
ids = self.acc_data_dict[account_id]
query_params = (tuple(ids), date1, date2)
if option == "credit" :
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0",
(ids,date1, date2))
WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0",query_params)
elif option == "debit" :
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
WHERE account_id =ANY(%s)\
AND date>=%s AND date<=%s AND amount>0",
(ids,date1, date2))
WHERE account_id IN %s\
AND date>=%s AND date<=%s AND amount>0",query_params)
elif option == "quantity" :
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
WHERE account_id =ANY(%s)\
AND date>=%s AND date<=%s",
(ids,date1, date2))
WHERE account_id IN %s\
AND date>=%s AND date<=%s",query_params)
return self.cr.fetchone()[0] or 0.0
# def _move_sum_debit(self, account_id, date1, date2):
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', [account_id])])
# self.cr.execute("SELECT sum(amount) \
# FROM account_analytic_line \
# WHERE account_id in ("+ ','.join(map(str, ids)) +") \
# AND date>=%s AND date<=%s AND amount>0",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
#
# def _move_sum_credit(self, account_id, date1, date2):
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', [account_id])])
# self.cr.execute("SELECT -sum(amount) \
# FROM account_analytic_line \
# WHERE account_id in ("+ ','.join(map(str, ids)) +") \
# AND date>=%s AND date<=%s AND amount<0",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
#
def _move_sum_balance(self, account_id, date1, date2):
debit = self._move_sum(account_id, date1, date2, 'debit')
credit = self._move_sum(account_id, date1, date2, 'credit')
return (debit-credit)
# def _move_sum_quantity(self, account_id, date1, date2):
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', [account_id])])
# self.cr.execute("SELECT sum(unit_amount) \
# FROM account_analytic_line \
# WHERE account_id in ("+ ','.join(map(str, ids)) +") \
# AND date>=%s AND date<=%s",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
def _sum_all(self, accounts, date1, date2, option):
ids = map(lambda x: x['id'], accounts)
if not len(ids):
@ -174,68 +132,25 @@ class account_analytic_balance(report_sxw.rml_parse):
self.acc_sum_list = ids2
else:
ids2 = self.acc_sum_list
query_params = (tuple(ids2), date1, date2)
if option == "debit" :
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0",
(ids,date1, date2,))
WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0",query_params)
elif option == "credit" :
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0",
(ids,date1, date2,))
WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0",query_params)
elif option == "quantity" :
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
WHERE account_id =ANY(%s)AND date>=%s AND date<=%s",
(ids,date1, date2,))
WHERE account_id IN %s AND date>=%s AND date<=%s",query_params)
return self.cr.fetchone()[0] or 0.0
# def _sum_debit(self, accounts, date1, date2):
# ids = map(lambda x: x['id'], accounts)
# if not len(ids):
# return 0.0
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids2 = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', ids)])
# self.cr.execute("SELECT sum(amount) \
# FROM account_analytic_line \
# WHERE account_id IN ("+','.join(map(str, ids2))+") \
# AND date>=%s AND date<=%s AND amount>0",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
#
# def _sum_credit(self, accounts, date1, date2):
# ids = map(lambda x: x['id'], accounts)
# if not len(ids):
# return 0.0
# ids = map(lambda x: x['id'], accounts)
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids2 = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', ids)])
# self.cr.execute("SELECT -sum(amount) \
# FROM account_analytic_line \
# WHERE account_id IN ("+','.join(map(str, ids2))+") \
# AND date>=%s AND date<=%s AND amount<0",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
def _sum_balance(self, accounts, date1, date2):
debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0
credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0
return (debit-credit)
# def _sum_quantity(self, accounts, date1, date2):
# ids = map(lambda x: x['id'], accounts)
# if not len(ids):
# return 0.0
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids2 = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', ids)])
# self.cr.execute("SELECT sum(unit_amount) \
# FROM account_analytic_line \
# WHERE account_id IN ("+','.join(map(str, ids2))+") \
# AND date>=%s AND date<=%s",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.analytic.account.balance',
'account.analytic.account', 'addons/account/project/report/analytic_balance.rml',

View File

@ -77,41 +77,6 @@ class account_analytic_analytic_check(report_sxw.rml_parse):
return res
# def _lines_p(self, date1, date2):
# res = []
# acc_obj = self.pool.get('account.account')
# for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code','sign']):
# self.cr.execute("SELECT sum(debit), sum(credit) \
# FROM account_move_line \
# WHERE date>=%s AND date<=%s AND state<>'draft' AND account_id = %s", (date1, date2, a['id']))
# (gd, gc) = self.cr.fetchone()
# gd = gd or 0.0
# gc = gc or 0.0
#
# self.cr.execute("SELECT abs(sum(amount)) AS balance \
# FROM account_analytic_line \
# WHERE date>=%s AND date<=%s AND amount*%s>0 AND general_account_id = %s", (date1, date2, a['sign'], a['id']))
# (ad,) = self.cr.fetchone()
# ad = ad or 0.0
# self.cr.execute("SELECT abs(sum(amount)) AS balance \
# FROM account_analytic_line \
# WHERE date>=%s AND date<=%s AND amount*%s<0 AND general_account_id = %s", (date1, date2, a['sign'], a['id']))
# (ac,) = self.cr.fetchone()
# ac = ac or 0.0
#
# res.append({'code': a['code'], 'name': a['name'],
# 'gen_debit': gd,
# 'gen_credit': gc,
# 'ana_debit': ad,
# 'ana_credit': ac,
# 'delta_debit': gd - ad,
# 'delta_credit': gc - ac,})
# self.sum_gen_deb += gd
# self.sum_gen_cred += gc
# self.sum_ana_deb += ad
# self.sum_ana_cred += ac
# return res
def _gen_deb(self, date1, date2):
return self.sum_gen_deb

View File

@ -93,15 +93,14 @@ class account_analytic_cost_ledger(report_sxw.rml_parse):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids, date1, date2,))
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(ids), date1, date2,))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
ids = map(lambda x: x.id, accounts)
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,))
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(ids),date1, date2,))
return self.cr.fetchone()[0] or 0.0
def _sum_balance(self, accounts, date1, date2):

View File

@ -38,12 +38,17 @@ class account_inverted_analytic_balance(report_sxw.rml_parse):
def _lines_g(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
self.cr.execute("SELECT aa.name AS name, aa.code AS code, sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aa.id AS id \
self.cr.execute("SELECT aa.name AS name, aa.code AS code, "
"sum(aal.amount) AS balance, "
"sum(aal.unit_amount) AS quantity, aa.id AS id \
FROM account_analytic_line AS aal, account_account AS aa \
WHERE (aal.general_account_id=aa.id) AND (aal.account_id =ANY(%s)) AND (date>=%s) AND (date<=%s) AND aa.active \
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (ids,date1,date2,))
WHERE (aal.general_account_id=aa.id) "
"AND (aal.account_id IN %s) "
"AND (date>=%s) AND (date<=%s) AND aa.active \
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id "
"ORDER BY aal.code",
(tuple(ids), date1, date2))
res = self.cr.dictfetchall()
for r in res:
if r['balance'] > 0:
r['debit'] = r['balance']
@ -58,10 +63,17 @@ class account_inverted_analytic_balance(report_sxw.rml_parse):
def _lines_a(self, accounts, general_account_id, date1, date2):
ids = map(lambda x: x.id, accounts)
self.cr.execute("SELECT sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aaa.code AS code, aaa.name AS name, account_id \
FROM account_analytic_line AS aal, account_analytic_account AS aaa \
WHERE aal.account_id=aaa.id AND aal.account_id =ANY(%s) AND aal.general_account_id=%s AND aal.date>=%s AND aal.date<=%s \
GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (ids,general_account_id, date1, date2,))
self.cr.execute("SELECT sum(aal.amount) AS balance, "
"sum(aal.unit_amount) AS quantity, "
"aaa.code AS code, aaa.name AS name, account_id \
FROM account_analytic_line AS aal, "
"account_analytic_account AS aaa \
WHERE aal.account_id=aaa.id AND aal.account_id IN %s "
"AND aal.general_account_id=%s AND aal.date>=%s "
"AND aal.date<=%s \
GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name "
"ORDER BY aal.account_id",
(tuple(ids), general_account_id, date1, date2))
res = self.cr.dictfetchall()
aaa_obj = self.pool.get('account.analytic.account')
@ -86,14 +98,14 @@ class account_inverted_analytic_balance(report_sxw.rml_parse):
ids = map(lambda x: x.id, accounts)
self.cr.execute("SELECT sum(amount) \
FROM account_analytic_line \
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids,date1, date2,))
WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(ids),date1, date2,))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
self.cr.execute("SELECT -sum(amount) \
FROM account_analytic_line \
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,))
WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(ids),date1, date2,))
return self.cr.fetchone()[0] or 0.0
def _sum_balance(self, accounts, date1, date2):
@ -105,7 +117,7 @@ class account_inverted_analytic_balance(report_sxw.rml_parse):
ids = map(lambda x: x.id, accounts)
self.cr.execute("SELECT sum(unit_amount) \
FROM account_analytic_line \
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", (ids,date1, date2,))
WHERE account_id IN %s AND date>=%s AND date<=%s", (tuple(ids),date1, date2,))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header=False)

View File

@ -52,9 +52,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
WHERE (aal.account_id=%s) AND (aal.date>=%s) \
AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
AND aa.active \
AND (aal.journal_id =ANY(%s) ) \
AND (aal.journal_id IN %s ) \
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code",
(account_id, date1, date2,journal_ids))
(account_id, date1, date2, tuple(journal_ids)))
res = self.cr.dictfetchall()
return res
@ -79,9 +79,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
account_analytic_journal AS aaj \
WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \
AND (aal.date>=%s) AND (aal.date<=%s) \
AND (aal.journal_id=aaj.id) AND (aaj.id =ANY(%s)) \
AND (aal.journal_id=aaj.id) AND (aaj.id IN %s) \
ORDER BY aal.date, aaj.code, aal.code",
(general_account_id, account_id, date1, date2,journal_ids,))
(general_account_id, account_id, date1, date2,tuple(journal_ids)))
res = self.cr.dictfetchall()
return res
@ -96,8 +96,8 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
self.cr.execute("SELECT sum(unit_amount) \
FROM account_analytic_line \
WHERE account_id = %s AND date >= %s AND date <= %s \
AND journal_id =ANY(%s)",
(account_id, date1, date2,journal_ids,))
AND journal_id IN %s",
(account_id, date1, date2, tuple(journal_ids),))
return self.cr.fetchone()[0] or 0.0
def _sum_quantity(self, accounts, date1, date2, journals):
@ -107,14 +107,14 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
if not journals:
self.cr.execute("SELECT sum(unit_amount) \
FROM account_analytic_line \
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s",
(ids, date1, date2,))
WHERE account_id IN %s AND date>=%s AND date<=%s",
(tuple(ids), date1, date2,))
else:
journal_ids = journals
self.cr.execute("SELECT sum(unit_amount) \
FROM account_analytic_line \
WHERE account_id =ANY(%s) AND date >= %s AND date <= %s \
AND journal_id =ANY(%s)",(ids, date1, date2, journal_ids))
WHERE account_id IN %s AND date >= %s AND date <= %s \
AND journal_id IN %s",(tuple(ids), date1, date2, tuple(journal_ids)))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger',

View File

@ -29,7 +29,7 @@ class account_analytic_cost_ledger_journal_report(osv.osv_memory):
_columns = {
'date1': fields.date('Start of period', required=True),
'date2': fields.date('End of period', required=True),
'journal': fields.many2many('account.analytic.journal', 'ledger_journal_rel','ledger_id', 'Journal_id','Journals'),
'journal': fields.many2many('account.analytic.journal', 'ledger_journal_rel', 'ledger_id', 'Journal_id', 'Journals'),
}
_defaults = {

View File

@ -38,8 +38,8 @@ class account_account_report(osv.osv):
('closed', 'Closed'),
], 'Internal Type', readonly=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'currency_mode': fields.selection([('current', 'At Date'), ('average', 'Average Rate')], 'Outgoing Currencies Rate',readonly=True),
'user_type': fields.many2one('account.account.type', 'Account Type',readonly=True),
'currency_mode': fields.selection([('current', 'At Date'), ('average', 'Average Rate')], 'Outgoing Currencies Rate', readonly=True),
'user_type': fields.many2one('account.account.type', 'Account Type', readonly=True),
'quantity': fields.float('Quantity', readonly=True),
'amount_total': fields.float('Total Amount', readonly=True),
'credit': fields.float('Credit', readonly=True),

View File

@ -28,21 +28,21 @@ class analytic_report(osv.osv):
_auto = False
_columns = {
'date_start': fields.date('Date Start', readonly=True),
'date_end': fields.date('Date End',readonly=True),
'date_end': fields.date('Date End', readonly=True),
'name' : fields.char('Analytic Account', size=128, readonly=True),
'partner_id' : fields.many2one('res.partner', 'Associated Partner',readonly=True),
'partner_id' : fields.many2one('res.partner', 'Associated Partner', readonly=True),
'journal_id' : fields.many2one('account.analytic.journal', 'Analytic Journal', readonly=True),
'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', readonly=True),
'user_id' : fields.many2one('res.users', 'Account Manager',readonly=True),
'product_id' : fields.many2one('product.product', 'Product',readonly=True),
'total_quantity': fields.float('# Total Quantity',readonly=True),
'debit' : fields.float('Debit',readonly=True),
'credit' : fields.float('Credit',readonly=True),
'balance' : fields.float('Balance',readonly=True),
'user_id' : fields.many2one('res.users', 'Account Manager', readonly=True),
'product_id' : fields.many2one('product.product', 'Product', readonly=True),
'total_quantity': fields.float('# Total Quantity', readonly=True),
'debit' : fields.float('Debit', readonly=True),
'credit' : fields.float('Credit', readonly=True),
'balance' : fields.float('Balance', readonly=True),
'year': fields.char('Year', size=4, readonly=True),
'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),
('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True),
'day': fields.char('Day', size=128, readonly=True),
'nbr':fields.integer('# of Lines', readonly=True),
'company_id': fields.many2one('res.company', 'Company', readonly=True),

View File

@ -68,14 +68,14 @@ class account_balance(report_sxw.rml_parse):
result=''
if form.has_key('periods') and form['periods']:
period_ids = form['periods']
per_ids = self.pool.get('account.period').browse(self.cr,self.uid,form['periods'])
per_ids = self.pool.get('account.period').browse(self.cr, self.uid, form['periods'])
for r in per_ids:
if r == per_ids[len(per_ids)-1]:
result+=r.name+". "
else:
result+=r.name+", "
else:
fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear'])
fy_obj = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear'])
res = fy_obj.period_ids
len_res = len(res)
for r in res:
@ -118,7 +118,7 @@ class account_balance(report_sxw.rml_parse):
child_ids = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, ids, ctx)
if child_ids:
ids = child_ids
accounts = self.pool.get('account.account').read(self.cr, self.uid, ids,['type','code','name','debit','credit','balance','parent_id'], ctx)
accounts = self.pool.get('account.account').read(self.cr, self.uid, ids, ['type','code','name','debit','credit','balance','parent_id'], ctx)
for account in accounts:
if account['id'] in done:
continue

View File

@ -351,7 +351,7 @@ class account_balance_landscape(rml_parse.rml_parse):
if perc==1:
if form['select_account']!=False:
ref_ac=self.pool.get('account.account').browse(self.cr, self.uid,form['select_account'],ctx.copy())
ref_ac=self.pool.get('account.account').browse(self.cr, self.uid, form['select_account'], ctx.copy())
if ref_ac.balance<>0.00:
ref_bal=ref_ac.balance
else:
@ -365,7 +365,7 @@ class account_balance_landscape(rml_parse.rml_parse):
total_for_perc=[]
# if perc==1:
self.done_total=1
self.total_for_perc=self.linesForTotal(form,ids={},doneAccount={},level=1)
self.total_for_perc=self.linesForTotal(form, ids={}, doneAccount={}, level=1)
self.done_total=0
for t1 in range(0,len(form['fiscalyear'])):
@ -376,13 +376,13 @@ class account_balance_landscape(rml_parse.rml_parse):
# self.result_total = {}
for temp in range(0,len(form['fiscalyear'])):
fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp])
fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp])
years["year"+str(temp)]=fy[0][1][12:16]
return [years]
def linesForTotal(self,form,ids={},doneAccount={},level=1):
def linesForTotal(self, form, ids={}, doneAccount={}, level=1):
if self.done_total==1:
self.done_total==1
else:
@ -443,7 +443,7 @@ class account_balance_landscape(rml_parse.rml_parse):
ids2 = [(x.code,x.id) for x in entry[0].child_id]
ids2.sort()
result_total_parent = self.linesForTotal(form, [x[1] for x in ids2],doneAccount,level+1)
result_total_parent = self.linesForTotal(form, [x[1] for x in ids2], doneAccount, level+1)
return [self.result_total]
@ -462,7 +462,7 @@ class account_balance_landscape(rml_parse.rml_parse):
ctx['periods'] = form['periods']
ctx['period_manner']=form['period_manner']
ctx['state'] = form['context'].get('state','all')
tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy())
tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy())
if len(tmp1):
accounts.append(tmp1)
@ -598,12 +598,12 @@ class account_balance_landscape(rml_parse.rml_parse):
return result
def get_years(self,form):
def get_years(self, form):
result =[]
res={}
for temp in range(0,len(form['fiscalyear'])):
for temp in range(0, len(form['fiscalyear'])):
res={}
fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp])
fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp])
res['year']=fy[0][1]
res['last_str']=temp
@ -611,7 +611,7 @@ class account_balance_landscape(rml_parse.rml_parse):
self.linesForYear(form)
return result
def get_lines(self,year_dict,form):
def get_lines(self, year_dict, form):
final_result = []
line_l =[]
res = {}
@ -643,7 +643,7 @@ class account_balance_landscape(rml_parse.rml_parse):
final_result.append(res)
return final_result
def cal_total(self,year_dict):
def cal_total(self, year_dict):
total_l = self.result_total
if total_l:
for k,v in total_l.items():

View File

@ -33,18 +33,18 @@ class account_entries_report(osv.osv):
'date_maturity': fields.date('Date Maturity', readonly=True),
'nbr':fields.integer('# of Entries', readonly=True),
'nbl':fields.integer('# of Lines', readonly=True),
'amount': fields.float('Amount',readonly=True),
'amount': fields.float('Amount', readonly=True),
'year': fields.char('Year', size=4, readonly=True),
'day': fields.char('Day', size=128, readonly=True),
'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),
'ref': fields.char('Reference', size=64,readonly=True),
('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True),
'ref': fields.char('Reference', size=64, readonly=True),
'period_id': fields.many2one('account.period', 'Period', readonly=True),
'account_id': fields.many2one('account.account', 'Account', readonly=True),
'journal_id': fields.many2one('account.journal', 'Journal', readonly=True),
'product_id': fields.many2one('product.product', 'Product', readonly=True),
'state': fields.selection([('draft','Draft'), ('posted','Posted')], 'State',readonly=True,
'state': fields.selection([('draft','Draft'), ('posted','Posted')], 'State', readonly=True,
help='When new account move is created the state will be \'Draft\'. When all the payments are done it will be in \'Posted\' state.'),
'state_2': fields.selection([('draft','Draft'), ('valid','Valid')], 'State of Move Line', readonly=True,
help='When new move line is created the state will be \'Draft\'.\n* When all the payments are done it will be in \'Valid\' state.'),

View File

@ -33,16 +33,16 @@ class account_invoice_report(osv.osv):
'day': fields.char('Day', size=128, readonly=True),
'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),
('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True),
'product_id':fields.many2one('product.product', 'Product', readonly=True),
'product_qty':fields.float('Qty', readonly=True),
'uom_name': fields.char('Default UoM', size=128, readonly=True),
'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True),
'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')],readonly=True),
'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position',readonly=True),
'payment_term': fields.many2one('account.payment.term', 'Payment Term', readonly=True),
'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], readonly=True),
'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position', readonly=True),
'currency_id': fields.many2one('res.currency', 'Currency', readonly=True),
'categ_id': fields.many2one('product.category','Category of Product', readonly=True),
'journal_id': fields.many2one('account.journal', 'Journal',readonly=True),
'journal_id': fields.many2one('account.journal', 'Journal', readonly=True),
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
'company_id':fields.many2one('res.company', 'Company', readonly=True),
'user_id':fields.many2one('res.users', 'Salesman', readonly=True),

View File

@ -207,15 +207,15 @@ class report_account_type_sales(osv.osv):
_description = "Report of the Sales by Account Type"
_auto = False
_columns = {
'name': fields.char('Year',size=64,required=False, readonly=True),
'period_id': fields.many2one('account.period', 'Force Period',readonly=True),
'product_id': fields.many2one('product.product', 'Product',readonly=True),
'name': fields.char('Year', size=64, required=False, readonly=True),
'period_id': fields.many2one('account.period', 'Force Period', readonly=True),
'product_id': fields.many2one('product.product', 'Product', readonly=True),
'quantity': fields.float('Quantity', readonly=True),
'user_type': fields.many2one('account.account.type', 'Account Type', readonly=True),
'amount_total': fields.float('Total', readonly=True),
'currency_id': fields.many2one('res.currency', 'Currency', readonly=True),
'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),
('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True),
}
_order = 'name desc,amount_total desc'
@ -249,15 +249,15 @@ class report_account_sales(osv.osv):
_description = "Report of the Sales by Account"
_auto = False
_columns = {
'name': fields.char('Year',size=64,required=False, readonly=True),
'period_id': fields.many2one('account.period', 'Force Period',readonly=True),
'product_id': fields.many2one('product.product', 'Product',readonly=True),
'name': fields.char('Year', size=64, required=False, readonly=True),
'period_id': fields.many2one('account.period', 'Force Period', readonly=True),
'product_id': fields.many2one('product.product', 'Product', readonly=True),
'quantity': fields.float('Quantity', readonly=True),
'account_id': fields.many2one('account.account', 'Account', readonly=True),
'amount_total': fields.float('Total', readonly=True),
'currency_id': fields.many2one('res.currency', 'Currency', readonly=True),
'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),
('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True),
}
_order = 'name desc,amount_total desc'

View File

@ -80,13 +80,13 @@ class aged_trial_report(rml_parse.rml_parse):
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
FROM account_move_line AS line, account_account
WHERE (line.account_id = account_account.id)
AND (account_account.type =ANY(%s))
AND (partner_id =ANY (%s))
AND (account_account.type IN %s)
AND (partner_id IN %s)
AND ((reconcile_id IS NULL)
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
AND (account_account.company_id = %s)
AND account_account.active
GROUP BY partner_id""" , (self.ACCOUNT_TYPE, partner_ids,form['date1'],form['company_id'],))
GROUP BY partner_id""" , (tuple(self.ACCOUNT_TYPE), tuple(partner_ids),form['date1'],form['company_id'],))
t = self.cr.fetchall()
for i in t:
totals[i[0]] = i[1]
@ -97,14 +97,14 @@ class aged_trial_report(rml_parse.rml_parse):
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
FROM account_move_line AS line, account_account
WHERE (line.account_id=account_account.id)
AND (account_account.type =ANY (%s))
AND (account_account.type IN %s)
AND (COALESCE(date_maturity,date) < %s)
AND (partner_id =ANY (%s))
AND (partner_id IN %s)
AND ((reconcile_id IS NULL)
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
AND (account_account.company_id = %s)
AND account_account.active
GROUP BY partner_id""", (self.ACCOUNT_TYPE, form['date1'], partner_ids,form['date1'], form['company_id'],))
GROUP BY partner_id""", (tuple(self.ACCOUNT_TYPE), form['date1'], tuple(partner_ids),form['date1'], form['company_id'],))
t = self.cr.fetchall()
for i in t:
future_past[i[0]] = i[1]
@ -112,14 +112,14 @@ class aged_trial_report(rml_parse.rml_parse):
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
FROM account_move_line AS line, account_account
WHERE (line.account_id=account_account.id)
AND (account_account.type =ANY (%s))
AND (account_account.type IN %s)
AND (COALESCE(date_maturity,date) > %s)
AND (partner_id =ANY (%s))
AND (partner_id IN %s)
AND ((reconcile_id IS NULL)
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
AND (account_account.company_id = %s)
AND account_account.active
GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form['date1'], partner_ids, form['date1'], form['company_id'],))
GROUP BY partner_id""" , (tuple(self.ACCOUNT_TYPE), form['date1'], tuple(partner_ids), form['date1'], form['company_id'],))
t = self.cr.fetchall()
for i in t:
future_past[i[0]] = i[1]
@ -131,14 +131,14 @@ class aged_trial_report(rml_parse.rml_parse):
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
FROM account_move_line AS line, account_account
WHERE (line.account_id=account_account.id)
AND (account_account.type =ANY (%s))
AND (account_account.type IN %s)
AND (COALESCE(date_maturity,date) BETWEEN %s AND %s)
AND (partner_id =ANY (%s))
AND (partner_id IN %s)
AND ((reconcile_id IS NULL)
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
AND (account_account.company_id = %s)
AND account_account.active
GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'],partner_ids ,form['date1'] ,form['company_id'],))
GROUP BY partner_id""" , (tuple(self.ACCOUNT_TYPE), form[str(i)]['start'], form[str(i)]['stop'], tuple(partner_ids) ,form['date1'] ,form['company_id'],))
t = self.cr.fetchall()
d = {}

View File

@ -40,7 +40,7 @@ class journal_print(report_sxw.rml_parse):
ids_final = []
for journal in journal_id:
for period in period_id:
ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)])
ids_journal_period = self.pool.get('account.journal.period').search(self.cr, self.uid, [('journal_id','=',journal),('period_id','=',period)])
if ids_journal_period:
self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%s and l.journal_id=%s and l.state<>\'draft\' group by a.id, a.code, a.name, l.journal_id, l.period_id', (period, journal))
res = self.cr.dictfetchall()

View File

@ -320,7 +320,7 @@ class account_balance(report_sxw.rml_parse):
# return super(account_balance,self).repeatIn(lst, name, nodes_parent=False)
#end
def linesForYear(self,form):
def linesForYear(self, form):
temp=0
years={}
@ -351,7 +351,7 @@ class account_balance(report_sxw.rml_parse):
if perc==1:
if form['select_account']!=False:
ref_ac=self.pool.get('account.account').browse(self.cr, self.uid,form['select_account'],ctx.copy())
ref_ac=self.pool.get('account.account').browse(self.cr, self.uid, form['select_account'], ctx.copy())
if ref_ac.balance<>0.00:
ref_bal=ref_ac.balance
else:
@ -365,7 +365,7 @@ class account_balance(report_sxw.rml_parse):
total_for_perc=[]
# if perc==1:
self.done_total=1
self.total_for_perc=self.linesForTotal(form,ids={},doneAccount={},level=1)
self.total_for_perc=self.linesForTotal(form, ids={}, doneAccount={}, level=1)
self.done_total=0
for t1 in range(0,len(form['fiscalyear'])):
@ -376,13 +376,13 @@ class account_balance(report_sxw.rml_parse):
# self.result_total = {}
for temp in range(0,len(form['fiscalyear'])):
fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp])
fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp])
years["year"+str(temp)]=fy[0][1][12:16]
return [years]
def linesForTotal(self,form,ids={},doneAccount={},level=1):
def linesForTotal(self, form, ids={}, doneAccount={}, level=1):
if self.done_total==1:
self.done_total==1
else:
@ -440,7 +440,7 @@ class account_balance(report_sxw.rml_parse):
ids2 = [(x.code,x.id) for x in entry[0].child_id]
ids2.sort()
result_total_parent = self.linesForTotal(form, [x[1] for x in ids2],doneAccount,level+1)
result_total_parent = self.linesForTotal(form, [x[1] for x in ids2], doneAccount, level+1)
return [self.result_total]
@ -459,7 +459,7 @@ class account_balance(report_sxw.rml_parse):
ctx['periods'] = form['periods']
ctx['period_manner']=form['period_manner']
ctx['state'] = form['context'].get('state','all')
tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy())
tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy())
if len(tmp1):
accounts.append(tmp1)
@ -594,12 +594,12 @@ class account_balance(report_sxw.rml_parse):
return result
def get_years(self,form):
def get_years(self, form):
result =[]
res={}
for temp in range(0,len(form['fiscalyear'])):
res={}
fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp])
fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp])
res['year']=fy[0][1]
res['last_str']=temp
@ -607,7 +607,7 @@ class account_balance(report_sxw.rml_parse):
self.linesForYear(form)
return result
def get_lines(self,year_dict,form):
def get_lines(self, year_dict, form):
final_result = []
line_l =[]
res = {}
@ -639,7 +639,7 @@ class account_balance(report_sxw.rml_parse):
final_result.append(res)
return final_result
def cal_total(self,year_dict):
def cal_total(self, year_dict):
total_l = self.result_total
if total_l:
for k,v in total_l.items():

View File

@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from operator import itemgetter
import pooler
import time
from report import report_sxw
@ -41,10 +41,12 @@ class journal_print(report_sxw.rml_parse):
def set_context(self, objects, data, ids, report_type = None):
super(journal_print, self).set_context(objects, data, ids, report_type)
self.cr.execute('select period_id, journal_id from account_journal_period where id =ANY(%s)',(ids,))
self.cr.execute('SELECT period_id, journal_id '
'FROM account_journal_period '
'WHERE id IN %s',
(tuple(ids),))
res = self.cr.fetchall()
self.period_ids = map(lambda x:x[0],res)
self.journal_ids = map(lambda x:x[1],res)
self.period_ids, self.journal_ids = zip(*res)
# returns a list of period objs
def periods(self, journal_period_objs):
@ -63,7 +65,7 @@ class journal_print(report_sxw.rml_parse):
ids_final = []
for journal in journal_id:
for period in period_id:
ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)])
ids_journal_period = self.pool.get('account.journal.period').search(self.cr, self.uid, [('journal_id','=',journal),('period_id','=',period)])
if ids_journal_period:
ids_final.append(ids_journal_period[0])
data_jour_period = self.pool.get('account.journal.period').browse(self.cr, self.uid, ids_final)
@ -74,7 +76,14 @@ class journal_print(report_sxw.rml_parse):
periods.append(data.period_id.id)
for period in periods:
period_data = self.pool.get('account.period').browse(self.cr, self.uid, period)
self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period,journal_id,))
self.cr.execute(
'SELECT j.code, j.name, '
'SUM(l.debit) AS debit, SUM(l.credit) AS credit '
'FROM account_move_line l '
'LEFT JOIN account_journal j ON (l.journal_id=j.id) '
'WHERE period_id=%s AND journal_id IN %s '
'AND l.state<>\'draft\' '
'GROUP BY j.id, j.code, j.name', (period, tuple(journal_id)))
res = self.cr.dictfetchall()
res[0].update({'period_name':period_data.name})
res[0].update({'pid':period})
@ -82,45 +91,60 @@ class journal_print(report_sxw.rml_parse):
return lines_data
if not self.journal_ids:
return []
self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,self.journal_ids,))
self.cr.execute('SELECT j.code, j.name, '
'SUM(l.debit) AS debit, SUM(l.credit) AS credit '
'FROM account_move_line l '
'LEFT JOIN account_journal j ON (l.journal_id=j.id) '
'WHERE period_id=%s AND journal_id IN %s '
'AND l.state<>\'draft\' '
'GROUP BY j.id, j.code, j.name',
(period_id, tuple(self.journal_ids)))
res = self.cr.dictfetchall()
return res
def _sum_debit_period(self, period_id,journal_id=None):
if type(journal_id)==type([]):
self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,journal_id,))
return self.cr.fetchone()[0] or 0.0
if not self.journal_ids:
def _sum_debit_period(self, period_id, journal_id=None):
journals = journal_id or self.journal_ids
if not journals:
return 0.0
self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,))
self.cr.execute('SELECT SUM(debit) FROM account_move_line '
'WHERE period_id=%s AND journal_id IN %s '
'AND state<>\'draft\'',
(period_id, tuple(journals)))
return self.cr.fetchone()[0] or 0.0
def _sum_credit_period(self, period_id,journal_id=None):
if type(journal_id)==type([]):
self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,journal_id,))
return self.cr.fetchone()[0] or 0.0
if not self.journal_ids:
def _sum_credit_period(self, period_id, journal_id=None):
journals = journal_id or self.journal_ids
if not journals:
return 0.0
self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,))
self.cr.execute('SELECT SUM(credit) FROM account_move_line '
'WHERE period_id=%s AND journal_id IN %s '
'AND state<>\'draft\'',
(period_id, tuple(journals)))
return self.cr.fetchone()[0] or 0.0
def _sum_debit(self,period_id=None,journal_id=None):
if type(period_id)==type([]):
self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,))
return self.cr.fetchone()[0] or 0.0
if not self.journal_ids or not self.period_ids:
def _sum_debit(self, period_id=None, journal_id=None):
journals = journal_id or self.journal_ids
periods = period_id or self.period_ids
if not (journals and periods):
return 0.0
self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,))
self.cr.execute('SELECT SUM(debit) FROM account_move_line '
'WHERE period_id IN %s '
'AND journal_id IN %s '
'AND state<>\'draft\'',
(tuple(periods), tuple(journals)))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self,period_id=None,journal_id=None):
if type(period_id)==type([]):
self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,))
return self.cr.fetchone()[0] or 0.0
if not self.journal_ids or not self.period_ids:
def _sum_credit(self, period_id=None, journal_id=None):
periods = period_id or self.period_ids
journals = journal_id or self.journal_ids
if not (periods and journals):
return 0.0
self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,))
self.cr.execute('SELECT SUM(credit) FROM account_move_line '
'WHERE period_id IN %s '
'AND journal_id IN %s '
'AND state<>\'draft\'',
(tuple(periods), tuple(journals)))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print)
report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml', parser=journal_print, header=False)

View File

@ -70,7 +70,7 @@ class general_ledger(rml_parse.rml_parse):
})
self.context = context
def get_min_date(self,form):
def get_min_date(self, form):
## Get max born from account_fiscal year
#
@ -87,14 +87,15 @@ class general_ledger(rml_parse.rml_parse):
#periods = form['periods'][0][2]
if not periods:
sql = """
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s
"""
sqlargs = (form['fiscalyear'],)
else:
periods_id = ','.join(map(str, periods))
sql = """
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """)
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in %s
"""
self.cr.execute(sql)
sqlargs = (tuple(periods),)
self.cr.execute(sql, sqlargs)
res = self.cr.dictfetchall()
borne_min = res[0]['start_date']
borne_max = res[0]['stop_date']
@ -105,15 +106,22 @@ class general_ledger(rml_parse.rml_parse):
periods = form['periods']
#periods = form['periods'][0][2]
if not periods:
sql = """
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """
"""
sql = """
SELECT MIN(p.date_start) AS start_date,
MAX(p.date_stop) AS stop_date
FROM account_period AS p
WHERE p.fiscalyear_id = %s
"""
sqlargs = (form['fiscalyear'],)
else:
periods_id = ','.join(map(str, periods))
sql = """
Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """)
SELECT MIN(p.date_start) AS start_date,
MAX(p.date_stop) AS stop_date
FROM account_period AS p
WHERE p.id IN %s
"""
self.cr.execute(sql)
sqlargs = (tuple(periods),)
self.cr.execute(sql, sqlargs)
res = self.cr.dictfetchall()
period_min = res[0]['start_date']
period_max = res[0]['stop_date']
@ -150,7 +158,7 @@ class general_ledger(rml_parse.rml_parse):
## We will make the test for period or date
## We will now make the test
#
ctx['state'] = form['context'].get('state','all')
ctx['state'] = form['context'].get('state', 'all')
if form.has_key('fiscalyear'):
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods']
@ -165,10 +173,10 @@ class general_ledger(rml_parse.rml_parse):
if account and account.child_consol_ids: # add ids of consolidated childs also of selected account
ctx['consolidate_childs'] = True
ctx['account_id'] = account.id
ids_acc = self.pool.get('account.account').search(self.cr, self.uid,[('parent_id', 'child_of', [account.id])], context=ctx)
ids_acc = self.pool.get('account.account').search(self.cr, self.uid, [('parent_id', 'child_of', [account.id])], context=ctx)
for child_id in ids_acc:
child_account = self.pool.get('account.account').browse(self.cr, self.uid, child_id)
sold_account = self._sum_solde_account(child_account,form)
sold_account = self._sum_solde_account(child_account, form)
self.sold_accounts[child_account.id] = sold_account
if form['display_account'] == 'bal_mouvement':
if child_account.type != 'view' \
@ -196,8 +204,12 @@ class general_ledger(rml_parse.rml_parse):
else:
## We will now compute solde initiaux
for move in res:
SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'"
self.cr.execute(SOLDEINIT)
SOLDEINIT = "SELECT SUM(l.debit) AS sum_debit,"\
" SUM(l.credit) AS sum_credit "\
"FROM account_move_line l "\
"WHERE l.account_id = %s "\
"AND l.date < %s AND l.date > %s"
self.cr.execute(SOLDEINIT, (move.id, self.borne_date['max_date'], self.borne_date['min_date']))
resultat = self.cr.dictfetchall()
if resultat[0] :
if resultat[0]['sum_debit'] == None:
@ -263,7 +275,7 @@ class general_ledger(rml_parse.rml_parse):
for l in res:
l['move']=l['move_name']
if l['invoice_id']:
l['ref'] = '%s: %s'%(inv_types[l['invoice_type']],l['invoice_number'])
l['ref'] = '%s: %s'%(inv_types[l['invoice_type']], l['invoice_number'])
l['partner'] = l['partner_name'] or ''
account_sum = l['debit'] - l ['credit']
#c = time.strptime(l['date'],"%Y-%m-%d")
@ -296,7 +308,7 @@ class general_ledger(rml_parse.rml_parse):
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id,self.query))
"WHERE l.account_id = %s AND %s "%(account.id, self.query))
## Add solde init to the result
#
sum_credit = self.cr.fetchone()[0] or 0.0
@ -310,7 +322,7 @@ class general_ledger(rml_parse.rml_parse):
def _sum_solde_account(self, account, form):
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s"%(account.id,self.query))
"WHERE l.account_id = %s AND %s"%(account.id, self.query))
sum_solde = self.cr.fetchone()[0] or 0.0
if form.get('soldeinit', False):
sum_solde += account.init_debit - account.init_credit
@ -322,7 +334,8 @@ class general_ledger(rml_parse.rml_parse):
return 0.0
self.cr.execute("SELECT sum(debit) "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
"WHERE l.account_id IN %s AND "+self.query,
(tuple(self.child_ids),))
sum_debit = self.cr.fetchone()[0] or 0.0
return sum_debit
@ -331,7 +344,8 @@ class general_ledger(rml_parse.rml_parse):
return 0.0
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
"WHERE l.account_id IN %s AND "+self.query,
(tuple(self.child_ids),))
## Add solde init to the result
#
sum_credit = self.cr.fetchone()[0] or 0.0
@ -342,7 +356,8 @@ class general_ledger(rml_parse.rml_parse):
return 0.0
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
"FROM account_move_line l "\
"WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query)
"WHERE l.account_id IN %s AND "+self.query,
(tuple(self.child_ids),))
sum_solde = self.cr.fetchone()[0] or 0.0
return sum_solde

View File

@ -51,7 +51,7 @@ class Overdue(report_sxw.rml_parse):
'country_id' : False,
}
if adr_id:
result = res_partner_address.read(self.cr, self.uid, [adr_id],context=self.context.copy())
result = res_partner_address.read(self.cr, self.uid, [adr_id], context=self.context.copy())
result[0]['country_id'] = result[0]['country_id'] and result[0]['country_id'][1] or False
return result

View File

@ -29,7 +29,6 @@ class partner_balance(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(partner_balance, self).__init__(cr, uid, name, context=context)
self.date_lst = []
self.date_lst_string = ''
self.account_ids = ''
self.localcontext.update( {
'time': time,
@ -49,7 +48,7 @@ class partner_balance(report_sxw.rml_parse):
#
# Date Management
#
def date_range(self,start,end):
def date_range(self, start, end):
if not start or not end:
return []
start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d")))
@ -63,7 +62,7 @@ class partner_balance(report_sxw.rml_parse):
full_str_date.append(str(date))
return full_str_date
def transform_period_into_date_array(self,data):
def transform_period_into_date_array(self, data):
## Get All Period Date
#
# If we have no period we will take all perdio in the FiscalYear.
@ -74,17 +73,17 @@ class partner_balance(report_sxw.rml_parse):
date_array = []
for period_id in periods_id:
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop)
self.date_lst = date_array
self.date_lst.sort()
def transform_date_into_date_array(self,data):
return_array = self.date_range(data['form']['date1'],data['form']['date2'])
def transform_date_into_date_array(self, data):
return_array = self.date_range(data['form']['date1'], data['form']['date2'])
self.date_lst = return_array
self.date_lst.sort()
def transform_both_into_date_array(self,data):
def transform_both_into_date_array(self, data):
final_date_array = []
date_start_date = data['form']['date1']
date_stop_date = data['form']['date2']
@ -96,7 +95,7 @@ class partner_balance(report_sxw.rml_parse):
if periods_id:
for period_id in periods_id:
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop)
period_start_date = date_array[0]
period_stop_date = date_array[-1]
@ -110,15 +109,15 @@ class partner_balance(report_sxw.rml_parse):
else :
stop_date = date_stop_date
final_date_array = final_date_array + self.date_range(start_date,stop_date)
final_date_array = final_date_array + self.date_range(start_date, stop_date)
self.date_lst = final_date_array
self.date_lst.sort()
else :
final_date_array = final_date_array + self.date_range(date_start_date,date_stop_date)
final_date_array = final_date_array + self.date_range(date_start_date, date_stop_date)
self.date_lst = final_date_array
self.date_lst.sort()
def transform_none_into_date_array(self,data):
def transform_none_into_date_array(self, data):
sql = "SELECT min(date) as start_date from account_move_line"
self.cr.execute(sql)
@ -130,12 +129,12 @@ class partner_balance(report_sxw.rml_parse):
array = []
array = array + self.date_range(start_date,stop_date)
array = array + self.date_range(start_date, stop_date)
self.date_lst = array
self.date_lst.sort()
def comma_me(self,amount):
def comma_me(self, amount):
if type(amount) is float :
amount = str('%.2f'%amount)
else :
@ -166,28 +165,24 @@ class partner_balance(report_sxw.rml_parse):
self.transform_both_into_date_array(data)
##
self.date_lst_string =''
if self.date_lst:
self.date_lst_string = '\'' + '\',\''.join(map(str, self.date_lst)) + '\''
## Compute Code
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
#
if (data['form']['result_selection'] == 'customer' ):
self.ACCOUNT_TYPE = ['receivable']
self.ACCOUNT_TYPE = ('receivable',)
elif (data['form']['result_selection'] == 'supplier'):
self.ACCOUNT_TYPE = ['payable']
self.ACCOUNT_TYPE = ('payable',)
else:
self.ACCOUNT_TYPE = ['payable','receivable']
self.ACCOUNT_TYPE = ('payable','receivable')
#
self.cr.execute("SELECT a.id " \
"FROM account_account a " \
"LEFT JOIN account_account_type t " \
"ON (a.type = t.code) " \
"WHERE a.company_id = %s " \
"AND a.type =ANY(%s) "\
"AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE,))
"AND a.type IN %s " \
"AND a.active", (data['form']['company_id'], self.ACCOUNT_TYPE))
self.account_ids = [a for (a,) in self.cr.fetchall()]
super(partner_balance, self).set_context(objects, data, ids, report_type)
@ -197,7 +192,7 @@ class partner_balance(report_sxw.rml_parse):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
full_account = []
result_tmp = 0.0
if self.date_lst_string:
if self.date_lst:
self.cr.execute(
"SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \
"CASE WHEN sum(debit) > sum(credit) " \
@ -211,16 +206,17 @@ class partner_balance(report_sxw.rml_parse):
"(SELECT sum(debit-credit) " \
"FROM account_move_line l " \
"WHERE partner_id = p.id " \
"AND l.date IN (" + self.date_lst_string + ") " \
"AND l.date IN %s " \
"AND blocked = TRUE " \
") AS enlitige " \
"FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
"JOIN account_account ac ON (l.account_id = ac.id)" \
"WHERE ac.type =ANY(%s) "
"AND l.date IN (" + self.date_lst_string + ") " \
"AND ac.company_id = %s" \
"WHERE ac.type IN %s " \
"AND l.date IN %s " \
"AND ac.company_id = %s " \
"GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \
"ORDER BY l.account_id,p.name",(self.ACCOUNT_TYPE,data['form']['company_id'],))
"ORDER BY l.account_id,p.name",
(tuple(self.date_lst), self.ACCOUNT_TYPE, tuple(self.date_lst), data['form']['company_id']))
res = self.cr.dictfetchall()
for r in res:
full_account.append(r)
@ -228,7 +224,7 @@ class partner_balance(report_sxw.rml_parse):
## We will now compute Total
return self._add_subtotal(full_account)
def _add_subtotal(self,cleanarray):
def _add_subtotal(self, cleanarray):
i=0
completearray = []
tot_debit = 0.0
@ -347,75 +343,79 @@ class partner_balance(report_sxw.rml_parse):
return completearray
def _sum_debit(self,data):
def _sum_debit(self, data):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
temp_res = 0.0
if self.date_lst_string:
if self.date_lst:
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line AS l " \
"WHERE l.account_id =ANY(%s)" \
"AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,))
"WHERE l.account_id IN %s" \
"AND l.date IN %s",
(tuple(self.account_ids), tuple(self.date_lst)))
temp_res = float(self.cr.fetchone()[0] or 0.0)
result_tmp = result_tmp + temp_res
return result_tmp
def _sum_credit(self,data):
def _sum_credit(self, data):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
temp_res = 0.0
if self.date_lst_string:
if self.date_lst:
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line AS l " \
"WHERE l.account_id =ANY(%s)" \
"AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,))
"WHERE l.account_id IN %s" \
"AND l.date IN %s",
(tuple(self.account_ids), tuple(self.date_lst),))
temp_res = float(self.cr.fetchone()[0] or 0.0)
result_tmp = result_tmp + temp_res
return result_tmp
def _sum_litige(self,data):
def _sum_litige(self, data):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
temp_res = 0.0
if self.date_lst_string:
if self.date_lst:
self.cr.execute(
"SELECT sum(debit-credit) " \
"FROM account_move_line AS l " \
"WHERE l.account_id =ANY(%s)" \
"AND l.date IN (" + self.date_lst_string + ")"\
"AND l.blocked=TRUE " ,(self.account_ids,))
"WHERE l.account_id IN %s" \
"AND l.date IN %s " \
"AND l.blocked=TRUE ",
(tuple(self.account_ids), tuple(self.date_lst),))
temp_res = float(self.cr.fetchone()[0] or 0.0)
result_tmp = result_tmp + temp_res
return result_tmp
def _sum_sdebit(self,data):
def _sum_sdebit(self, data):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
a = 0.0
if self.date_lst_string:
if self.date_lst:
self.cr.execute(
"SELECT CASE WHEN sum(debit) > sum(credit) " \
"THEN sum(debit) - sum(credit) " \
"ELSE 0 " \
"END " \
"FROM account_move_line AS l " \
"WHERE l.account_id =ANY(%s)" \
"AND l.date IN (" + self.date_lst_string + ")" \
"GROUP BY l.partner_id",(self.account_ids,))
"WHERE l.account_id IN %s" \
"AND l.date IN %s " \
"GROUP BY l.partner_id",
(tuple(self.account_ids), tuple(self.date_lst),))
a = self.cr.fetchone()[0]
if self.cr.fetchone() != None:
@ -425,7 +425,7 @@ class partner_balance(report_sxw.rml_parse):
return result_tmp
def _sum_scredit(self,data):
def _sum_scredit(self, data):
if not self.ids:
return 0.0
@ -433,16 +433,17 @@ class partner_balance(report_sxw.rml_parse):
result_tmp = 0.0
a = 0.0
if self.date_lst_string:
if self.date_lst:
self.cr.execute(
"SELECT CASE WHEN sum(debit) < sum(credit) " \
"THEN sum(credit) - sum(debit) " \
"ELSE 0 " \
"END " \
"FROM account_move_line AS l " \
"WHERE l.account_id =ANY(%s)" \
"AND l.date IN (" + self.date_lst_string + ")" \
"GROUP BY l.partner_id",(self.account_ids,))
"WHERE l.account_id IN %s" \
"AND l.date IN %s " \
"GROUP BY l.partner_id",
(tuple(self.account_ids), tuple(self.date_lst),))
a = self.cr.fetchone()[0] or 0.0
if self.cr.fetchone() != None:
@ -453,11 +454,11 @@ class partner_balance(report_sxw.rml_parse):
return result_tmp
def _solde_balance_debit(self,data):
def _solde_balance_debit(self, data):
debit, credit = self._sum_debit(data), self._sum_credit(data)
return debit > credit and debit - credit
def _solde_balance_credit(self,data):
def _solde_balance_credit(self, data):
debit, credit = self._sum_debit(data), self._sum_credit(data)
return credit > debit and credit - debit

View File

@ -28,7 +28,6 @@ from report import report_sxw
class tax_report(rml_parse.rml_parse):
_name = 'report.account.vat.declaration'
def __init__(self, cr, uid, name, context={}):
print "tax______init", name, context
super(tax_report, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
@ -86,9 +85,10 @@ class tax_report(rml_parse.rml_parse):
def _get_period(self, period_id, context={}):
return self.pool.get('account.period').browse(self.cr, self.uid, period_id, context=context).name
def _get_general(self, tax_code_id,period_list ,company_id, based_on, context={}):
def _get_general(self, tax_code_id, period_list ,company_id, based_on, context={}):
res=[]
obj_account = self.pool.get('account.account')
periods_ids = tuple(period_list)
if based_on == 'payments':
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
SUM(line.debit) AS debit, \
@ -107,11 +107,11 @@ class tax_report(rml_parse.rml_parse):
AND line.account_id = account.id \
AND account.company_id = %s \
AND move.id = line.move_id \
AND line.period_id =ANY(%s) \
AND line.period_id IN %s \
AND ((invoice.state = %s) \
OR (invoice.id IS NULL)) \
GROUP BY account.id,account.name,account.code', ('draft', tax_code_id,
company_id, period_list, 'paid',))
company_id, periods_ids, 'paid',))
else :
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
@ -127,10 +127,10 @@ class tax_report(rml_parse.rml_parse):
AND line.tax_code_id = %s \
AND line.account_id = account.id \
AND account.company_id = %s \
AND line.period_id =ANY(%s)\
AND line.period_id IN %s\
AND account.active \
GROUP BY account.id,account.name,account.code', ('draft', tax_code_id,
company_id, period_list,))
company_id, periods_ids,))
res = self.cr.dictfetchall()
#AND line.period_id IN ('+ period_sql_list +') \

View File

@ -42,7 +42,7 @@ class third_party_ledger(rml_parse.rml_parse):
'get_currency': self._get_currency,
'comma_me' : self.comma_me,
})
def date_range(self,start,end):
def date_range(self, start, end):
if not start or not end:
return []
start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d")))
@ -57,7 +57,7 @@ class third_party_ledger(rml_parse.rml_parse):
return full_str_date
#
def transform_period_into_date_array(self,data):
def transform_period_into_date_array(self, data):
## Get All Period Date
if not data['form']['periods']:
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
@ -66,12 +66,12 @@ class third_party_ledger(rml_parse.rml_parse):
date_array = []
for period_id in periods_id:
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop)
self.date_lst = date_array
self.date_lst.sort()
def transform_date_into_date_array(self,data):
return_array = self.date_range(data['form']['date1'],data['form']['date2'])
return_array = self.date_range(data['form']['date1'], data['form']['date2'])
self.date_lst = return_array
self.date_lst.sort()
@ -84,7 +84,7 @@ class third_party_ledger(rml_parse.rml_parse):
date_array = []
for period_id in periods_id:
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop)
period_start_date = date_array[0]
date_start_date = data['form']['date1']
@ -105,7 +105,7 @@ class third_party_ledger(rml_parse.rml_parse):
self.date_lst = final_date_array
self.date_lst.sort()
def transform_none_into_date_array(self,data):
def transform_none_into_date_array(self, data):
sql = "SELECT min(date) as start_date from account_move_line"
self.cr.execute(sql)
start_date = self.cr.fetchone()[0]
@ -118,7 +118,7 @@ class third_party_ledger(rml_parse.rml_parse):
self.date_lst.sort()
def comma_me(self,amount):
def comma_me(self, amount):
if type(amount) is float :
amount = str('%.2f'%amount)
else :
@ -143,7 +143,7 @@ class third_party_ledger(rml_parse.rml_parse):
## Si on imprime depuis les partenaires
if ids:
#PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")"
PARTNER_REQUEST = "AND line.partner_id =ANY(%s)" %ids
PARTNER_REQUEST = "AND line.partner_id IN %s",(tuple(ids),)
# Transformation des date
#
#
@ -179,8 +179,8 @@ class third_party_ledger(rml_parse.rml_parse):
"LEFT JOIN account_account_type t " \
"ON (a.type=t.code) " \
"WHERE a.company_id = %s " \
'AND a.type =ANY(%s)' \
"AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE,))
'AND a.type IN %s' \
"AND a.active", (data['form']['company_id'],tuple(self.ACCOUNT_TYPE)))
self.account_ids = [a for (a,) in self.cr.fetchall()]
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
@ -196,11 +196,11 @@ class third_party_ledger(rml_parse.rml_parse):
"AND line.date >= %s " \
"AND line.date <= %s " \
"AND line.reconcile_id IS NULL " \
"AND line.account_id =ANY(%s)" \
"AND line.account_id IN %s" \
" " + PARTNER_REQUEST + " " \
"AND account.company_id = %s " \
"AND account.active " ,
(self.date_lst[0],self.date_lst[len(self.date_lst)-1],self.account_ids,data['form']['company_id'],))
(self.date_lst[0],self.date_lst[len(self.date_lst)-1],tuple(self.account_ids),data['form']['company_id'],))
# else:
#
# self.cr.execute(
@ -261,11 +261,11 @@ class third_party_ledger(rml_parse.rml_parse):
"LEFT JOIN account_journal j " \
"ON (l.journal_id = j.id) " \
"WHERE l.partner_id = %s " \
"AND l.account_id =ANY(%s)"\
"AND l.account_id IN %s"\
"AND l.date IN (" + self.date_lst_string + ")"
" " + RECONCILE_TAG + " "\
"ORDER BY l.id",
(partner.id,self.account_ids,))
(partner.id, tuple(self.account_ids),))
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
@ -275,7 +275,7 @@ class third_party_ledger(rml_parse.rml_parse):
return full_account
def _sum_debit_partner(self, partner,data):
def _sum_debit_partner(self, partner, data):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
@ -288,10 +288,10 @@ class third_party_ledger(rml_parse.rml_parse):
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id = %s " \
"AND account_id =ANY(%s)" \
"AND account_id IN %s" \
"AND reconcile_id IS NULL " \
"AND date < %s " ,
(partner.id, self.account_ids,self.date_lst[0],))
(partner.id, tuple(self.account_ids), self.date_lst[0],))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
@ -303,10 +303,10 @@ class third_party_ledger(rml_parse.rml_parse):
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id = %s " \
"AND account_id =ANY(%s)" \
"AND account_id IN %s" \
" " + RECONCILE_TAG + " " \
"AND date IN (" + self.date_lst_string + ")" ,
(partner.id,self.account_ids,))
(partner.id,tuple(self.account_ids),))
contemp = self.cr.fetchone()
if contemp != None:
@ -315,7 +315,7 @@ class third_party_ledger(rml_parse.rml_parse):
result_tmp = result_tmp + 0.0
return result_tmp
def _sum_credit_partner(self, partner,data):
def _sum_credit_partner(self, partner, data):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
if data['form']['reconcil'] :
@ -327,10 +327,10 @@ class third_party_ledger(rml_parse.rml_parse):
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id=%s " \
"AND account_id =ANY(%s)" \
"AND account_id IN %s" \
"AND reconcile_id IS NULL " \
"AND date < %s " ,
(partner.id,self.account_ids,self.date_lst[0],))
(partner.id, tuple(self.account_ids), self.date_lst[0],))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
@ -342,10 +342,10 @@ class third_party_ledger(rml_parse.rml_parse):
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id=%s " \
"AND account_id =ANY(%s)" \
"AND account_id IN %s" \
" " + RECONCILE_TAG + " " \
"AND date IN (" + self.date_lst_string + ")",
(partner.id,self.account_ids,))
(partner.id, tuple(self.account_ids),))
contemp = self.cr.fetchone()
if contemp != None:
@ -354,7 +354,7 @@ class third_party_ledger(rml_parse.rml_parse):
result_tmp = result_tmp + 0.0
return result_tmp
def _sum_debit(self,data):
def _sum_debit(self, data):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
@ -367,11 +367,11 @@ class third_party_ledger(rml_parse.rml_parse):
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id =ANY(%s)" \
"AND account_id =ANY(%s)" \
"WHERE partner_id IN %s" \
"AND account_id IN %s" \
"AND reconcile_id IS NULL " \
"AND date < %s " ,
(self.partner_ids,self.account_ids,self.date_lst[0],))
(tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
@ -382,10 +382,10 @@ class third_party_ledger(rml_parse.rml_parse):
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id =ANY(%s)" \
"AND account_id =ANY(%s)" \
"WHERE partner_id IN %s" \
"AND account_id IN %s" \
" " + RECONCILE_TAG + " " \
"AND date IN (" + self.date_lst_string + ")",(self.partner_ids,self.account_ids,))
"AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
@ -395,7 +395,7 @@ class third_party_ledger(rml_parse.rml_parse):
return result_tmp
def _sum_credit(self,data):
def _sum_credit(self, data):
if not self.ids:
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
@ -408,11 +408,11 @@ class third_party_ledger(rml_parse.rml_parse):
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id =ANY(%s)" \
"AND account_id =ANY(%s)" \
"WHERE partner_id IN %s" \
"AND account_id IN %s" \
"AND reconcile_id IS NULL " \
"AND date < %s " ,
(self.partner_ids,self.account_ids,self.date_lst[0],))
(tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0
@ -423,10 +423,10 @@ class third_party_ledger(rml_parse.rml_parse):
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id =ANY(%s)" \
"AND account_id =ANY(%s)" \
"WHERE partner_id IN %s" \
"AND account_id IN %s" \
" " + RECONCILE_TAG + " " \
"AND date IN (" + self.date_lst_string + ")",(self.partner_ids,self.account_ids,))
"AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),))
contemp = self.cr.fetchone()
if contemp != None:
result_tmp = contemp[0] or 0.0

View File

@ -36,10 +36,10 @@ class report_voucher_move(report_sxw.rml_parse):
})
self.user=uid
def convert(self,amount):
user_id = self.pool.get('res.users').browse(self.cr, self.user,[self.user])[0]
def convert(self, amount):
user_id = self.pool.get('res.users').browse(self.cr, self.user, [self.user])[0]
cur = user_id.company_id.currency_id.name
amt_en = amount_to_text_en.amount_to_text(amount,'en',cur);
amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur);
return amt_en
def debit(self, move_ids):

View File

@ -117,7 +117,7 @@ class account_balance_report(osv.osv_memory):
context = {}
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
cr.execute(sql,(data['form']['date_from'],))
cr.execute(sql, (data['form']['date_from'],))
res = cr.dictfetchall()
if res:

View File

@ -53,12 +53,12 @@ class account_chart(osv.osv_memory):
act_obj = self.pool.get('ir.actions.act_window')
data = self.read(cr, uid, ids, [], context=context)[0]
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'],context=context)[0]['res_id']
id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id']
result = act_obj.read(cr, uid, [id], context=context)[0]
result['context'] = str({'fiscalyear': data['fiscalyear'], \
'state': data['target_move']})
if data['fiscalyear']:
result['name'] += ':' + self.pool.get('account.fiscalyear').read(cr, uid, [data['fiscalyear']],context=context)[0]['code']
result['name'] += ':' + self.pool.get('account.fiscalyear').read(cr, uid, [data['fiscalyear']], context=context)[0]['code']
return result
_defaults = {

View File

@ -160,10 +160,10 @@ class account_fiscalyear_close(osv.osv_memory):
'WHERE b.account_id = %s ' \
'AND b.reconcile_id is NOT NULL ' \
'AND a.reconcile_id = b.reconcile_id ' \
'AND b.period_id =ANY(%s)'\
'AND a.period_id =ANY(%s)' \
'AND b.period_id IN %s'\
'AND a.period_id IN %s' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id,period_ids,periods_fy2,limit, offset))
'LIMIT %s OFFSET %s', (account.id,tuple(period_ids),tuple(periods_fy2),limit, offset))
result = cr.dictfetchall()
if not result:
break

View File

@ -43,7 +43,7 @@ class account_fiscalyear_close_state(osv.osv_memory):
@param ids: List of Account fiscalyear close states IDs
"""
for data in self.read(cr, uid, ids,context=context):
for data in self.read(cr, uid, ids, context=context):
if not data['sure']:
raise osv.except_osv(_('UserError'), _('Closing of states \
cancelled, please check the box !'))

View File

@ -96,7 +96,7 @@ class account_general_ledger_report(osv.osv_memory):
context = {}
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
cr.execute(sql,(data['form']['date_from'],))
cr.execute(sql, (data['form']['date_from'],))
res = cr.dictfetchall()
if res:
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):

View File

@ -61,7 +61,7 @@ class account_invoice_refund(osv.osv_memory):
date = False
period = False
description = False
for inv in inv_obj.browse(cr, uid, context['active_ids'],context=context):
for inv in inv_obj.browse(cr, uid, context['active_ids'], context=context):
if inv.state in ['draft', 'proforma2', 'cancel']:
raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
if form['period'] :
@ -81,7 +81,7 @@ class account_invoice_refund(osv.osv_memory):
from account_period where date(%s)
between date_start AND date_stop \
and company_id = %s limit 1 """,
(date, self.pool.get('res.users').browse(cr, uid, uid,context=context).company_id.id,))
(date, self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id,))
else:
cr.execute("""SELECT id
from account_period where date(%s)
@ -102,7 +102,7 @@ class account_invoice_refund(osv.osv_memory):
_('No Period found on Invoice!'))
refund_id = inv_obj.refund(cr, uid, [inv.id], date, period, description)
refund = inv_obj.browse(cr, uid, refund_id[0],context=context)
refund = inv_obj.browse(cr, uid, refund_id[0], context=context)
inv_obj.write(cr, uid, [refund.id], {'date_due': date,
'check_total': inv.check_total})
inv_obj.button_compute(cr, uid, refund_id)
@ -118,7 +118,7 @@ class account_invoice_refund(osv.osv_memory):
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)
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 :
to_reconcile_ids[tmpline.account_id.id].append(tmpline.id)
@ -136,13 +136,13 @@ class account_invoice_refund(osv.osv_memory):
'partner_insite', 'partner_contact',
'partner_ref', 'payment_term', 'account_id',
'currency_id', 'invoice_line', 'tax_line',
'journal_id', 'period_id'],context=context)
'journal_id', 'period_id'], context=context)
invoice = invoice[0]
del invoice['id']
invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'],context=context)
invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'], context=context)
invoice_lines = inv_obj._refund_cleanup_lines(cr, uid, invoice_lines)
tax_lines = self.pool.get('account.invoice.tax').read(
cr, uid, invoice['tax_line'],context=context)
cr, uid, invoice['tax_line'], context=context)
tax_lines = inv_obj._refund_cleanup_lines(cr, uid, tax_lines)
invoice.update({
@ -176,8 +176,8 @@ class account_invoice_refund(osv.osv_memory):
else:
xml_id = 'action_invoice_tree4'
result = mod_obj._get_id(cr, uid, 'account', xml_id)
id = mod_obj.read(cr, uid, result, ['res_id'],context=context)['res_id']
result = act_obj.read(cr, uid, id,context=context)
id = mod_obj.read(cr, uid, result, ['res_id'], context=context)['res_id']
result = act_obj.read(cr, uid, id, context=context)
result['res_id'] = created_inv
return result

View File

@ -40,7 +40,7 @@ class account_move_bank_reconcile(osv.osv_memory):
@param ids: account move bank reconciles ID or list of IDs
@return: dictionary of Open account move line on given journal_id.
"""
data = self.read(cr, uid, ids,context=context)[0]
data = self.read(cr, uid, ids, context=context)[0]
cr.execute('select default_credit_account_id \
from account_journal where id=%s', (data['journal_id'],))
account_id = cr.fetchone()[0]

View File

@ -35,18 +35,9 @@ class account_open_closed_fiscalyear(osv.osv_memory):
if not data_fyear.end_journal_period_id:
raise osv.except_osv(_('Error'), _('No journal for ending writing has been defined for the fiscal year'))
period_journal = data_fyear.end_journal_period_id
ids_move = self.pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
ids_move = self.pool.get('account.move').search(cr, uid, [('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
if ids_move:
cr.execute('delete from account_move where id =ANY(%s)',(ids_move,))
#cr.execute('UPDATE account_journal_period ' \
# 'SET state = %s ' \
# 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
# ('draft',data_fyear))
#cr.execute('UPDATE account_period SET state = %s ' \
# 'WHERE fiscalyear_id = %s', ('draft',data_fyear))
#cr.execute('UPDATE account_fiscalyear ' \
# 'SET state = %s, end_journal_period_id = null '\
# 'WHERE id = %s', ('draft',data_fyear))
cr.execute('delete from account_move where id IN %s', (tuple(ids_move),))
return {}
account_open_closed_fiscalyear()

View File

@ -72,7 +72,6 @@ class account_partner_balance(osv.osv_memory):
'model': 'res.partner',
'form': self.read(cr, uid, ids, [])[0],
}
if data['form']['state'] == 'bydate' :
return self._check_date(cr, uid, data, context)
if data['form']['state'] == 'byperiod':
@ -89,7 +88,7 @@ class account_partner_balance(osv.osv_memory):
def _check_date(self, cr, uid, data, context):
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
cr.execute(sql,(data['form']['date1'],))
cr.execute(sql, (data['form']['date1'],))
res = cr.dictfetchall()
if res:
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):

View File

@ -142,7 +142,7 @@ class account_invoice_pay(osv.osv_memory):
cur_obj = self.pool.get('res.currency')
if context is None:
context = {}
data = self.read(cr, uid, ids,context=context)[0]
data = self.read(cr, uid, ids, context=context)[0]
writeoff_account_id = False
writeoff_journal_id = False
comment = False

View File

@ -45,9 +45,9 @@ class account_move_line_reconcile(osv.osv_memory):
_description = 'Account move line reconcile'
_columns = {
'trans_nbr': fields.integer('# of Transaction', readonly=True),
'credit': fields.float('Credit amount',readonly=True),
'debit': fields.float('Debit amount',readonly=True),
'writeoff': fields.float('Write-Off amount',readonly=True),
'credit': fields.float('Credit amount', readonly=True),
'debit': fields.float('Debit amount', readonly=True),
'writeoff': fields.float('Write-Off amount', readonly=True),
}
def default_get(self, cr, uid, fields, context=None):

View File

@ -41,7 +41,7 @@ class account_statement_from_invoice_lines(osv.osv_memory):
currency_obj = self.pool.get('res.currency')
statement_reconcile_obj = self.pool.get('account.bank.statement.reconcile')
data = self.read(cr, uid, ids,context=context)[0]
data = self.read(cr, uid, ids, context=context)[0]
line_ids = data['line_ids']
line_date = time.strftime('%Y-%m-%d')
@ -98,8 +98,8 @@ class account_statement_from_invoice(osv.osv_memory):
_description = "Entries by Statement from Invoices"
_columns = {
'date': fields.date('Date payment',required=True),
'journal_ids': fields.many2many('account.journal','account_journal_relation','account_id','journal_id','Journal'),
'line_ids': fields.many2many('account.move.line','account_move_line_relation','move_id','line_id','Invoices'),
'journal_ids': fields.many2many('account.journal', 'account_journal_relation', 'account_id', 'journal_id', 'Journal'),
'line_ids': fields.many2many('account.move.line', 'account_move_line_relation', 'move_id', 'line_id', 'Invoices'),
}
_defaults = {
'date':lambda *a: time.strftime('%Y-%m-%d'),
@ -113,7 +113,7 @@ class account_statement_from_invoice(osv.osv_memory):
mod_obj = self.pool.get('ir.model.data')
statement_id = 'statement_id' in context and context['statement_id']
data = self.read(cr, uid, ids,context=context)[0]
data = self.read(cr, uid, ids, context=context)[0]
statement = statement_obj.browse(cr, uid, statement_id, context=context)
args_move_line = []
repeated_move_line_ids = []
@ -126,7 +126,7 @@ class account_statement_from_invoice(osv.osv_memory):
args_move_line.append(('partner_id','=',st_line.partner_id.id))
args_move_line.append(('account_id','=',st_line.account_id.id))
move_line_id = line_obj.search(cr, uid, args_move_line,context=context)
move_line_id = line_obj.search(cr, uid, args_move_line, context=context)
if move_line_id:
repeated_move_line_ids += move_line_id

View File

@ -112,7 +112,7 @@ class account_partner_ledger(osv.osv_memory):
context = {}
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
cr.execute(sql,(data['form']['date1'],))
cr.execute(sql, (data['form']['date1'],))
res = cr.dictfetchall()
if res:
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):

View File

@ -29,7 +29,7 @@ class account_use_model(osv.osv_memory):
_name = 'account.use.model'
_description = 'Use model'
_columns = {
'model': fields.many2many('account.model', 'account_use_model_relation','account_id','model_id','Account Model'),
'model': fields.many2many('account.model', 'account_use_model_relation', 'account_id', 'model_id', 'Account Model'),
}
def create_entries(self, cr, uid, ids, context=None):
@ -41,12 +41,12 @@ class account_use_model(osv.osv_memory):
if context is None:
context = {}
data = self.read(cr, uid, ids,context=context)[0]
data = self.read(cr, uid, ids, context=context)[0]
record_id = context and context.get('model_line', False) or False
if record_id:
data_model = account_model_obj.browse(cr,uid,data['model'])
data_model = account_model_obj.browse(cr, uid, data['model'])
else:
data_model = account_model_obj.browse(cr,uid,context['active_ids'])
data_model = account_model_obj.browse(cr, uid, context['active_ids'])
move_ids = []
for model in data_model:
period_id = account_period_obj.find(cr, uid, context=context)

View File

@ -32,31 +32,29 @@ class account_analytic_account(osv.osv):
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
if ids2:
acc_set = ",".join(map(str, ids2))
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \
from account_analytic_line \
join account_analytic_journal \
on account_analytic_line.journal_id = account_analytic_journal.id \
where account_analytic_line.account_id =ANY(%s) \
where account_analytic_line.account_id IN %s \
and account_analytic_journal.type = 'sale' \
group by account_analytic_line.account_id" ,(ids2,))
group by account_analytic_line.account_id" ,(parent_ids,))
for account_id, sum in cr.fetchall():
res[account_id] = round(sum,2)
return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context)
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
res2 = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
if ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
# Amount uninvoiced hours to invoice at sale price
# Warning
# This computation doesn't take care of pricelist !
# Just consider list_price
acc_set = ",".join(map(str, ids2))
cr.execute("""SELECT account_analytic_account.id, \
COALESCE(sum (product_template.list_price * \
account_analytic_line.unit_amount * \
@ -73,11 +71,11 @@ class account_analytic_account(osv.osv):
on account_analytic_account.id = account_analytic_line.account_id \
JOIN hr_timesheet_invoice_factor \
on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \
WHERE account_analytic_account.id =ANY(%s) \
WHERE account_analytic_account.id IN %s \
AND account_analytic_line.invoice_id is null \
AND account_analytic_line.to_invoice IS NOT NULL \
and account_analytic_journal.type in ('purchase','general') \
GROUP BY account_analytic_account.id;""",(ids2,))
GROUP BY account_analytic_account.id;""",(parent_ids,))
for account_id, sum in cr.fetchall():
res[account_id] = round(sum,2)
@ -96,17 +94,17 @@ class account_analytic_account(osv.osv):
def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
if ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \
from account_analytic_line \
join account_analytic_journal \
on account_analytic_line.journal_id = account_analytic_journal.id \
where account_analytic_line.account_id =ANY(%s) \
where account_analytic_line.account_id IN %s \
and account_analytic_journal.type='general' \
and invoice_id is null \
AND to_invoice IS NOT NULL \
GROUP BY account_analytic_line.account_id;",(ids2,))
GROUP BY account_analytic_line.account_id;",(parent_ids,))
for account_id, sum in cr.fetchall():
res[account_id] = round(sum,2)
for obj_id in ids:
@ -121,15 +119,15 @@ class account_analytic_account(osv.osv):
def _hours_quantity_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
if ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \
from account_analytic_line \
join account_analytic_journal \
on account_analytic_line.journal_id = account_analytic_journal.id \
where account_analytic_line.account_id =ANY(%s) \
where account_analytic_line.account_id IN %s \
and account_analytic_journal.type='general' \
GROUP BY account_analytic_line.account_id",(ids2,))
GROUP BY account_analytic_line.account_id",(parent_ids,))
ff = cr.fetchall()
for account_id, sum in ff:
res[account_id] = round(sum,2)
@ -145,30 +143,29 @@ class account_analytic_account(osv.osv):
def _total_cost_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
if ids2:
acc_set = ",".join(map(str, ids2))
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \
from account_analytic_line \
join account_analytic_journal \
on account_analytic_line.journal_id = account_analytic_journal.id \
where account_analytic_line.account_id =ANY(%s) \
where account_analytic_line.account_id IN %s \
and amount<0 \
GROUP BY account_analytic_line.account_id""",(ids2,))
GROUP BY account_analytic_line.account_id""",(parent_ids,))
for account_id, sum in cr.fetchall():
res[account_id] = round(sum,2)
return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context)
# TODO Take care of pricelist and purchase !
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
res2 = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
# Warning
# This computation doesn't take care of pricelist !
# Just consider list_price
if ids2:
if parent_ids:
cr.execute("""select account_analytic_line.account_id as account_id, \
COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \
- (account_analytic_line.unit_amount * pt.list_price \
@ -184,10 +181,10 @@ class account_analytic_account(osv.osv):
on (a.id=account_analytic_line.account_id) \
join hr_timesheet_invoice_factor hr \
on (hr.id=a.to_invoice) \
where account_analytic_line.account_id =ANY(%s) \
where account_analytic_line.account_id IN %s \
and a.to_invoice IS NOT NULL \
and account_analytic_journal.type in ('purchase','general')
GROUP BY account_analytic_line.account_id""",(ids2,))
and account_analytic_journal.type IN ('purchase','general')
GROUP BY account_analytic_line.account_id""",(parent_ids,))
for account_id, sum in cr.fetchall():
res2[account_id] = round(sum,2)
@ -207,13 +204,13 @@ class account_analytic_account(osv.osv):
def _last_worked_date_calc (self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
if ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
cr.execute("select account_analytic_line.account_id, max(date) \
from account_analytic_line \
where account_id =ANY(%s) \
where account_id IN %s \
and invoice_id is null \
GROUP BY account_analytic_line.account_id" ,(ids2,))
GROUP BY account_analytic_line.account_id" ,(parent_ids,))
for account_id, sum in cr.fetchall():
res[account_id] = sum
for obj_id in ids:
@ -228,16 +225,16 @@ class account_analytic_account(osv.osv):
def _last_invoice_date_calc (self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
if ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
cr.execute ("select account_analytic_line.account_id, \
date(max(account_invoice.date_invoice)) \
from account_analytic_line \
join account_invoice \
on account_analytic_line.invoice_id = account_invoice.id \
where account_analytic_line.account_id =ANY(%s) \
where account_analytic_line.account_id IN %s \
and account_analytic_line.invoice_id is not null \
GROUP BY account_analytic_line.account_id",(ids2,))
GROUP BY account_analytic_line.account_id",(parent_ids,))
for account_id, sum in cr.fetchall():
res[account_id] = sum
for obj_id in ids:
@ -252,13 +249,13 @@ class account_analytic_account(osv.osv):
def _last_worked_invoiced_date_calc (self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
if ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
cr.execute("select account_analytic_line.account_id, max(date) \
from account_analytic_line \
where account_id =ANY(%s) \
where account_id IN %s \
and invoice_id is not null \
GROUP BY account_analytic_line.account_id;",(ids2,))
GROUP BY account_analytic_line.account_id;",(parent_ids,))
for account_id, sum in cr.fetchall():
res[account_id] = sum
for obj_id in ids:
@ -346,10 +343,10 @@ class account_analytic_account(osv.osv):
def _month(self, cr, uid, ids, name, arg, context=None):
res = {}
for id in ids:
ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])])
if ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
cr.execute('SELECT DISTINCT(month_id) FROM account_analytic_analysis_summary_month ' \
'WHERE account_id =ANY(%s) AND unit_amount <> 0.0',(ids2,))
'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,))
res[id] = [int(id * 1000000 + int(x[0])) for x in cr.fetchall()]
else:
res[id] = []
@ -360,10 +357,10 @@ class account_analytic_account(osv.osv):
cr.execute('SELECT MAX(id) FROM res_users')
max_user = cr.fetchone()[0]
for id in ids:
ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])])
if ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \
'WHERE account_id =ANY(%s) AND unit_amount <> 0.0',(ids2,))
'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,))
res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()]
else:
res[id] = []
@ -405,12 +402,12 @@ class account_analytic_account_summary_user(osv.osv):
max_user = cr.fetchone()[0]
account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids]
user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids]
account_ids2 = account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)])
if account_ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)]))
if parent_ids:
cr.execute('SELECT id, unit_amount ' \
'FROM account_analytic_analysis_summary_user ' \
'WHERE account_id =ANY(%s) ' \
'AND "user" =ANY(%s)',(account_ids2, user_ids,))
'WHERE account_id IN %s ' \
'AND "user" IN %s',(parent_ids, user_ids,))
for sum_id, unit_amount in cr.fetchall():
res[sum_id] = unit_amount
for obj_id in ids:
@ -488,9 +485,9 @@ class account_analytic_account_summary_user(osv.osv):
for i in range(0, len(ids), cr.IN_MAX):
sub_ids = ids[i:i+cr.IN_MAX]
if d1:
cr.execute('select %s from \"%s\" where id in (%s) ' \
'and account_id in (%s) ' \
'and "user" in (%s) and %s order by %s' % \
cr.execute('select %s from \"%s\" where id IN (%s) ' \
'and account_id IN (%s) ' \
'and "user" IN (%s) and %s order by %s' % \
(','.join(fields_pre2 + ['id']), self._table,
','.join([str(x) for x in sub_ids]),
','.join([str(x/max_user - (x%max_user == 0 and 1 or 0)) for x in sub_ids]),
@ -500,9 +497,9 @@ class account_analytic_account_summary_user(osv.osv):
raise except_orm(_('AccessError'),
_('You try to bypass an access rule (Document type: %s).') % self._description)
else:
cr.execute('select %s from \"%s\" where id in (%s) ' \
'and account_id in (%s) ' \
'and "user" in (%s) order by %s' % \
cr.execute('select %s from \"%s\" where id IN (%s) ' \
'and account_id IN (%s) ' \
'and "user" IN (%s) order by %s' % \
(','.join(fields_pre2 + ['id']), self._table,
','.join([str(x) for x in sub_ids]),
','.join([str(x/max_user - (x%max_user == 0 and 1 or 0)) for x in sub_ids]),
@ -570,12 +567,12 @@ class account_analytic_account_summary_month(osv.osv):
account_obj = self.pool.get('account.analytic.account')
account_ids = [int(str(int(x))[:-6]) for x in ids]
month_ids = [int(str(int(x))[-6:]) for x in ids]
account_ids2 = account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)])
if account_ids2:
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)]))
if parent_ids:
cr.execute('SELECT id, unit_amount ' \
'FROM account_analytic_analysis_summary_month ' \
'WHERE account_id =ANY(%s) ' \
'AND month_id =ANY(%s) ',(account_ids2, month_ids,))
'WHERE account_id IN %s ' \
'AND month_id IN %s ',(parent_ids, month_ids,))
for sum_id, unit_amount in cr.fetchall():
res[sum_id] = unit_amount
for obj_id in ids:
@ -664,9 +661,9 @@ class account_analytic_account_summary_month(osv.osv):
for i in range(0, len(ids), cr.IN_MAX):
sub_ids = ids[i:i+cr.IN_MAX]
if d1:
cr.execute('select %s from \"%s\" where id in (%s) ' \
'and account_id in (%s) ' \
'and month_id in (%s) and %s order by %s' % \
cr.execute('select %s from \"%s\" where id IN (%s) ' \
'and account_id IN (%s) ' \
'and month_id IN (%s) and %s order by %s' % \
(','.join(fields_pre2 + ['id']), self._table,
','.join([str(x) for x in sub_ids]),
','.join([str(x)[:-6] for x in sub_ids]),
@ -676,9 +673,9 @@ class account_analytic_account_summary_month(osv.osv):
raise except_orm(_('AccessError'),
_('You try to bypass an access rule (Document type: %s).') % self._description)
else:
cr.execute('select %s from \"%s\" where id in (%s) ' \
'and account_id in (%s) ' \
'and month_id in (%s) order by %s' % \
cr.execute('select %s from \"%s\" where id IN (%s) ' \
'and account_id IN (%s) ' \
'and month_id IN (%s) order by %s' % \
(','.join(fields_pre2 + ['id']), self._table,
','.join([str(x) for x in sub_ids]),
','.join([str(x)[:-6] for x in sub_ids]),

View File

@ -83,16 +83,16 @@ class account_analytic_plan_instance(osv.osv):
_name='account.analytic.plan.instance'
_description = 'Analytic Plan Instance'
_columns={
'name':fields.char('Analytic Distribution',size=64),
'code':fields.char('Distribution Code',size=16),
'name':fields.char('Analytic Distribution', size=64),
'code':fields.char('Distribution Code', size=16),
'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal' ),
'account_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account Id'),
'account1_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account1 Id'),
'account2_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account2 Id'),
'account3_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account3 Id'),
'account4_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account4 Id'),
'account5_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account5 Id'),
'account6_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account6 Id'),
'account_ids':fields.one2many('account.analytic.plan.instance.line', 'plan_id', 'Account Id'),
'account1_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account1 Id'),
'account2_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account2 Id'),
'account3_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account3 Id'),
'account4_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account4 Id'),
'account5_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account5 Id'),
'account6_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account6 Id'),
'plan_id':fields.many2one('account.analytic.plan', "Model's Plan"),
}
@ -186,21 +186,21 @@ class account_analytic_plan_instance(osv.osv):
def create(self, cr, uid, vals, context=None):
if context and 'journal_id' in context:
journal= self.pool.get('account.journal').browse(cr,uid,context['journal_id'])
journal= self.pool.get('account.journal').browse(cr, uid, context['journal_id'])
pids = self.pool.get('account.analytic.plan.instance').search(cr, uid, [('name','=',vals['name']),('code','=',vals['code']),('plan_id','<>',False)])
if pids:
raise osv.except_osv(_('Error'), _('A model having this name and code already exists !'))
res = self.pool.get('account.analytic.plan.line').search(cr,uid,[('plan_id','=',journal.plan_id.id)])
res = self.pool.get('account.analytic.plan.line').search(cr, uid, [('plan_id','=',journal.plan_id.id)])
for i in res:
total_per_plan = 0
item = self.pool.get('account.analytic.plan.line').browse(cr,uid,i)
item = self.pool.get('account.analytic.plan.line').browse(cr, uid, i)
temp_list=['account1_ids','account2_ids','account3_ids','account4_ids','account5_ids','account6_ids']
for l in temp_list:
if vals.has_key(l):
for tempo in vals[l]:
if self.pool.get('account.analytic.account').search(cr,uid,[('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]):
if self.pool.get('account.analytic.account').search(cr, uid, [('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]):
total_per_plan += tempo[2]['rate']
if total_per_plan < item.min_required or total_per_plan > item.max_required:
raise osv.except_osv(_('Value Error') ,_('The Total Should be Between %s and %s') % (str(item.min_required), str(item.max_required)))
@ -208,13 +208,13 @@ class account_analytic_plan_instance(osv.osv):
return super(account_analytic_plan_instance, self).create(cr, uid, vals, context)
def write(self, cr, uid, ids, vals, context={}, check=True, update_check=True):
this = self.browse(cr,uid,ids[0])
this = self.browse(cr, uid, ids[0])
if this.plan_id and not vals.has_key('plan_id'):
#this instance is a model, so we have to create a new plan instance instead of modifying it
#copy the existing model
temp_id = self.copy(cr, uid, this.id, None, context)
#get the list of the invoice line that were linked to the model
list = self.pool.get('account.invoice.line').search(cr,uid,[('analytics_id','=',this.id)])
list = self.pool.get('account.invoice.line').search(cr, uid, [('analytics_id','=',this.id)])
#make them link to the copy
self.pool.get('account.invoice.line').write(cr, uid, list, {'analytics_id':temp_id}, context)
@ -232,8 +232,8 @@ class account_analytic_plan_instance_line(osv.osv):
_name='account.analytic.plan.instance.line'
_description = 'Analytic Instance Line'
_columns={
'plan_id':fields.many2one('account.analytic.plan.instance','Plan Id'),
'analytic_account_id':fields.many2one('account.analytic.account','Analytic Account', required=True),
'plan_id':fields.many2one('account.analytic.plan.instance', 'Plan Id'),
'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account', required=True),
'rate':fields.float('Rate (%)', required=True),
}
_defaults = {
@ -254,7 +254,7 @@ class account_journal(osv.osv):
_inherit='account.journal'
_name='account.journal'
_columns = {
'plan_id':fields.many2one('account.analytic.plan','Analytic Plans'),
'plan_id':fields.many2one('account.analytic.plan', 'Analytic Plans'),
}
account_journal()
@ -262,7 +262,7 @@ class account_invoice_line(osv.osv):
_inherit='account.invoice.line'
_name='account.invoice.line'
_columns = {
'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Distribution'),
'analytics_id':fields.many2one('account.analytic.plan.instance', 'Analytic Distribution'),
}
def create(self, cr, uid, vals, context=None):
@ -288,7 +288,7 @@ class account_move_line(osv.osv):
_inherit='account.move.line'
_name='account.move.line'
_columns = {
'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Distribution'),
'analytics_id':fields.many2one('account.analytic.plan.instance', 'Analytic Distribution'),
}
def _default_get_move_form_hook(self, cursor, user, data):
@ -357,7 +357,7 @@ class account_invoice(osv.osv):
ref = inv.reference
else:
ref = self._convert_ref(cr, uid, inv.number)
obj_move_line=self.pool.get('account.analytic.plan.instance').browse(cr,uid,il['analytics_id'])
obj_move_line=self.pool.get('account.analytic.plan.instance').browse(cr, uid, il['analytics_id'])
amount_calc=cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, il['price'], context={'date': inv.date_invoice}) * sign
qty=il['quantity']
il['analytic_lines']=[]

View File

@ -37,7 +37,7 @@ class analytic_plan_create_model(osv.osv_memory):
raise osv.except_osv(_('Error'), _('No analytic plan defined !'))
plan_obj.write(cr, uid, [context['active_id']], {'plan_id':pids[0]})
model_data_ids = mod_obj.search(cr,uid,[('model', '=', 'ir.ui.view'),('name', '=', 'view_analytic_plan_create_model')], context=context)
model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'),('name', '=', 'view_analytic_plan_create_model')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
return {
'name': _('Distribution Model Saved'),

View File

@ -157,17 +157,17 @@ class account_invoice(osv.osv):
def _refund_cleanup_lines(self, cr, uid, lines):
for line in lines:
inv_id = line['invoice_id']
inv_obj = self.browse(cr,uid,inv_id[0])
inv_obj = self.browse(cr, uid, inv_id[0])
if inv_obj.type == 'in_invoice':
if line.get('product_id',False):
product_obj = self.pool.get('product.product').browse(cr,uid,line['product_id'][0])
product_obj = self.pool.get('product.product').browse(cr, uid, line['product_id'][0])
oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id
if not oa:
oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id
if oa:
fpos = inv_obj.fiscal_position or False
a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)
account_data = self.pool.get('account.account').read(cr,uid,[a],['name'])[0]
account_data = self.pool.get('account.account').read(cr, uid, [a], ['name'])[0]
line.update({'account_id': (account_data['id'],account_data['name'])})
res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines)
return res

View File

@ -72,7 +72,7 @@ class account_budget_post_dotation(osv.osv):
res={}
for line in self.browse(cr, uid, ids):
if line.period_id:
obj_period=self.pool.get('account.period').browse(cr, uid,line.period_id.id)
obj_period=self.pool.get('account.period').browse(cr, uid, line.period_id.id)
total_days=strToDate(obj_period.date_stop) - strToDate(obj_period.date_start)
budget_id=line.post_id and line.post_id.id or False
@ -84,7 +84,7 @@ class account_budget_post_dotation(osv.osv):
tot_planned=0.00
for record in res1:
obj_lines = self.pool.get('crossovered.budget.lines').browse(cr, uid,record[0])
obj_lines = self.pool.get('crossovered.budget.lines').browse(cr, uid, record[0])
count_days = min(strToDate(obj_period.date_stop),strToDate(obj_lines.date_to)) - max(strToDate(obj_period.date_start), strToDate(obj_lines.date_from))
days_in_period = count_days.days +1
count_days = strToDate(obj_lines.date_to) - strToDate(obj_lines.date_from)
@ -102,7 +102,7 @@ class account_budget_post_dotation(osv.osv):
'post_id': fields.many2one('account.budget.post', 'Item', select=True),
'period_id': fields.many2one('account.period', 'Period'),
'amount': fields.float('Amount', digits=(16,2)),
'tot_planned':fields.function(_tot_planned,method=True, string='Total Planned Amount',type='float',store=True),
'tot_planned':fields.function(_tot_planned, method=True, string='Total Planned Amount', type='float', store=True),
}
account_budget_post_dotation()
@ -114,12 +114,12 @@ class crossovered_budget(osv.osv):
_columns = {
'name': fields.char('Name', size=50, required=True,states={'done':[('readonly',True)]}),
'code': fields.char('Code', size=20, required=True,states={'done':[('readonly',True)]}),
'creating_user_id': fields.many2one('res.users','Responsible User'),
'validating_user_id': fields.many2one('res.users','Validate User', readonly=True),
'date_from': fields.date('Start Date',required=True,states={'done':[('readonly',True)]}),
'date_to': fields.date('End Date',required=True,states={'done':[('readonly',True)]}),
'creating_user_id': fields.many2one('res.users', 'Responsible User'),
'validating_user_id': fields.many2one('res.users', 'Validate User', readonly=True),
'date_from': fields.date('Start Date', required=True, states={'done':[('readonly',True)]}),
'date_to': fields.date('End Date', required=True, states={'done':[('readonly',True)]}),
'state' : fields.selection([('draft','Draft'),('confirm','Confirmed'),('validate','Validated'),('done','Done'),('cancel', 'Cancelled')], 'Status', select=True, required=True, readonly=True),
'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'crossovered_budget_id', 'Budget Lines',states={'done':[('readonly',True)]} ),
'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'crossovered_budget_id', 'Budget Lines', states={'done':[('readonly',True)]} ),
}
_defaults = {
@ -186,10 +186,10 @@ class crossovered_budget_lines(osv.osv):
res[line.id] = result
return res
def _prac(self, cr, uid, ids,name,args,context):
def _prac(self, cr, uid, ids, name, args, context):
res={}
for line in self.browse(cr, uid, ids):
res[line.id]=self._prac_amt(cr,uid,[line.id],context=context)[line.id]
res[line.id]=self._prac_amt(cr, uid, [line.id], context=context)[line.id]
return res
@ -223,14 +223,14 @@ class crossovered_budget_lines(osv.osv):
res[line.id]=theo_amt
return res
def _theo(self, cr, uid, ids,name,args,context):
def _theo(self, cr, uid, ids, name, args, context):
res={}
for line in self.browse(cr, uid, ids):
res[line.id]=self._theo_amt(cr,uid,[line.id],context=context)[line.id]
res[line.id]=self._theo_amt(cr, uid, [line.id], context=context)[line.id]
return res
def _perc(self, cr, uid, ids,name,args,context):
def _perc(self, cr, uid, ids, name, args, context):
res = {}
for line in self.browse(cr, uid, ids):
if line.theoritical_amount<>0.00:
@ -244,13 +244,13 @@ class crossovered_budget_lines(osv.osv):
'crossovered_budget_id': fields.many2one('crossovered.budget', 'Budget', ondelete='cascade', select=True, required=True),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account',required=True),
'general_budget_id': fields.many2one('account.budget.post', 'Budgetary Position',required=True),
'date_from': fields.date('Start Date',required=True),
'date_to': fields.date('End Date',required=True),
'date_from': fields.date('Start Date', required=True),
'date_to': fields.date('End Date', required=True),
'paid_date': fields.date('Paid Date'),
'planned_amount':fields.float('Planned Amount',required=True,digits=(16,2)),
'practical_amount':fields.function(_prac,method=True, string='Practical Amount',type='float',digits=(16,2)),
'theoritical_amount':fields.function(_theo,method=True, string='Theoritical Amount',type='float',digits=(16,2)),
'percentage':fields.function(_perc,method=True, string='Percentage',type='float'),
'planned_amount':fields.float('Planned Amount', required=True, digits=(16,2)),
'practical_amount':fields.function(_prac, method=True, string='Practical Amount', type='float', digits=(16,2)),
'theoritical_amount':fields.function(_theo, method=True, string='Theoritical Amount', type='float', digits=(16,2)),
'percentage':fields.function(_perc, method=True, string='Percentage', type='float'),
}
crossovered_budget_lines()

View File

@ -36,7 +36,7 @@ class budget_report(report_sxw.rml_parse):
})
self.context=context
def funct(self,object,form,ids={}, done=None, level=1):
def funct(self, object, form, ids={}, done=None, level=1):
if not ids:
ids = self.ids
@ -78,7 +78,7 @@ class budget_report(report_sxw.rml_parse):
context={'wizard_date_from':d_from,'wizard_date_to':d_to}
for i in range(0,len(an_ids)):
analytic_name=self.pool.get('account.analytic.account').browse(self.cr, self.uid,[an_ids[i][0]])
analytic_name=self.pool.get('account.analytic.account').browse(self.cr, self.uid, [an_ids[i][0]])
res={
'b_id':'-1',
@ -94,7 +94,7 @@ class budget_report(report_sxw.rml_parse):
line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', budget_ids),('analytic_account_id','=',an_ids[i][0])])
line_id = c_b_lines_obj.browse(self.cr,self.uid,line_ids)
line_id = c_b_lines_obj.browse(self.cr, self.uid, line_ids)
tot_theo=tot_pln=tot_prac=tot_perc=0.00
done_budget=[]
@ -194,7 +194,7 @@ class budget_report(report_sxw.rml_parse):
tot['perc']=float(tot['prac'] /tot['theo'])*100
return result
def funct_total(self,form):
def funct_total(self, form):
result=[]
res={}

View File

@ -47,7 +47,7 @@ class account_budget_report(osv.osv_memory):
'form': data
}
data_model = self.pool.get(datas['model']).browse(cr,uid,context['active_id'])
data_model = self.pool.get(datas['model']).browse(cr, uid, context['active_id'])
if not data_model.dotation_ids:
raise osv.except_osv(_('Insufficient Data!'),_('No Depreciation or Master Budget Expenses Found on Budget %s!') % data_model.name)

View File

@ -27,7 +27,7 @@ class account_budget_spread(osv.osv_memory):
_name = 'account.budget.spread'
_description = 'Account Budget spread '
_columns = {
'fiscalyear': fields.many2one('account.fiscalyear','Fiscal Year', required=True),
'fiscalyear': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
}

View File

@ -29,8 +29,8 @@ class account_coda(osv.osv):
'name': fields.binary('Coda file', readonly=True),
'statement_ids': fields.one2many('account.bank.statement','coda_id','Generated Bank Statement', readonly=True),
'note': fields.text('Import log', readonly=True),
'journal_id': fields.many2one('account.journal','Bank Journal', readonly=True,select=True),
'date': fields.date('Import Date', readonly=True,select=True),
'journal_id': fields.many2one('account.journal','Bank Journal', readonly=True, select=True),
'date': fields.date('Import Date', readonly=True, select=True),
'user_id': fields.many2one('res.users','User', readonly=True, select=True),
}
_defaults = {

View File

@ -123,8 +123,8 @@ def _coda_parsing(self, cr, uid, data, context):
bank_statement_lines = {}
bank_statement['date'] = str2date(line[5:11])
bank_statement['journal_id']=data['form']['journal_id']
period_id = pool.get('account.period').search(cr,uid,[('date_start','<=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d"))),('date_stop','>=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d")))])
# bank_statement['period_id'] = period_id and period_id[0] or False
period_id = pool.get('account.period').search(cr, uid, [('date_start','<=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d"))),('date_stop','>=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d")))])
bank_statement['period_id'] = period_id[0]
bank_statement['state']='draft'
elif line[0] == '1':
# old balance data
@ -178,10 +178,10 @@ def _coda_parsing(self, cr, uid, data, context):
st_line_partner_acc = str(line[10:47]).strip()
cntry_number=line[10:47].strip()
contry_name=line[47:125].strip()
bank_ids = pool.get('res.partner.bank').search(cr,uid,[('acc_number','=',st_line_partner_acc)])
bank_ids = pool.get('res.partner.bank').search(cr, uid, [('acc_number','=',st_line_partner_acc)])
bank_statement_lines[st_line_name].update({'cntry_number': cntry_number, 'contry_name': contry_name})
if bank_ids:
bank = pool.get('res.partner.bank').browse(cr,uid,bank_ids[0],context)
bank = pool.get('res.partner.bank').browse(cr, uid, bank_ids[0], context)
if line and bank.partner_id:
bank_statement_lines[st_line_name].update({'partner_id': bank.partner_id.id})
if bank_statement_lines[st_line_name]['amount'] < 0 :
@ -276,7 +276,7 @@ def _coda_parsing(self, cr, uid, data, context):
err_log += '\n\nNumber of statements : '+ str(len(bkst_list))
err_log += '\nNumber of error :'+ str(nb_err) +'\n'
pool.get('account.coda').create(cr, uid,{
pool.get('account.coda').create(cr, uid, {
'name':codafile,
'statement_ids': [(6, 0, bkst_list,)],
'note':str_log1+str_not+std_log+err_log,

View File

@ -178,7 +178,7 @@ class account_followup_print_all(osv.osv_memory):
msg_unsent = ''
count = 0
data_user = user_obj.browse(cr, uid, uid)
move_lines = line_obj.browse(cr,uid,data['partner_ids'][0][2])
move_lines = line_obj.browse(cr, uid, data['partner_ids'][0][2])
partners = []
dict_lines = {}
for line in move_lines:
@ -186,7 +186,7 @@ class account_followup_print_all(osv.osv_memory):
dict_lines[line.name.id] =line
for partner in partners:
ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable'])])
data_lines = move_obj.browse(cr,uid,ids_lines)
data_lines = move_obj.browse(cr, uid, ids_lines)
followup_data = dict_lines[partner.id]
dest = False
if partner.address:

View File

@ -26,8 +26,8 @@ class notify_message(osv.osv):
_name = 'notify.message'
_description = 'Notify By Messages'
_columns = {
'name' : fields.char('Title',size=64,required=True),
'msg' : fields.text('Special Message',size=125,required=True,help='This notification will appear at the bottom of the Invoices when printed.',translate=True)
'name' : fields.char('Title', size=64, required=True),
'msg' : fields.text('Special Message', size=125, required=True, help='This notification will appear at the bottom of the Invoices when printed.', translate=True)
}
notify_message()

View File

@ -43,7 +43,7 @@ class account_invoice_1(report_sxw.rml_parse):
ids = self.pool.get('account.invoice.line').search(self.cr, self.uid, [('invoice_id', '=', invoice.id)])
ids.sort()
for id in range(0,len(ids)):
info = self.pool.get('account.invoice.line').browse(self.cr, self.uid,ids[id], self.context.copy())
info = self.pool.get('account.invoice.line').browse(self.cr, self.uid, ids[id], self.context.copy())
list_in_seq[info]=info.sequence
i=1
j=0
@ -80,7 +80,7 @@ class account_invoice_1(report_sxw.rml_parse):
if entry.uos_id.id==False:
res['uos']=''
else:
uos_name = self.pool.get('product.uom').read(self.cr,self.uid,entry.uos_id.id,['name'],self.context.copy())
uos_name = self.pool.get('product.uom').read(self.cr, self.uid, entry.uos_id.id, ['name'], self.context.copy())
res['uos'] = uos_name['name']
else:

View File

@ -89,7 +89,7 @@ class account_invoice_with_message(report_sxw.rml_parse):
if entry.uos_id.id==False:
res['uos']=''
else:
uos_name = self.pool.get('product.uom').read(self.cr,self.uid,entry.uos_id.id,['name'],self.context.copy())
uos_name = self.pool.get('product.uom').read(self.cr, self.uid, entry.uos_id.id, ['name'], self.context.copy())
res['uos']=uos_name['name']
else:

View File

@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from operator import itemgetter
from osv import fields, osv
from tools.translate import _
@ -42,7 +42,7 @@ class account_move_line(osv.osv):
WHERE move_line_id = ml.id
AND po.state != 'cancel') as amount
FROM account_move_line ml
WHERE id =ANY(%s)""" ,(ids,))
WHERE id IN %s""", (tuple(ids),))
r=dict(cr.fetchall())
return r
@ -58,8 +58,10 @@ class account_move_line(osv.osv):
END - coalesce(sum(pl.amount_currency), 0)
FROM payment_line pl
INNER JOIN payment_order po ON (pl.order_id = po.id)
WHERE move_line_id = l.id AND po.state != 'cancel')''' \
+ x[1] + str(x[2])+' ',args))
WHERE move_line_id = l.id
AND po.state != 'cancel'
) %(operator)s %%s ''' % {'operator': x[1]}, args))
sql_args = tuple(map(itemgetter(2), args))
cr.execute(('''select id
from account_move_line l
@ -68,7 +70,7 @@ class account_move_line(osv.osv):
where type=%s and active)
and reconcile_id is null
and credit > 0
and ''' + where + ' and ' + query), ('payable',) )
and ''' + where + ' and ' + query), ('payable',)+sql_args )
res = cr.fetchall()
if not len(res):

View File

@ -31,7 +31,7 @@ class payment_type(osv.osv):
'code': fields.char('Code', size=64, required=True, help='Specifies the Code for Payment Type'),
'suitable_bank_types': fields.many2many('res.partner.bank.type',
'bank_type_payment_type_rel',
'pay_type_id','bank_type_id',
'pay_type_id', 'bank_type_id',
'Suitable bank types')
}
@ -41,15 +41,15 @@ class payment_mode(osv.osv):
_name= 'payment.mode'
_description= 'Payment Mode'
_columns= {
'name': fields.char('Name', size=64, required=True,help='Mode of Payment'),
'name': fields.char('Name', size=64, required=True, help='Mode of Payment'),
'bank_id': fields.many2one('res.partner.bank', "Bank account",
required=True,help='Bank Account for the Payment Mode'),
'journal': fields.many2one('account.journal', 'Journal', required=True,
domain=[('type', '=', 'cash')],help='Cash Journal for the Payment Mode'),
'type': fields.many2one('payment.type','Payment type',required=True,help='Select the Payment Type for the Payment Mode.'),
domain=[('type', '=', 'cash')], help='Cash Journal for the Payment Mode'),
'type': fields.many2one('payment.type', 'Payment type', required=True, help='Select the Payment Type for the Payment Mode.'),
}
def suitable_bank_types(self,cr,uid,payment_code=None,context={}):
def suitable_bank_types(self, cr, uid, payment_code=None, context={}):
"""Return the codes of the bank type that are suitable
for the given payment type code"""
if not payment_code:
@ -96,10 +96,10 @@ class payment_order(osv.osv):
('cancel','Cancelled'),
('done','Done')], 'State', select=True,
help='When an order is placed the state is \'Draft\'.\n Once the bank is confirmed the state is set to \'Confirmed\'.\n Then the order is paid the state is \'Done\'.'),
'line_ids': fields.one2many('payment.line','order_id','Payment lines',states={'done':[('readonly',True)]}),
'line_ids': fields.one2many('payment.line', 'order_id', 'Payment lines', states={'done':[('readonly',True)]}),
'total': fields.function(_total, string="Total", method=True,
type='float'),
'user_id': fields.many2one('res.users','User', required=True, states={'done':[('readonly',True)]}),
'user_id': fields.many2one('res.users', 'User', required=True, states={'done':[('readonly',True)]}),
'date_prefered': fields.selection([
('now', 'Directly'),
('due', 'Due date'),
@ -125,10 +125,10 @@ class payment_order(osv.osv):
return True
def action_open(self, cr, uid, ids, *args):
for order in self.read(cr,uid,ids,['reference']):
for order in self.read(cr, uid, ids, ['reference']):
if not order['reference']:
reference = self.pool.get('ir.sequence').get(cr, uid, 'payment.order')
self.write(cr,uid,order['id'],{'reference':reference})
self.write(cr, uid, order['id'],{'reference':reference})
return True
def set_done(self, cr, uid, id, *args):
@ -144,19 +144,9 @@ class payment_line(osv.osv):
_name = 'payment.line'
_description = 'Payment Line'
#~ def partner_payable(self, cr, uid, ids, name, args, context={}):
#~ if not ids: return {}
#~ partners= self.read(cr, uid, ids, ['partner_id'], context)
#~ partners= dict(map(lambda x: (x['id'], x['partner_id'][0]), partners))
#~ debit = self.pool.get('res.partner')._debit_get(cr, uid,
#~ partners.values(), name, args, context)
#~ for i in partners:
#~ partners[i] = debit[partners[i]]
#~ return partners
def translate(self, orig):
return {
# "to_pay": "credit",
"due_date": "date_maturity",
"reference": "ref"}.get(orig, orig)
@ -173,7 +163,7 @@ class payment_line(osv.osv):
st=ads.street and ads.street or ''
st1=ads.street2 and ads.street2 or ''
if 'zip_id' in ads:
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or ''
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
else:
zip=ads.zip and ads.zip or ''
city= ads.city and ads.city or ''
@ -199,7 +189,7 @@ class payment_line(osv.osv):
st=ads.street and ads.street or ''
st1=ads.street2 and ads.street2 or ''
if 'zip_id' in ads:
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or ''
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
else:
zip=ads.zip and ads.zip or ''
city= ads.city and ads.city or ''
@ -218,14 +208,14 @@ class payment_line(osv.osv):
from account_move_line ml
inner join payment_line pl
on (ml.id = pl.move_line_id)
where pl.id =ANY(%s)""",
(self.translate(name),ids,))
where pl.id IN %%s"""% self.translate(name),
(tuple(ids),))
res = dict(cr.fetchall())
if name == 'partner_id':
partner_name = {}
for p_id, p_name in partner_obj.name_get(cr,uid,
filter(lambda x:x and x != 0,res.values()),context=context):
for p_id, p_name in partner_obj.name_get(cr, uid,
filter(lambda x:x and x != 0,res.values()), context=context):
partner_name[p_id] = p_name
for id in ids:
@ -238,61 +228,6 @@ class payment_line(osv.osv):
res.setdefault(id, (False, ""))
return res
# def _currency(self, cursor, user, ids, name, args, context=None):
# if not ids:
# return {}
# res = {}
#
# currency_obj = self.pool.get('res.currency')
# account_obj = self.pool.get('account.account')
# cursor.execute('''SELECT pl.id, ml.currency_id, ml.account_id
# FROM account_move_line ml
# INNER JOIN payment_line pl
# ON (ml.id = pl.move_line_id)
# WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')')
#
# res2 = {}
# account_ids = []
# for payment_line_id, currency_id, account_id in cursor.fetchall():
# res2[payment_line_id] = [currency_id, account_id]
# account_ids.append(account_id)
#
# account2currency_id = {}
# for account in account_obj.browse(cursor, user, account_ids,
# context=context):
# account2currency_id[account.id] = account.company_currency_id.id
#
# for payment_line_id in ids:
# if res2[payment_line_id][0]:
# res[payment_line_id] = res2[payment_line_id][0]
# else:
# res[payment_line_id] = \
# account2currency_id[res2[payment_line_id][1]]
#
# currency_names = {}
# for currency_id, name in currency_obj.name_get(cursor, user, res.values(),
# context=context):
# currency_names[currency_id] = name
# for payment_line_id in ids:
# res[payment_line_id] = (res[payment_line_id],
# currency_names[res[payment_line_id]])
# return res
#
# def _to_pay_currency(self, cursor, user, ids, name , args, context=None):
# if not ids:
# return {}
#
# cursor.execute('''SELECT pl.id,
# CASE WHEN ml.amount_currency < 0
# THEN - ml.amount_currency
# ELSE ml.credit
# END
# FROM account_move_line ml
# INNER JOIN payment_line pl
# ON (ml.id = pl.move_line_id)
# WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')')
# return dict(cursor.fetchall())
def _amount(self, cursor, user, ids, name, args, context=None):
if not ids:
return {}
@ -328,15 +263,6 @@ class payment_line(osv.osv):
else:
return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
# def select_move_lines(*a):
# print a
# return []
# def create(self, cr, uid, vals, context):
# print "created!!!"
# vals['company_currency'] = self._get_currency(cr, uid, context)
# return super(payment_line, self).create(cr, uid, vals, context)
def _get_ml_inv_ref(self, cr, uid, ids, *a):
res={}
for id in self.browse(cr, uid, ids):
@ -366,42 +292,28 @@ class payment_line(osv.osv):
_columns = {
'name': fields.char('Your Reference', size=64, required=True),
'communication': fields.char('Communication', size=64, required=True,help="Used as the message between ordering customer and current company. Depicts 'What do you want to say to the recipient about this order ?'"),
'communication2': fields.char('Communication 2', size=64,help='The successor message of Communication.'),
'move_line_id': fields.many2one('account.move.line','Entry line', domain=[('reconcile_id','=', False), ('account_id.type', '=','payable')],help='This Entry Line will be referred for the information of the ordering customer.'),
'communication': fields.char('Communication', size=64, required=True, help="Used as the message between ordering customer and current company. Depicts 'What do you want to say to the recipient about this order ?'"),
'communication2': fields.char('Communication 2', size=64, help='The successor message of Communication.'),
'move_line_id': fields.many2one('account.move.line', 'Entry line', domain=[('reconcile_id','=', False), ('account_id.type', '=','payable')], help='This Entry Line will be referred for the information of the ordering customer.'),
'amount_currency': fields.float('Amount in Partner Currency', digits=(16,2),
required=True, help='Payment amount in the partner currency'),
# 'to_pay_currency': fields.function(_to_pay_currency, string='To Pay',
# method=True, type='float',
# help='Amount to pay in the partner currency'),
# 'currency': fields.function(_currency, string='Currency',
# method=True, type='many2one', obj='res.currency'),
'currency': fields.many2one('res.currency','Partner Currency',required=True),
'company_currency': fields.many2one('res.currency','Company Currency',readonly=True),
'currency': fields.many2one('res.currency','Partner Currency', required=True),
'company_currency': fields.many2one('res.currency', 'Company Currency', readonly=True),
'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'),
'order_id': fields.many2one('payment.order', 'Order', required=True,
ondelete='cascade', select=True),
'partner_id': fields.many2one('res.partner', string="Partner",required=True,help='The Ordering Customer'),
'partner_id': fields.many2one('res.partner', string="Partner", required=True, help='The Ordering Customer'),
'amount': fields.function(_amount, string='Amount in Company Currency',
method=True, type='float',
help='Payment amount in the company currency'),
# 'to_pay': fields.function(select_by_name, string="To Pay", method=True,
# type='float', help='Amount to pay in the company currency'),
# 'due_date': fields.function(select_by_name, string="Due date",
# method=True, type='date'),
'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date",
method=True, type='date',help="Invoice Effective Date"),
# 'reference': fields.function(select_by_name, string="Ref", method=True,
# type='char'),
method=True, type='date', help="Invoice Effective Date"),
'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='date', string='Maturity Date'),
'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='many2one', relation='account.invoice', string='Invoice Ref.'),
'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text",help='Address of the Main Partner'),
'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text",help='Address of the Ordering Customer.'),
# 'partner_payable': fields.function(partner_payable, string="Partner payable", method=True, type='float'),
# 'value_date': fields.function(_value_date, string='Value Date',
# method=True, type='date'),
'date': fields.date('Payment Date',help="If no payment date is specified, the bank will treat this payment line directly"),
'create_date': fields.datetime('Created' ,readonly=True),
'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text", help='Address of the Main Partner'),
'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text", help='Address of the Ordering Customer.'),
'date': fields.date('Payment Date', help="If no payment date is specified, the bank will treat this payment line directly"),
'create_date': fields.datetime('Created' , readonly=True),
'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True)
}
_defaults = {
@ -415,13 +327,13 @@ class payment_line(osv.osv):
('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'),
]
def onchange_move_line(self,cr,uid,ids,move_line_id,payment_type,date_prefered,date_planned,currency=False,company_currency=False,context=None):
def onchange_move_line(self, cr, uid, ids, move_line_id, payment_type, date_prefered, date_planned, currency=False, company_currency=False, context=None):
data={}
data['amount_currency']=data['communication']=data['partner_id']=data['reference']=data['date_created']=data['bank_id']=data['amount']=False
if move_line_id:
line = self.pool.get('account.move.line').browse(cr,uid,move_line_id)
line = self.pool.get('account.move.line').browse(cr, uid, move_line_id)
data['amount_currency']=line.amount_to_pay
res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency,
@ -437,7 +349,7 @@ class payment_line(osv.osv):
data['currency'] = temp
# calling onchange of partner and updating data dictionary
temp_dict=self.onchange_partner(cr,uid,ids,line.partner_id.id,payment_type)
temp_dict=self.onchange_partner(cr, uid, ids, line.partner_id.id, payment_type)
data.update(temp_dict['value'])
data['reference']=line.ref
@ -463,12 +375,12 @@ class payment_line(osv.osv):
res['amount'] = company_amount
return {'value': res}
def onchange_partner(self,cr,uid,ids,partner_id,payment_type,context=None):
def onchange_partner(self, cr, uid, ids, partner_id, payment_type, context=None):
data={}
data['info_partner']=data['bank_id']=False
if partner_id:
part_obj=self.pool.get('res.partner').browse(cr,uid,partner_id)
part_obj=self.pool.get('res.partner').browse(cr, uid, partner_id)
partner=part_obj.name or ''
if part_obj.address:
@ -478,7 +390,7 @@ class payment_line(osv.osv):
st1=ads.street2 and ads.street2 or ''
if 'zip_id' in ads:
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or ''
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
else:
zip=ads.zip and ads.zip or ''
city= ads.city and ads.city or ''

View File

@ -61,7 +61,7 @@ class account_report(osv.osv):
if key==0:
return obj.find(cr, uid, exception=False)
else:
obj_key=obj.browse(cr,uid,obj.find(cr, uid, exception=False))
obj_key=obj.browse(cr, uid, obj.find(cr, uid, exception=False))
if isinstance(obj_key,list):
obj_key=obj_key[0]
key_ids=obj.search(cr,uid,[('date_stop','<',obj_key.date_start)])
@ -69,8 +69,8 @@ class account_report(osv.osv):
return False
return key_ids[key]
def _calc_credit(code,year=0):
context['fiscalyear']=_calc_context(year,obj_fy)
def _calc_credit(code, year=0):
context['fiscalyear']=_calc_context(year, obj_fy)
if not context['fiscalyear']:
del context['fiscalyear']
acc = self.pool.get('account.account')
@ -78,7 +78,7 @@ class account_report(osv.osv):
return reduce(lambda y,x=0: x.credit+y, acc.browse(cr, uid, acc_id, context),0.0)
def _calc_debit(code,year=0):
context['fiscalyear']=_calc_context(year,obj_fy)
context['fiscalyear']=_calc_context(year, obj_fy)
if not context['fiscalyear']:
del context['fiscalyear']
acc = self.pool.get('account.account')
@ -86,7 +86,7 @@ class account_report(osv.osv):
return reduce(lambda y,x=0: x.debit+y, acc.browse(cr, uid, acc_id, context),0.0)
def _calc_balance(code,year=0):
context['fiscalyear']=_calc_context(year,obj_fy)
context['fiscalyear']=_calc_context(year, obj_fy)
if not context['fiscalyear']:
del context['fiscalyear']
acc = self.pool.get('account.account')
@ -102,7 +102,7 @@ class account_report(osv.osv):
return reduce(lambda y,x=0: x.amount+y, acc.browse(cr, uid, acc_id, context),0.0)
def _calc_tax_code(code,period=0):
context['period_id']=_calc_context(period,obj_period)
context['period_id']=_calc_context(period, obj_period)
if not context['period_id']:
return 0.00
context['period_id']=context['period_id'][0]
@ -145,7 +145,7 @@ class account_report(osv.osv):
def onchange_parent_id(self, cr, uid, ids, parent_id):
v={}
if parent_id:
acc=self.pool.get('account.report.report').browse(cr,uid,parent_id)
acc=self.pool.get('account.report.report').browse(cr, uid, parent_id)
v['type']=acc.type
# if int(acc.style) < 6:
# v['style'] = str(int(acc.style)+1)
@ -163,8 +163,8 @@ class account_report(osv.osv):
('other','Others')],
'Type', required=True),
'expression': fields.char('Expression', size=240, required=True),
'badness_limit' :fields.float('Badness Indicator Limit', digits=(16,2),help='This Value sets the limit of badness.'),
'goodness_limit' :fields.float('Goodness Indicator Limit', digits=(16,2),help='This Value sets the limit of goodness.'),
'badness_limit' :fields.float('Badness Indicator Limit', digits=(16,2), help='This Value sets the limit of badness.'),
'goodness_limit' :fields.float('Goodness Indicator Limit', digits=(16,2), help='This Value sets the limit of goodness.'),
'parent_id': fields.many2one('account.report.report', 'Parent'),
'child_ids': fields.one2many('account.report.report', 'parent_id', 'Children'),
'note': fields.text('Note'),
@ -180,8 +180,8 @@ class account_report(osv.osv):
('very good', 'Very Good')
],
string='Status'),
'disp_tree':fields.boolean('Display Tree',help='When the indicators are printed, if one indicator is set with this field to True, then it will display one more graphs with all its children in tree'),
'disp_graph':fields.boolean('Display As Graph',help='If the field is set to True, information will be printed as a Graph, otherwise as an array.'),
'disp_tree':fields.boolean('Display Tree', help='When the indicators are printed, if one indicator is set with this field to True, then it will display one more graphs with all its children in tree'),
'disp_graph':fields.boolean('Display As Graph', help='If the field is set to True, information will be printed as a Graph, otherwise as an array.'),
# 'style': fields.selection(_style, 'Style', required=True),
# 'color_font' : fields.selection(_color, 'Font Color', help="Font Color for the report"),
# 'color_back' : fields.selection(_color, 'Back Color')
@ -215,12 +215,12 @@ account_report()
class account_report_history(osv.osv):
def _calc_value(self, cr, uid, ids, name, args, context):
acc_report_id=self.read(cr,uid,ids,['tmp','period_id'])
acc_report_id=self.read(cr, uid, ids, ['tmp','period_id'])
tmp_ids={}
for a in acc_report_id:
period_val=pooler.get_pool(cr.dbname).get('account.period').read(cr,uid,[a['period_id'][0]])[0]
period_id=pooler.get_pool(cr.dbname).get('account.period').search(cr,uid,[('date_start','<=',period_val['date_start']),('fiscalyear_id','=',period_val['fiscalyear_id'][0])])
tmp_ids[a['id']] = pooler.get_pool(cr.dbname).get('account.report.report').read(cr,uid,[a['tmp']],context={'periods':period_id})[0]['amount']
period_val=pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [a['period_id'][0]])[0]
period_id=pooler.get_pool(cr.dbname).get('account.period').search(cr, uid, [('date_start','<=',period_val['date_start']),('fiscalyear_id','=',period_val['fiscalyear_id'][0])])
tmp_ids[a['id']] = pooler.get_pool(cr.dbname).get('account.report.report').read(cr, uid, [a['tmp']], context={'periods':period_id})[0]['amount']
return tmp_ids
_name = "account.report.history"

View File

@ -76,7 +76,7 @@ class account_report_bs(osv.osv):
def onchange_parent_id(self, cr, uid, ids, parent_id):
v={}
if parent_id:
acc=self.pool.get('account.report.report').browse(cr,uid,parent_id)
acc=self.pool.get('account.report.report').browse(cr, uid, parent_id)
v['type']=acc.type
if int(acc.style) < 6:
v['style'] = str(int(acc.style)+1)

View File

@ -126,9 +126,9 @@ class account_invoice_line(osv.osv):
_columns = {
'price_subtotal': fields.function(_amount_line2, method=True, string='Subtotal w/o tax', multi='amount',
store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self,cr,uid,ids,c={}: ids, None,10)}),
store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids, None,10)}),
'price_subtotal_incl': fields.function(_amount_line2, method=True, string='Subtotal', multi='amount',
store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self,cr,uid,ids,c={}: ids, None,10)}),
store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids, None,10)}),
}
_defaults = {

View File

@ -34,8 +34,8 @@ class report_voucher(report_sxw.rml_parse):
'get_ref' : self._get_ref
})
def convert(self,amount, cur):
amt_en = amount_to_text_en.amount_to_text(amount,'en',cur);
def convert(self, amount, cur):
amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur);
return amt_en
def debit(self, move_ids):

View File

@ -31,8 +31,8 @@ class report_voucher_amount(report_sxw.rml_parse):
'convert':self.convert
})
def convert(self,amount, cur):
amt_en = amount_to_text_en.amount_to_text(amount,'en',cur);
def convert(self, amount, cur):
amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur);
return amt_en

View File

@ -212,7 +212,7 @@ class account_voucher(osv.osv):
self.write(cr, uid, ids, {'state':'posted'})
return True
def cancel_voucher(self,cr,uid,ids,context={}):
def cancel_voucher(self, cr, uid, ids, context={}):
self.action_cancel(cr, uid, ids)
self.write(cr, uid, ids, {'state':'cancel'})
return True
@ -406,7 +406,7 @@ class account_voucher(osv.osv):
'general_account_id':line.account_id.id,
'ref':ref
}
self.pool.get('account.analytic.line').create(cr,uid,an_line)
self.pool.get('account.analytic.line').create(cr, uid, an_line)
self.write(cr, uid, [inv.id], {'move_id': move_id})
obj=self.pool.get('account.move').browse(cr, uid, move_id)
@ -440,7 +440,7 @@ class account_voucher(osv.osv):
def action_number(self, cr, uid, ids, *args):
cr.execute('SELECT id, type, number, move_id, reference ' \
'FROM account_voucher ' \
'WHERE id =ANY(%s)',(ids,))
'WHERE id IN %s',(tuple(ids),))
for (id, invtype, number, move_id, reference) in cr.fetchall():
if not number:
number = self.pool.get('ir.sequence').get(cr, uid, invtype)
@ -568,7 +568,7 @@ class account_voucher_line(osv.osv):
'value' : {'account_id' : account_id.id, 'type' : ttype, 'amount':balance}
}
def onchange_amount(self, cr, uid, ids,partner_id,amount, type,type1):
def onchange_amount(self, cr, uid, ids, partner_id, amount, type, type1):
if not amount:
return {'value' : {}}
if partner_id:
@ -630,7 +630,7 @@ class account_voucher_line(osv.osv):
'value' : { 'type' : type , 'amount':amount}
}
def onchange_type(self, cr, uid, ids,partner_id,amount,type,type1):
def onchange_type(self, cr, uid, ids, partner_id, amount, type, type1):
if partner_id:
obj = self.pool.get('res.partner')
if type1 in ('rec_voucher','bank_rec_voucher', 'journal_voucher'):

View File

@ -33,7 +33,7 @@ account_move_line()
class account_voucher(osv.osv):
_inherit = 'account.voucher'
_columns = {
'voucher_line_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=False, states={'proforma':[('readonly',True)]}),
'voucher_line_ids':fields.one2many('account.voucher.line', 'voucher_id', 'Voucher Lines', readonly=False, states={'proforma':[('readonly',True)]}),
}
def action_move_line_create(self, cr, uid, ids, *args):
@ -192,7 +192,7 @@ class account_voucher(osv.osv):
'general_account_id':line.account_id.id,
'ref':ref
}
self.pool.get('account.analytic.line').create(cr,uid,an_line)
self.pool.get('account.analytic.line').create(cr, uid, an_line)
if mline_ids:
self.pool.get('account.move.line').reconcile_partial(cr, uid, mline_ids, 'manual', context={})
self.write(cr, uid, [inv.id], {'move_id': move_id})

View File

@ -33,10 +33,10 @@ class account_analytic_account(osv.osv):
_name = 'account.analytic.account'
_description = 'Analytic Account'
def _compute_currency_for_level_tree(self, cr, uid, ids, ids2, res, acc_set, context={}):
def _compute_currency_for_level_tree(self, cr, uid, ids, ids2, res, context={}):
# Handle multi-currency on each level of analytic account
# This is a refactoring of _balance_calc computation
cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id in (%s)" % acc_set)
cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id IN %s" , (tuple(ids2),))
currency= dict(cr.fetchall())
res_currency= self.pool.get('res.currency')
for id in ids:
@ -50,24 +50,22 @@ class account_analytic_account(osv.osv):
else:
res[id] += res.get(child, 0.0)
cur_obj = res_currency.browse(cr,uid,currency.values(),context)
cur_obj = res_currency.browse(cr, uid, currency.values(), context)
cur_obj = dict([(o.id, o) for o in cur_obj])
for id in ids:
if id in ids2:
res[id] = res_currency.round(cr,uid,cur_obj[currency[id]],res.get(id,0.0))
res[id] = res_currency.round(cr, uid, cur_obj[currency[id]], res.get(id,0.0))
return dict([(i, res[i]) for i in ids ])
def _credit_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
acc_set = ",".join(map(str, ids2))
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
for i in ids:
res.setdefault(i,0.0)
if not ids2:
if not parent_ids:
return res
where_date = ''
@ -75,19 +73,17 @@ class account_analytic_account(osv.osv):
where_date += " AND l.date >= '" + context['from_date'] + "'"
if context.get('to_date',False):
where_date += " AND l.date <= '" + context['to_date'] + "'"
cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency<0 and a.id =ANY(%s) GROUP BY a.id",(ids2,))
cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency<0 and a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
r = dict(cr.fetchall())
return self._compute_currency_for_level_tree(cr, uid, ids, ids2, r, acc_set, context)
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context)
def _debit_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
acc_set = ",".join(map(str, ids2))
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
for i in ids:
res.setdefault(i,0.0)
if not ids2:
if not parent_ids:
return res
where_date = ''
@ -95,19 +91,17 @@ class account_analytic_account(osv.osv):
where_date += " AND l.date >= '" + context['from_date'] + "'"
if context.get('to_date',False):
where_date += " AND l.date <= '" + context['to_date'] + "'"
cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency>0 and a.id =ANY(%s) GROUP BY a.id" ,(ids2,))
cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency>0 and a.id IN %s GROUP BY a.id" ,(tuple(parent_ids),))
r= dict(cr.fetchall())
return self._compute_currency_for_level_tree(cr, uid, ids, ids2, r, acc_set, context)
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context)
def _balance_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
acc_set = ",".join(map(str, ids2))
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
for i in ids:
res.setdefault(i,0.0)
if not ids2:
if not parent_ids:
return res
where_date = ''
@ -115,23 +109,22 @@ class account_analytic_account(osv.osv):
where_date += " AND l.date >= '" + context['from_date'] + "'"
if context.get('to_date',False):
where_date += " AND l.date <= '" + context['to_date'] + "'"
cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id =ANY(%s) GROUP BY a.id",(ids2,))
cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
for account_id, sum in cr.fetchall():
res[account_id] = sum
return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context)
def _quantity_calc(self, cr, uid, ids, name, arg, context={}):
#XXX must convert into one uom
res = {}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
acc_set = ",".join(map(str, ids2))
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
for i in ids:
res.setdefault(i,0.0)
if not ids2:
if not parent_ids:
return res
where_date = ''
@ -143,13 +136,13 @@ class account_analytic_account(osv.osv):
cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \
FROM account_analytic_account a \
LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \
WHERE a.id =ANY(%s) GROUP BY a.id',(ids2,))
WHERE a.id IN %s GROUP BY a.id',(tuple(parent_ids),))
for account_id, sum in cr.fetchall():
res[account_id] = sum
for id in ids:
if id not in ids2:
if id not in parent_ids:
continue
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
if child != id:
@ -223,9 +216,9 @@ class account_analytic_account(osv.osv):
'type' : lambda *a : 'normal',
'company_id': _default_company,
'state' : lambda *a : 'open',
'user_id' : lambda self,cr,uid,ctx : uid,
'partner_id': lambda self,cr, uid, ctx: ctx.get('partner_id', False),
'contact_id': lambda self,cr, uid, ctx: ctx.get('contact_id', False),
'user_id' : lambda self, cr, uid, ctx : uid,
'partner_id': lambda self, cr, uid, ctx: ctx.get('partner_id', False),
'contact_id': lambda self, cr, uid, ctx: ctx.get('contact_id', False),
'date_start': lambda *a: time.strftime('%Y-%m-%d')
}
@ -330,13 +323,13 @@ class account_analytic_line(osv.osv):
'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency',
store={
'account.analytic.account': (_get_account_line, ['company_id'], 50),
'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10),
'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount','unit_amount'],10),
},
help="The related account currency if not equal to the company one."),
'amount_currency': fields.function(_amount_currency, method=True, digits_compute= dp.get_precision('Account'), string='Amount currency',
store={
'account.analytic.account': (_get_account_line, ['company_id'], 50),
'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10),
'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount','unit_amount'],10),
},
help="The amount expressed in the related account currency if not equal to the company one."),

View File

@ -27,8 +27,8 @@ class analytic_journal_rate_grid(osv.osv):
_name="analytic_journal_rate_grid"
_description= "Relation table between journals and billing rates"
_columns={
'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal',required=True,),
'account_id': fields.many2one("account.analytic.account", "Analytic Account",required=True,),
'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal', required=True,),
'account_id': fields.many2one("account.analytic.account", "Analytic Account", required=True,),
'rate_id': fields.many2one("hr_timesheet_invoice.factor", "Invoicing Rate",),
}
@ -67,14 +67,14 @@ class hr_analytic_timesheet(osv.osv):
#get the old values from super and add the value from the new relation analytic_journal_rate_grid
r = self.pool.get('analytic_journal_rate_grid').browse(cr, uid, temp)[0]
res.setdefault('value',{})
res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id,user_id, unit_amount)['value']
res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id, user_id, unit_amount)['value']
if r.rate_id.id:
res['value']['to_invoice'] = r.rate_id.id
return res
def on_change_journal_id(self, cr, uid, ids,journal_id, account_id):
def on_change_journal_id(self, cr, uid, ids, journal_id, account_id):
res = {}
if not (journal_id and account_id):
return res

View File

@ -28,9 +28,9 @@ class analytic_user_funct_grid(osv.osv):
_name="analytic_user_funct_grid"
_description= "Relation table between users and products on a analytic account"
_columns={
'user_id': fields.many2one("res.users","User",required=True,),
'product_id': fields.many2one("product.product","Product",required=True,),
'account_id': fields.many2one("account.analytic.account", "Analytic Account",required=True,),
'user_id': fields.many2one("res.users", "User", required=True,),
'product_id': fields.many2one("product.product", "Product", required=True,),
'account_id': fields.many2one("account.analytic.account", "Analytic Account", required=True,),
}
analytic_user_funct_grid()
@ -53,15 +53,15 @@ class hr_analytic_timesheet(osv.osv):
# Look in account, if no value for the user => look in parent until there is no more parent to look
# Take the first found... if nothing found => return False
def _get_related_user_account_recursiv(self,cr,uid,user_id,account_id):
def _get_related_user_account_recursiv(self, cr, uid, user_id, account_id):
temp=self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ])
account=self.pool.get('account.analytic.account').browse(cr,uid,account_id)
account=self.pool.get('account.analytic.account').browse(cr, uid, account_id)
if temp:
return temp
else:
if account.parent_id:
return self._get_related_user_account_recursiv(cr,uid,user_id,account.parent_id.id)
return self._get_related_user_account_recursiv(cr, uid, user_id, account.parent_id.id)
else:
return False
@ -74,19 +74,19 @@ class hr_analytic_timesheet(osv.osv):
return res
if not (user_id):
return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id)
return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id)
#get the browse record related to user_id and account_id
temp = self._get_related_user_account_recursiv(cr,uid,user_id,account_id)
temp = self._get_related_user_account_recursiv(cr, uid, user_id, account_id)
# temp = self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ])
if not temp:
#if there isn't any record for this user_id and account_id
return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id)
return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id)
else:
#get the old values from super and add the value from the new relation analytic_user_funct_grid
r = self.pool.get('analytic_user_funct_grid').browse(cr, uid, temp)[0]
res.setdefault('value',{})
res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id)['value']
res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id)['value']
res['value']['product_id'] = r.product_id.id
res['value']['product_uom_id'] = r.product_id.product_tmpl_id.uom_id.id
@ -108,19 +108,19 @@ class hr_analytic_timesheet(osv.osv):
res ['value']['general_account_id']= a
return res
def on_change_user_id(self, cr, uid, ids,user_id, account_id, unit_amount=0):
def on_change_user_id(self, cr, uid, ids, user_id, account_id, unit_amount=0):
res = {}
if not (user_id):
#avoid a useless call to super
return res
#get the old values from super
res = super(hr_analytic_timesheet, self).on_change_user_id(cr, uid, ids,user_id)
res = super(hr_analytic_timesheet, self).on_change_user_id(cr, uid, ids, user_id)
if account_id:
#get the browse record related to user_id and account_id
# temp = self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ])
temp = self._get_related_user_account_recursiv(cr,uid,user_id,account_id)
temp = self._get_related_user_account_recursiv(cr, uid, user_id, account_id)
if temp:
#add the value from the new relation analytic_user_funct_grid
r = self.pool.get('analytic_user_funct_grid').browse(cr, uid, temp)[0]

View File

@ -34,7 +34,7 @@ class auction_artists(osv.osv):
_columns = {
'name': fields.char('Artist/Author Name', size=64, required=True),
'pseudo': fields.char('Pseudo', size=64),
'birth_death_dates':fields.char('Birth / Death dates',size=64),
'birth_death_dates':fields.char('Birth / Death dates', size=64),
'biography': fields.text('Biography'),
}
auction_artists()
@ -45,7 +45,7 @@ auction_artists()
class auction_dates(osv.osv):
_name = "auction.dates"
def _adjudication_get(self, cr, uid, ids, prop, unknow_none,unknow_dict):
def _adjudication_get(self, cr, uid, ids, prop, unknow_none, unknow_dict):
tmp={}
for id in ids:
tmp[id]=0.0
@ -97,15 +97,21 @@ class auction_dates(osv.osv):
# objects vendus mais non factures
#TODO: convert this query to tiny API
lots_obj = self.pool.get('auction.lots')
cr.execute('select count(*) as c from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',))
cr.execute('select count(*) as c from auction_lots where auction_id IN %s and state=%s and obj_price>0', (tuple(ids),'draft',))
cr.execute('SELECT COUNT(*) AS c '
'FROM auction_lots '
'WHERE auction_id IN %s '
'AND state=%s AND obj_price>0', (tuple(ids), 'draft'))
nbr = cr.fetchone()[0]
ach_uids = {}
cr.execute('select id from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',))
cr.execute('SELECT id FROM auction_lots '
'WHERE auction_id IN %s '
'AND state=%s AND obj_price>0', (tuple(ids), 'draft'))
r = lots_obj.lots_invoice(cr, uid, [x[0] for x in cr.fetchall()],{},None)
cr.execute('select id from auction_lots where auction_id =ANY(%s) and obj_price>0',(ids,))
cr.execute('select id from auction_lots where auction_id IN %s and obj_price>0',(tuple(ids),))
ids2 = [x[0] for x in cr.fetchall()]
# for auction in auction_ids:
c = lots_obj.seller_trans_create(cr, uid, ids2,{})
c = lots_obj.seller_trans_create(cr, uid, ids2, {})
self.write(cr, uid, ids, {'state':'closed'}) #close the auction
return True
auction_dates()
@ -115,7 +121,9 @@ auction_dates()
# Deposits
#----------------------------------------------------------
def _inv_uniq(cr, ids):
cr.execute('select name from auction_deposit where id =ANY(%s)',(ids,))
cr.execute('SELECT id FROM auction_lots '
'WHERE auction_id IN %s '
'AND obj_price>0', (tuple(ids),))
for datas in cr.fetchall():
cr.execute('select count(*) from auction_deposit where name=%s', (datas[0],))
if cr.fetchone()[0]>1:
@ -231,7 +239,9 @@ def _type_get(self, cr, uid,ids):
# Lots
#----------------------------------------------------------
def _inv_constraint(cr, ids):
cr.execute('select id, bord_vnd_id, lot_num from auction_lots where id =ANY(%s)', (ids,))
cr.execute('SELECT id, bord_vnd_id, lot_num FROM auction_lots '
'WHERE id IN %s',
(tuple(ids),))
for datas in cr.fetchall():
cr.execute('select count(*) from auction_lots where bord_vnd_id=%s and lot_num=%s', (datas[1],datas[2]))
if cr.fetchone()[0]>1:

View File

@ -26,9 +26,9 @@ class report_artistlot(report_int):
def __init__(self, name):
report_int.__init__(self, name)
def create(self,cr, uid, ids, datas, context):
def create(self, cr, uid, ids, datas, context):
service = netsvc.LocalService("object_proxy")
lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', ids, ['artist_id'])
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['artist_id'])
artists = []
for lot in lots:
if lot['artist_id'] and lot['artist_id'] not in artists:
@ -40,7 +40,7 @@ class report_artistlot(report_int):
datas['ids'] = artists
self._obj_report = netsvc.LocalService('report.report.auction.artists')
return self._obj_report.create(cr,uid, artists, datas, context)
return self._obj_report.create(cr, uid, artists, datas, context)
def result(self):
return self._obj_report.result()

View File

@ -27,7 +27,7 @@ class auction_invoice(report_int):
report_int.__init__(self, name)
def create(self,cr, uid, ids, datas, context):
lots = self.pool.get('auction.lots').read(cr,uid, ids, ['ach_inv_id'], context=context)
lots = self.pool.get('auction.lots').read(cr, uid, ids, ['ach_inv_id'], context=context)
invoices = {}
for l in lots:
@ -40,7 +40,7 @@ class auction_invoice(report_int):
datas['ids'] = new_ids
self._obj_invoice = netsvc.LocalService('report.account.invoice')
return self._obj_invoice.create(cr,uid, new_ids, datas, context)
return self._obj_invoice.create(cr, uid, new_ids, datas, context)
def result(self):
return self._obj_invoice.result()

View File

@ -28,19 +28,8 @@ class auction_objects(report_sxw.rml_parse):
super(auction_objects, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
#'lines': self.lines
#'get_data' : self.get_data
})
# def lines(self, auction_id):
#
# cr.execute('select ad.name from auction_dates ad, a1uction_lots al where ad.id=al.%d group by ad.name',(auction_id))
# return self.cr.fetchone()[0]
# def get_data(self, auction_id):
# res = self.pool.get('auction.bid.lines').read(self.cr,self.uid,[lot_id])
# return True
report_sxw.report_sxw('report.auction.objects', 'auction.lots', 'addons/auction/report/auction_objects.rml', parser=auction_objects)

View File

@ -54,62 +54,65 @@ class auction_total_rml(report_sxw.rml_parse):
for lot_id in objects:
auc_lot_ids.append(lot_id.id)
self.total_obj=auc_lot_ids
self.cr.execute('select auction_id from auction_lots where id =ANY(%s) group by auction_id',(auc_lot_ids,))
self.cr.execute('SELECT auction_id FROM auction_lots '
'WHERE id IN %s '
'GROUP BY auction_id',
(tuple(auc_lot_ids),))
auc_date_ids = self.cr.fetchall()
auct_dat=[]
for ad_id in auc_date_ids:
auc_dates_fields = self.pool.get('auction.dates').read(self.cr,self.uid,ad_id[0],['name','auction1','id'])
auc_dates_fields = self.pool.get('auction.dates').read(self.cr, self.uid, ad_id[0], ['name','auction1','id'])
auct_dat.append(auc_dates_fields)
return auct_dat
def sum_taxes(self,auction_id):
self.cr.execute("select count(1) from auction_lots where id =ANY(%s) and auction_id=%s group by auction_id ", (self.total_obj,auction_id,))
self.cr.execute("select count(1) from auction_lots where id IN %s and auction_id=%s group by auction_id ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return res[0]
def sold_item(self, object_id):
self.cr.execute("select count(1) from auction_lots where id =ANY(%s) and auction_id=%s and state in ('unsold') ", (self.total_obj,object_id,))
self.cr.execute("select count(1) from auction_lots where id IN %s and auction_id=%s and state IN ('unsold') ", (tuple(self.total_obj),object_id,))
res = self.cr.fetchone()
return str(res[0])
def sum_buyer(self, auction_id):
self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and (ach_uid is not null or ach_login is not null) ", (self.total_obj,auction_id,))
self.cr.execute("select count(*) from auction_lots where id IN %s and auction_id=%s and (ach_uid is not null or ach_login is not null) ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0])
def sum_seller(self, auction_id):
self.cr.execute("select count(distinct bord_vnd_id) from auction_lots where id =ANY(%s) and auction_id=%s AND bord_vnd_id is not null ", (self.total_obj,auction_id,))
self.cr.execute("select count(distinct bord_vnd_id) from auction_lots where id IN %s and auction_id=%s AND bord_vnd_id is not null ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return res[0]
def sum_adj(self, auction_id):
self.cr.execute("select sum(obj_price) from auction_lots where id =ANY(%s) and auction_id=%s ", (self.total_obj,auction_id,))
self.cr.execute("select sum(obj_price) from auction_lots where id IN %s and auction_id=%s ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0])
def count_take(self, auction_id):
self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and ach_emp='True' ", (self.total_obj,auction_id,))
self.cr.execute("select count(*) from auction_lots where id IN %s and auction_id=%s and ach_emp='True' ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0])
def chek_paid(self, auction_id):
self.cr.execute("select count(1) from auction_lots where id =ANY(%s) and auction_id=%s and ((paid_ach='T') or (is_ok='T')) ", (self.total_obj,auction_id,))
self.cr.execute("select count(1) from auction_lots where id IN %s and auction_id=%s and ((paid_ach='T') or (is_ok='T')) ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0])
def check_paid_seller(self,auction_id):
self.cr.execute("select sum(seller_price) from auction_lots where id =ANY(%s) and auction_id=%s and paid_vnd != 'T' ", (self.total_obj,auction_id,))
self.cr.execute("select sum(seller_price) from auction_lots where id IN %s and auction_id=%s and paid_vnd != 'T' ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0]) or 0.0
def sum_credit(self,auction_id):
self.cr.execute("select sum(buyer_price) from auction_lots where id =ANY(%s) and auction_id=%s", (self.total_obj,auction_id,))
self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0])
def sum_debit_buyer(self,auction_id):
self.cr.execute("select sum(buyer_price) from auction_lots where id =ANY(%s) and auction_id=%s", (self.total_obj,auction_id,))
self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0] or 0)
@ -121,27 +124,27 @@ class auction_total_rml(report_sxw.rml_parse):
def sum_credit_seller(self, object_id):
self.cr.execute("select sum(seller_price) from auction_lots where id =ANY(%s) and auction_id=%s", (self.total_obj,object_id,))
self.cr.execute("select sum(seller_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),object_id,))
res = self.cr.fetchone()
return str(res[0] or 0)
def sum_minadj(self, auction_id):
self.cr.execute('select sum(lot_est1) from auction_lots where id =ANY(%s) and auction_id=%s', (self.total_obj,auction_id,))
self.cr.execute('select sum(lot_est1) from auction_lots where id IN %s and auction_id=%s', (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0]) or 0
def sum_maxadj(self, auction_id):
self.cr.execute('select sum(lot_est2) from auction_lots where id =ANY(%s) and auction_id=%s', (self.total_obj,auction_id,))
self.cr.execute('select sum(lot_est2) from auction_lots where id IN %s and auction_id=%s', (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0]) or 0
def sum_buyer_paid(self, auction_id):
self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and state = 'paid' ", (self.total_obj,auction_id,))
self.cr.execute("select count(*) from auction_lots where id IN %s and auction_id=%s and state = 'paid' ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0])
def count_comm(self, auction_id):
self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and obj_comm is not null ", (self.total_obj,auction_id,))
self.cr.execute("select count(*) from auction_lots where id IN %s and auction_id=%s and obj_comm is not null ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone()
return str(res[0])

View File

@ -44,7 +44,7 @@ class buyer_form_report(report_sxw.rml_parse):
taxes.append(lot.author_right)
if lot.auction_id:
taxes += lot.auction_id.buyer_costs
tax=self.pool.get('account.tax').compute(self.cr,self.uid,taxes,lot.obj_price,1)
tax=self.pool.get('account.tax').compute(self.cr, self.uid, taxes, lot.obj_price, 1)
for t in tax:
amount+=t['amount']
return amount
@ -55,7 +55,7 @@ class buyer_form_report(report_sxw.rml_parse):
for object in objects:
partner = ret_dict.get(object.ach_uid.id,False)
if not partner:
ret_dict[object.ach_uid.id] = {'partner' : object.ach_uid or False,'lots':[object]}
ret_dict[object.ach_uid.id] = {'partner' : object.ach_uid or False, 'lots':[object]}
else:
lots = partner.get('lots')
lots.append(object)

View File

@ -43,22 +43,23 @@ class buyer_list(report_sxw.rml_parse):
'sum_lots':self.sum_lots
})
def lines_lots_from_auction(self,objects):
def lines_lots_from_auction(self, objects):
auc_lot_ids = []
for lot_id in objects:
auc_lot_ids.append(lot_id.id)
self.auc_lot_ids=auc_lot_ids
self.cr.execute('select auction_id from auction_lots where id =ANY(%s) group by auction_id',(auc_lot_ids,))
self.cr.execute('SELECT auction_id FROM auction_lots WHERE id IN %s GROUP BY auction_id',
(tuple(auc_lot_ids),))
auc_date_ids = self.cr.fetchall()
auct_dat=[]
for ad_id in auc_date_ids:
auc_dates_fields = self.pool.get('auction.dates').read(self.cr,self.uid,ad_id[0],['name'])
auc_dates_fields = self.pool.get('auction.dates').read(self.cr, self.uid, ad_id[0], ['name'])
self.cr.execute('select * from auction_buyer_taxes_rel abr,auction_dates ad where ad.id=abr.auction_id and ad.id=%s', (ad_id[0],))
res=self.cr.fetchall()
total=0
for r in res:
buyer_rel_field = self.pool.get('account.tax').read(self.cr,self.uid,r[1],['amount'])
buyer_rel_field = self.pool.get('account.tax').read(self.cr, self.uid, r[1], ['amount'])
total = total + buyer_rel_field['amount']
auc_dates_fields['amount']=total
auct_dat.append(auc_dates_fields)
@ -67,15 +68,18 @@ class buyer_list(report_sxw.rml_parse):
def lines_lots_auct_lot(self,obj):
auc_lot_ids = []
auc_date_ids = self.pool.get('auction.dates').search(self.cr,self.uid,([('name','like',obj['name'])]))
auc_date_ids = self.pool.get('auction.dates').search(self.cr, self.uid, ([('name','like',obj['name'])]))
# self.cr.execute('select ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%s and ach_uid is not null group by ach_uid ', (auc_date_ids[0],))
self.cr.execute('select ach_login as ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id =ANY(%s) and auction_id=%s and ach_login is not null group by ach_login order by ach_login', (self.auc_lot_ids,auc_date_ids[0],))
self.cr.execute('SELECT ach_login AS ach_uid, COUNT(1) AS no_lot, '\
'SUM(obj_price) AS adj_price, '\
'SUM(buyer_price)-SUM(obj_price) AS buyer_cost, '\
'SUM(buyer_price) AS to_pay '\
'FROM auction_lots WHERE id IN %s '\
'AND auction_id=%s AND ach_login IS NOT NULL '\
'GROUP BY ach_login ORDER BY ach_login',
(tuple(self.auc_lot_ids), auc_date_ids[0],))
res = self.cr.dictfetchall()
for r in res:
# if r['ach_uid']:
# tnm=self.pool.get('res.partner').read(self.cr,self.uid,[r['ach_uid']],['name'])#
# r.__setitem__('ach_uid',tnm[0]['name'])
self.sum_adj_price_val = self.sum_adj_price_val + r['adj_price']
self.sum_buyer_obj_price_val = self.sum_buyer_obj_price_val + r['buyer_cost']
self.sum_buyer_price_val = self.sum_buyer_price_val + r['to_pay']

View File

@ -69,7 +69,7 @@ class auction_catalog(report_rml):
temp=self.post_process_xml_data(cr, uid, xml, context)
return temp
def catalog_xml(self,cr,uid,ids,data,context,cwid="0"):
def catalog_xml(self, cr, uid, ids, data, context, cwid="0"):
impl = minidom.getDOMImplementation()
doc = impl.createDocument(None, "report", None)
@ -84,10 +84,10 @@ class auction_catalog(report_rml):
tab_no_photo=[]
for id in ids:
lot_ids=pooler.get_pool(cr.dbname).get('auction.lots').search(cr, uid, [('auction_id', '=', id)])
ab=pooler.get_pool(cr.dbname).get('auction.lots').read(cr,uid,lot_ids,['auction_id','name','lot_num','lot_est1','lot_est2'],context)
ab=pooler.get_pool(cr.dbname).get('auction.lots').read(cr, uid, lot_ids, ['auction_id','name','lot_num','lot_est1','lot_est2'], context)
auction_dates_ids = [x["auction_id"][0] for x in ab]
res=pooler.get_pool(cr.dbname).get('auction.dates').read(cr,uid,ids,['name','auction1','auction2'],context)
res=pooler.get_pool(cr.dbname).get('auction.dates').read(cr, uid, ids, ['name','auction1','auction2'], context)
# name emelment
key = 'name'
categ = doc.createElement(key)
@ -126,7 +126,7 @@ class auction_catalog(report_rml):
for test in ab:
if test.has_key('auction_id'):
auction_ids.append(test['auction_id'][0])
cr.execute('select * from auction_lots where auction_id =ANY(%s)',(auction_ids,))
cr.execute('select * from auction_lots where auction_id IN %s',(tuple(auction_ids),))
res = cr.dictfetchall()
for cat in res:
product =doc.createElement('product')

View File

@ -31,7 +31,7 @@ class lots_list(report_sxw.rml_parse):
'bid_line' : self.bid_line
})
def bid_line(self, lot_id):
res = self.pool.get('auction.bid.lines').read(self.cr,self.uid,[lot_id])
res = self.pool.get('auction.bid.lines').read(self.cr, self.uid, [lot_id])
return True
report_sxw.report_sxw('report.lots.list', 'auction.lots', 'addons/auction/report/lots_list.rml', parser=lots_list)

View File

@ -26,9 +26,9 @@ class auction_seller(report_int):
def __init__(self, name):
report_int.__init__(self, name)
def create(self,cr, uid, ids, datas, context):
def create(self, cr, uid, ids, datas, context):
service = netsvc.LocalService("object_proxy")
lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', ids, ['bord_vnd_id'])
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['bord_vnd_id'])
bords = {}
for l in lots:
@ -37,7 +37,7 @@ class auction_seller(report_int):
new_ids = bords.keys()
parts = {}
partners = service.execute(cr.dbname,uid, 'auction.deposit', 'read', new_ids, ['partner_id'])
partners = service.execute(cr.dbname, uid, 'auction.deposit', 'read', new_ids, ['partner_id'])
for l in partners:
if l['partner_id']:
parts[l['partner_id'][0]]=True
@ -48,7 +48,7 @@ class auction_seller(report_int):
datas['ids'] = new_ids
self._obj_invoice = netsvc.LocalService('report.res.partner.address')
return self._obj_invoice.create(cr,uid, new_ids, datas, context)
return self._obj_invoice.create(cr, uid, new_ids, datas, context)
def result(self):
return self._obj_invoice.result()

View File

@ -28,7 +28,7 @@ from osv import osv
class seller_form_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(seller_form_report, self).__init__(cr, uid, name, context=context)
lot=self.pool.get('auction.lots').browse(cr,uid,uid)
lot=self.pool.get('auction.lots').browse(cr, uid, uid)
#address=lot.bord_vnd_id.address_get(self.cr,self.uid,[partner.id])
# partner=lot.bord_vnd_id.partner_id
# address=partner.address and partner.address[0] or ""
@ -53,7 +53,7 @@ class seller_form_report(report_sxw.rml_parse):
taxes.append(lot.bord_vnd_id.tax_id)
elif lot.auction_id and lot.auction_id.seller_costs:
taxes += lot.auction_id.seller_costs
tax=self.pool.get('account.tax').compute(self.cr,self.uid,taxes,lot.obj_price,1)
tax=self.pool.get('account.tax').compute(self.cr, self.uid, taxes, lot.obj_price, 1)
for t in tax:
amount+=t['amount']
return amount

View File

@ -35,14 +35,14 @@ class report_custom(report_rml):
def __init__(self, name, table, tmpl, xsl):
report_rml.__init__(self, name, table, tmpl, xsl)
def create_xml(self,cr, uid, ids, datas, context={}):
def create_xml(self, cr, uid, ids, datas, context={}):
service = netsvc.LocalService("object_proxy")
# start_time = time.clock()
# lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', ids, ['obj_price','ach_pay_id','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id'])
lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', ids, ['obj_price','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id'])
auction = service.execute(cr.dbname,uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0]
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['obj_price','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id'])
auction = service.execute(cr.dbname, uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0]
# mid_time = time.clock()
@ -96,7 +96,7 @@ class report_custom(report_rml):
# mid_time3 = time.clock()
debit = adj
costs = service.execute(cr.dbname,uid, 'auction.lots', 'compute_seller_costs', ids)
costs = service.execute(cr.dbname, uid, 'auction.lots', 'compute_seller_costs', ids)
for cost in costs:
debit += cost['amount']

View File

@ -142,7 +142,7 @@ class auction_lots_send_aie(osv.osv_memory):
for (ref,id) in ids:
# ids_attach = service.execute(db_name,uid, 'ir.attachment', 'search', [('res_model','=','auction.lots'), ('res_id', '=',id)])
datas = service.execute(cr.db_name,uid, 'auction.lots', 'read',[id], ['name','image'])
datas = service.execute(cr.db_name, uid, 'auction.lots', 'read', [id], ['name','image'])
if len(datas):
bin = base64.decodestring(datas[0]['image'])
fname = datas[0]['name']

View File

@ -52,9 +52,9 @@ class auction_catalog_flagey(osv.osv_memory):
"""
lots_obj = self.pool.get('auction.lots')
auc_dates_obj = self.pool.get('auction.dates')
current_auction = auc_dates_obj.browse(cr,uid,context.get('active_ids', []))
v_lots = lots_obj.search(cr,uid,[('auction_id','=',current_auction.id)])
v_ids = lots_obj.browse(cr,uid,v_lots)
current_auction = auc_dates_obj.browse(cr, uid, context.get('active_ids', []))
v_lots = lots_obj.search(cr, uid, [('auction_id','=',current_auction.id)])
v_ids = lots_obj.browse(cr, uid, v_lots)
for ab in v_ids:
if not ab.auction_id :
raise osv.except_osv('Error!','No Lots belong to this Auction Date')

View File

@ -84,7 +84,7 @@ class wiz_auc_lots_buyer_map(osv.osv_memory):
"""
rec_ids = context and context.get('active_ids',False) or False
assert rec_ids, _('Active IDs not Found')
datas = self.read(cr, uid, ids[0],['ach_login','ach_uid'])
datas = self.read(cr, uid, ids[0], ['ach_login','ach_uid'])
lots_obj = self.pool.get('auction.lots')
recs = lots_obj.browse(cr, uid, rec_ids, context)
for rec in recs:

View File

@ -43,11 +43,11 @@ class auction_lots_cancel(osv.osv):
lots_obj = self.pool.get('auction.lots')
invoice_obj = self.pool.get('account.invoice')
lot = lots_obj.browse(cr,uid,context['active_id'],context)
lot = lots_obj.browse(cr, uid, context['active_id'], context)
if lot.ach_inv_id:
supplier_refund_inv_id = invoice_obj.refund(cr, uid,[lot.ach_inv_id.id])
supplier_refund_inv_id = invoice_obj.refund(cr, uid, [lot.ach_inv_id.id])
if lot.sel_inv_id:
customer_refund_inv_id = invoice_obj.refund(cr, uid,[lot.sel_inv_id.id])
customer_refund_inv_id = invoice_obj.refund(cr, uid, [lot.sel_inv_id.id])
return {}
_columns = {

View File

@ -50,7 +50,7 @@ class auction_lots_invoice(osv.osv_memory):
res = super(auction_lots_invoice, self).default_get(cr, uid, fields, context=context)
service = netsvc.LocalService("object_proxy")
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids', []))
auction = service.execute(cr.dbname,uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0]
auction = service.execute(cr.dbname, uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0]
price = 0.0
price_topay = 0.0

View File

@ -66,14 +66,14 @@ class auction_transfer_unsold_object(osv.osv):
bid_line_obj = self.pool.get('auction.bid_line')
lots_obj = self.pool.get('auction.lots')
lot_history_obj = self.pool.get('auction.lot.history')
line_ids= bid_line_obj.search(cr,uid,[('lot_id','in',context['active_ids'])])
line_ids= bid_line_obj.search(cr, uid, [('lot_id','in',context['active_ids'])])
bid_line_obj.unlink(cr, uid, line_ids)
res = self.browse(cr, uid, ids)
unsold_ids = lots_obj.search(cr,uid,[('auction_id','=',res[0].auction_id_from.id),('state','=','unsold')])
for rec in lots_obj.browse(cr, uid, unsold_ids, context):
new_id = lot_history_obj.create(cr,uid,{'auction_id':rec.auction_id.id,'lot_id':rec.id,'price': rec.obj_ret, 'name': rec.auction_id.auction1})
up_auction = lots_obj.write(cr,uid,[rec.id],{'auction_id': res[0].auction_id_to.id,
new_id = lot_history_obj.create(cr, uid, {'auction_id':rec.auction_id.id,'lot_id':rec.id,'price': rec.obj_ret, 'name': rec.auction_id.auction1})
up_auction = lots_obj.write(cr, uid, [rec.id], {'auction_id': res[0].auction_id_to.id,
'obj_ret':None,
'obj_price':None,
'ach_login':None,

View File

@ -59,18 +59,18 @@ class res_partner_contact(osv.osv):
return res
_columns = {
'name': fields.char('Last Name', size=30,required=True),
'name': fields.char('Last Name', size=30, required=True),
'first_name': fields.char('First Name', size=30),
'mobile': fields.char('Mobile',size=30),
'mobile': fields.char('Mobile', size=30),
'title': fields.selection(_title_get, 'Title'),
'website': fields.char('Website',size=120),
'lang_id': fields.many2one('res.lang','Language'),
'job_ids': fields.one2many('res.partner.job','contact_id','Functions and Addresses'),
'website': fields.char('Website', size=120),
'lang_id': fields.many2one('res.lang', 'Language'),
'job_ids': fields.one2many('res.partner.job', 'contact_id', 'Functions and Addresses'),
'country_id': fields.many2one('res.country','Nationality'),
'birthdate': fields.date('Birth Date'),
'active': fields.boolean('Active', help="If the active field is set to true,\
it will allow you to hide the partner contact without removing it."),
'partner_id': fields.related('job_ids','address_id','partner_id',type='many2one',\
'partner_id': fields.related('job_ids', 'address_id', 'partner_id', type='many2one',\
relation='res.partner', string='Main Employer'),
'function': fields.related('job_ids', 'function', type='char', \
string='Main Function'),

View File

@ -61,7 +61,7 @@ This test checks the speed of the module. Note that at least 5 demo data is need
# remove osv_memory class becaz it does not have demo data
if obj_list:
cr.execute("select w.res_model from ir_actions_todo as t left join ir_act_window as w on t.action_id=w.id where w.res_model =ANY(%s)",(obj_list,))
cr.execute("select w.res_model from ir_actions_todo as t left join ir_act_window as w on t.action_id=w.id where w.res_model IN %s",(tuple(obj_list),))
res = cr.fetchall()
print res
for remove_obj in res:

View File

@ -465,7 +465,7 @@ class crm_case_section(osv.osv):
level = 100
while len(ids):
cr.execute('select distinct parent_id from crm_case_section where id =ANY(%s)', (ids,))
cr.execute('select distinct parent_id from crm_case_section where id IN %s', (tuple(ids),))
ids = filter(None, map(lambda x: x[0], cr.fetchall()))
if not level:
return False

View File

@ -69,7 +69,7 @@ class report_custom(report_int):
cr.execute('select probability, planned_revenue, planned_cost, user_id,\
res_users.name as name from crm_case left join res_users on \
(crm_case.user_id=res_users.id) where crm_case.id =ANY(%s) order by user_id',(ids,))
(crm_case.user_id=res_users.id) where crm_case.id IN %s order by user_id',(tuple(ids),))
res = cr.dictfetchall()
for row in res:

View File

@ -33,17 +33,17 @@ def _get_answers(cr, uid, ids):
query = """
select distinct(answer)
from profile_question_yes_rel
where profile=ANY(%s)"""
where profile IN %s"""
cr.execute(query, (ids,))
cr.execute(query, (tuple(ids),))
ans_yes = [x[0] for x in cr.fetchall()]
query = """
select distinct(answer)
from profile_question_no_rel
where profile=ANY(%s)"""
where profile IN %s"""
cr.execute(query, (ids,))
cr.execute(query, (tuple(ids),))
ans_no = [x[0] for x in cr.fetchall()]
return [ans_yes, ans_no]
@ -61,7 +61,7 @@ def _get_parents(cr, uid, ids):
select distinct(parent_id)
from crm_segmentation
where parent_id is not null
and id=ANY(%s)""",(ids,))
and id IN %s""",(tuple(ids),))
parent_ids = [x[0] for x in cr.fetchall()]

View File

@ -27,7 +27,7 @@ class NhException(Exception):
from subprocess import Popen, PIPE
class indexer():
class indexer(object):
""" An indexer knows how to parse the content of some file.
Typically, one indexer should be instantiated per file
@ -43,7 +43,7 @@ class indexer():
def _getExtensions(self):
return []
def _getDefMime(self,ext):
def _getDefMime(self, ext):
""" Return a mimetype for this document type, ideally the
closest to the extension ext. """
mts = self._getMimeTypes();
@ -51,7 +51,7 @@ class indexer():
return mts[0]
return None
def indexContent(self,content,filename=None, realfile = None):
def indexContent(self, content, filename=None, realfile = None):
""" Use either content or the real file, to index.
Some parsers will work better with the actual
content, others parse a file easier. Try the
@ -111,7 +111,7 @@ def mime_match(mime, mdict):
return (None, None)
class contentIndex():
class contentIndex(object):
__logger = logging.getLogger('addons.document.content_index')
def __init__(self):
self.mimes = {}
@ -132,7 +132,7 @@ class contentIndex():
if not f:
raise Exception("Your indexer should at least suport a mimetype or extension")
def doIndex(self,content, filename=None, content_type=None, realfname = None, debug=False):
def doIndex(self, content, filename=None, content_type=None, realfname = None, debug=False):
fobj = None
fname = None
mime = None

View File

@ -35,10 +35,10 @@ class ir_action_report_xml(osv.osv):
def _model_get(self, cr, uid, ids, name, arg, context):
res = {}
model_pool = self.pool.get('ir.model')
for data in self.read(cr,uid,ids,['model']):
for data in self.read(cr, uid, ids, ['model']):
model = data.get('model',False)
if model:
model_id =model_pool.search(cr,uid,[('model','=',model)])
model_id =model_pool.search(cr, uid, [('model','=',model)])
if model_id:
res[data.get('id')] = model_id[0]
else:
@ -51,14 +51,14 @@ class ir_action_report_xml(osv.osv):
model_id= args[0][2]
if not model_id:
return []
model = self.pool.get('ir.model').read(cr,uid,[model_id])[0]['model']
report_id = self.search(cr,uid,[('model','=',model)])
model = self.pool.get('ir.model').read(cr, uid, [model_id])[0]['model']
report_id = self.search(cr, uid, [('model','=',model)])
if not report_id:
return [('id','=','0')]
return [('id','in',report_id)]
_columns={
'model_id' : fields.function(_model_get,fnct_search=_model_search,method=True,string='Model Id'),
'model_id' : fields.function(_model_get, fnct_search=_model_search, method=True, string='Model Id'),
}
ir_action_report_xml()

View File

@ -78,10 +78,10 @@ class document_directory(osv.osv):
return False
return objid.browse(cr, uid, mid, context=context).res_id
def _get_def_storage(self,cr,uid,context=None):
def _get_def_storage(self, cr, uid, context=None):
if context and context.has_key('default_parent_id'):
# Use the same storage as the parent..
diro = self.browse(cr,uid,context['default_parent_id'])
diro = self.browse(cr, uid, context['default_parent_id'])
if diro.storage_id:
return diro.storage_id.id
objid=self.pool.get('ir.model.data')
@ -119,7 +119,7 @@ class document_directory(osv.osv):
""" Return the full path to this directory, in a list, root first
"""
def _parent(dir_id, path):
parent=self.browse(cr,uid,dir_id)
parent=self.browse(cr, uid, dir_id)
if parent.parent_id and not parent.ressource_parent_type_id:
_parent(parent.parent_id.id,path)
path.append(parent.name)
@ -130,12 +130,12 @@ class document_directory(osv.osv):
_parent(dir_id, path)
return path
def ol_get_resource_path(self,cr,uid,dir_id,res_model,res_id):
def ol_get_resource_path(self, cr, uid, dir_id, res_model, res_id):
# this method will be used in process module
# to be need test and Improvement if resource dir has parent resource (link resource)
path=[]
def _parent(dir_id,path):
parent=self.browse(cr,uid,dir_id)
parent=self.browse(cr, uid, dir_id)
if parent.parent_id and not parent.ressource_parent_type_id:
_parent(parent.parent_id.id,path)
path.append(parent.name)
@ -144,10 +144,10 @@ class document_directory(osv.osv):
return path
directory=self.browse(cr,uid,dir_id)
model_ids=self.pool.get('ir.model').search(cr,uid,[('model','=',res_model)])
model_ids=self.pool.get('ir.model').search(cr, uid, [('model','=',res_model)])
if directory:
_parent(dir_id,path)
path.append(self.pool.get(directory.ressource_type_id.model).browse(cr,uid,res_id).name)
path.append(self.pool.get(directory.ressource_type_id.model).browse(cr, uid, res_id).name)
#user=self.pool.get('res.users').browse(cr,uid,uid)
#return "ftp://%s:%s@localhost:%s/%s/%s"%(user.login,user.password,config.get('ftp_server_port',8021),cr.dbname,'/'.join(path))
# No way we will return the password!
@ -195,7 +195,7 @@ class document_directory(osv.osv):
context['lang'] = lang
try: #just instrumentation
return nodes.get_node_context(cr, uid, context).get_uri(cr,uri)
return nodes.get_node_context(cr, uid, context).get_uri(cr, uri)
except Exception,e:
print "exception: ",e
raise
@ -235,15 +235,15 @@ class document_directory(osv.osv):
default ={}
name = self.read(cr, uid, [id])[0]['name']
default.update({'name': name+ " (copy)"})
return super(document_directory,self).copy(cr,uid,id,default,context)
return super(document_directory,self).copy(cr, uid, id, default, context)
def _check_duplication(self, cr, uid,vals,ids=[],op='create'):
def _check_duplication(self, cr, uid, vals, ids=[], op='create'):
name=vals.get('name',False)
parent_id=vals.get('parent_id',False)
ressource_parent_type_id=vals.get('ressource_parent_type_id',False)
ressource_id=vals.get('ressource_id',0)
if op=='write':
for directory in self.browse(cr,uid,ids):
for directory in self.browse(cr, uid, ids):
if not name:
name=directory.name
if not parent_id:
@ -261,12 +261,12 @@ class document_directory(osv.osv):
return False
return True
def write(self, cr, uid, ids, vals, context=None):
if not self._check_duplication(cr,uid,vals,ids,op='write'):
if not self._check_duplication(cr, uid, vals, ids, op='write'):
raise osv.except_osv(_('ValidateError'), _('Directory name must be unique!'))
return super(document_directory,self).write(cr,uid,ids,vals,context=context)
return super(document_directory,self).write(cr, uid, ids, vals, context=context)
def create(self, cr, uid, vals, context=None):
if not self._check_duplication(cr,uid,vals):
if not self._check_duplication(cr, uid, vals):
raise osv.except_osv(_('ValidateError'), _('Directory name must be unique!'))
if vals.get('name',False) and (vals.get('name').find('/')+1 or vals.get('name').find('@')+1 or vals.get('name').find('$')+1 or vals.get('name').find('#')+1) :
raise osv.except_osv(_('ValidateError'), _('Directory name contains special characters!'))

View File

@ -309,7 +309,7 @@ class document_storage(osv.osv):
if not fname:
return None
path = storage_bo.path
return ( storage_bo.id, 'file', os.path.join(path,fname))
return ( storage_bo.id, 'file', os.path.join(path, fname))
else:
raise TypeError("No %s storage" % boo.type)

View File

@ -42,7 +42,7 @@ import time
#
def get_node_context(cr, uid, context):
return node_context(cr,uid,context)
return node_context(cr, uid, context)
class node_context(object):
""" This is the root node, representing access to some particular
@ -60,7 +60,7 @@ class node_context(object):
def get_uri(self, cr, uri):
""" Although this fn passes back to doc.dir, it is needed since
it is a potential caching point """
(ndir, duri) = self._dirobj._locate_child(cr,self.uid, self.rootdir,uri, None, self)
(ndir, duri) = self._dirobj._locate_child(cr, self.uid, self.rootdir, uri, None, self)
while duri:
ndir = ndir.child(cr, duri[0])
if not ndir:
@ -158,7 +158,7 @@ class node_class(object):
return True
return False
def get_dav_eprop(self,cr,ns,prop):
def get_dav_eprop(self, cr, ns, prop):
return None
def rm(self, cr):
@ -205,19 +205,19 @@ class node_database(node_class):
where2 = where + domain + [('type', '=', 'directory')]
ids = dirobj.search(cr, uid, where2, context=ctx)
res = []
for dirr in dirobj.browse(cr,uid,ids,context=ctx):
res.append(node_dir(dirr.name,self,self.context,dirr))
for dirr in dirobj.browse(cr, uid, ids, context=ctx):
res.append(node_dir(dirr.name, self, self.context,dirr))
where2 = where + domain + [('type', '=', 'ressource'), ('ressource_parent_type_id','=',False)]
ids = dirobj.search(cr, uid, where2, context=ctx)
for dirr in dirobj.browse(cr,uid,ids,context=ctx):
res.append(node_res_dir(dirr.name,self,self.context,dirr))
for dirr in dirobj.browse(cr, uid, ids, context=ctx):
res.append(node_res_dir(dirr.name, self, self.context, dirr))
fil_obj = dirobj.pool.get('ir.attachment')
ids = fil_obj.search(cr,uid,where,context=ctx)
ids = fil_obj.search(cr, uid, where, context=ctx)
if ids:
for fil in fil_obj.browse(cr,uid,ids,context=ctx):
res.append(node_file(fil.name,self,self.context,fil))
for fil in fil_obj.browse(cr, uid, ids, context=ctx):
res.append(node_file(fil.name, self, self.context, fil))
return res
def _file_get(self,cr, nodename=False, directory_id=False):
@ -241,7 +241,7 @@ class node_database(node_class):
class node_dir(node_database):
our_type = 'collection'
def __init__(self,path, parent, context, dirr, dctx=None):
def __init__(self, path, parent, context, dirr, dctx=None):
super(node_dir,self).__init__(path, parent,context)
self.dir_id = dirr and dirr.id or False
#todo: more info from dirr
@ -269,7 +269,7 @@ class node_dir(node_database):
pass
def get_data(self,cr):
def get_data(self, cr):
res = ''
for child in self.children(cr):
res += child.get_data(cr)
@ -277,7 +277,7 @@ class node_dir(node_database):
def _file_get(self,cr, nodename=False):
def _file_get(self, cr, nodename=False):
return super(node_dir,self)._file_get(cr, nodename, self.dir_id)
@ -320,7 +320,7 @@ class node_dir(node_database):
return dirobj.create(cr, uid, val)
def create_child(self,cr,path,data):
def create_child(self, cr, path, data):
""" API function to create a child file object and node
Return the node_* created
"""
@ -336,10 +336,10 @@ class node_dir(node_database):
# Datas are not set here
}
fil_id = fil_obj.create(cr,uid, val, context=ctx)
fil = fil_obj.browse(cr,uid,fil_id,context=ctx)
fnode = node_file(path,self,self.context,fil)
fnode.set_data(cr,data,fil)
fil_id = fil_obj.create(cr, uid, val, context=ctx)
fil = fil_obj.browse(cr, uid, fil_id, context=ctx)
fnode = node_file(path, self, self.context, fil)
fnode.set_data(cr, data, fil)
return fnode
def get_etag(self, cr):
@ -365,8 +365,8 @@ class node_res_dir(node_class):
node_dirs (with limited domain).
"""
our_type = 'collection'
def __init__(self,path, parent, context, dirr, dctx=None ):
super(node_res_dir,self).__init__(path, parent,context)
def __init__(self, path, parent, context, dirr, dctx=None ):
super(node_res_dir,self).__init__(path, parent, context)
self.dir_id = dirr.id
#todo: more info from dirr
self.mimetype = 'application/x-directory'
@ -400,7 +400,7 @@ class node_res_dir(node_class):
return res[0]
return None
def _child_get(self,cr, name = None, domain=None):
def _child_get(self, cr, name = None, domain=None):
""" return virtual children of resource, based on the
foreign object.
@ -409,7 +409,6 @@ class node_res_dir(node_class):
"""
obj = self.context._dirobj.pool.get(self.res_model)
if not obj:
print "couldn't find model", self.res_model
return []
dirobj = self.context._dirobj
uid = self.context.uid
@ -432,12 +431,12 @@ class node_res_dir(node_class):
if obj._parent_name in obj.fields_get(cr, uid):
where.append((obj._parent_name,'=',object2 and object2.id or False))
resids = obj.search(cr,uid, where, context=ctx)
resids = obj.search(cr, uid, where, context=ctx)
res = []
for bo in obj.browse(cr,uid,resids,context=ctx):
for bo in obj.browse(cr, uid, resids, context=ctx):
if not bo:
continue
name = getattr(bo,self.namefield)
name = getattr(bo, self.namefield)
if not name:
continue
# Yes! we can't do better but skip nameless records.
@ -479,7 +478,7 @@ class node_res_obj(node_class):
dc2['this'] = res_bo
for fld,expr in self.dctx_dict.items():
try:
self.dctx[fld] = safe_eval(expr,dc2)
self.dctx[fld] = safe_eval(expr, dc2)
except Exception,e:
print "Cannot eval %s for %s" % (expr, fld)
print e
@ -490,11 +489,11 @@ class node_res_obj(node_class):
def children(self, cr, domain=None):
return self._child_get(cr, domain=domain) + self._file_get(cr)
def child(self,cr, name, domain=None):
def child(self, cr, name, domain=None):
res = self._child_get(cr, name, domain=domain)
if res:
return res[0]
res = self._file_get(cr,name)
res = self._file_get(cr, name)
if res:
return res[0]
return None
@ -509,9 +508,9 @@ class node_res_obj(node_class):
#if self.domain:
# where.extend(self.domain)
# print "res_obj file_get clause", where
ids = cntobj.search(cr,uid,where,context=ctx)
for content in cntobj.browse(cr,uid,ids,context=ctx):
res3 = cntobj._file_get(cr,self,nodename,content, context=ctx)
ids = cntobj.search(cr, uid, where, context=ctx)
for content in cntobj.browse(cr, uid, ids, context=ctx):
res3 = cntobj._file_get(cr, self, nodename, content, context=ctx)
if res3:
res.extend(res3)
@ -524,15 +523,15 @@ class node_res_obj(node_class):
ctx = self.context.context.copy()
ctx.update(self.dctx)
where = [('directory_id','=',self.dir_id) ]
ids = cntobj.search(cr,uid,where,context=ctx)
for content in cntobj.browse(cr,uid,ids,context=ctx):
ids = cntobj.search(cr, uid, where, context=ctx)
for content in cntobj.browse(cr, uid, ids, context=ctx):
if content.extension == '.ics': # FIXME: call the content class!
res['http://groupdav.org/'] = ('resourcetype',)
return res
def get_dav_eprop(self,cr,ns,prop):
def get_dav_eprop(self, cr, ns, prop):
if ns != 'http://groupdav.org/' or prop != 'resourcetype':
print "Who asked for %s:%s?" % (ns,prop)
print "Who asked for %s:%s?" % (ns, prop)
return None
res = {}
cntobj = self.context._dirobj.pool.get('document.directory.content')
@ -541,12 +540,12 @@ class node_res_obj(node_class):
ctx.update(self.dctx)
where = [('directory_id','=',self.dir_id) ]
ids = cntobj.search(cr,uid,where,context=ctx)
for content in cntobj.browse(cr,uid,ids,context=ctx):
for content in cntobj.browse(cr, uid, ids, context=ctx):
if content.extension == '.ics': # FIXME: call the content class!
return ('vevent-collection','http://groupdav.org/')
return None
def _child_get(self,cr, name=None, domain=None):
def _child_get(self, cr, name=None, domain=None):
dirobj = self.context._dirobj
uid = self.context.uid
ctx = self.context.context.copy()
@ -563,8 +562,8 @@ class node_res_obj(node_class):
where1 = []
if obj._parent_name in obj.fields_get(cr, uid):
where1 = where + [(obj._parent_name, '=', self.res_id)]
resids = obj.search(cr,uid, where1, context=ctx)
for bo in obj.browse(cr,uid,resids,context=ctx):
resids = obj.search(cr, uid, where1, context=ctx)
for bo in obj.browse(cr, uid, resids, context=ctx):
namefield = directory.resource_field.name or 'name'
if not bo:
continue
@ -634,7 +633,7 @@ class node_res_obj(node_class):
return dirobj.create(cr, uid, val)
def create_child(self,cr,path,data):
def create_child(self, cr, path, data):
""" API function to create a child file object and node
Return the node_* created
"""
@ -652,18 +651,18 @@ class node_res_obj(node_class):
# Datas are not set here
}
fil_id = fil_obj.create(cr,uid, val, context=ctx)
fil = fil_obj.browse(cr,uid,fil_id,context=ctx)
fnode = node_file(path,self,self.context,fil)
fnode.set_data(cr,data,fil)
fil_id = fil_obj.create(cr, uid, val, context=ctx)
fil = fil_obj.browse(cr, uid, fil_id, context=ctx)
fnode = node_file(path, self, self.context, fil)
fnode.set_data(cr, data, fil)
return fnode
def _get_ttag(self,cr):
return 'rodir-%d-%d' % (self.dir_id,self.res_id)
return 'rodir-%d-%d' % (self.dir_id, self.res_id)
class node_file(node_class):
our_type = 'file'
def __init__(self,path, parent, context, fil):
def __init__(self, path, parent, context, fil):
super(node_file,self).__init__(path, parent,context)
self.file_id = fil.id
#todo: more info from ir_attachment
@ -745,7 +744,7 @@ class node_file(node_class):
stor = data_obj.browse(cr, self.context.uid, data_id, context=self.context.context).res_id
assert stor
stobj = self.context._dirobj.pool.get('document.storage')
return stobj.get_data(cr,self.context.uid,stor, self,self.context.context, fil_obj)
return stobj.get_data(cr, self.context.uid,stor, self,self.context.context, fil_obj)
def get_data_len(self, cr, fil_obj = None):
# TODO: verify with the storage object!
@ -768,14 +767,14 @@ class node_file(node_class):
stor = data_obj.browse(cr, self.context.uid, data_id, context=self.context.context).res_id
assert stor
stobj = self.context._dirobj.pool.get('document.storage')
return stobj.set_data(cr,self.context.uid,stor, self, data, self.context.context, fil_obj)
return stobj.set_data(cr, self.context.uid,stor, self, data, self.context.context, fil_obj)
def _get_ttag(self,cr):
return 'file-%d' % self.file_id
class node_content(node_class):
our_type = 'content'
def __init__(self,path, parent, context, cnt, dctx = None, act_id=None):
def __init__(self, path, parent, context, cnt, dctx = None, act_id=None):
super(node_content,self).__init__(path, parent,context)
self.cnt_id = cnt.id
self.create_date = False
@ -799,7 +798,7 @@ class node_content(node_class):
res.name = self
return res
def fill_fields(self,cr,dctx = None):
def fill_fields(self, cr, dctx = None):
""" Try to read the object and fill missing fields, like mimetype,
dates etc.
This function must be different from the constructor, because
@ -817,7 +816,7 @@ class node_content(node_class):
cntobj = self.context._dirobj.pool.get('document.directory.content')
ctx = self.context.context.copy()
ctx.update(self.dctx)
data = cntobj.process_read(cr,self.context.uid,self,ctx)
data = cntobj.process_read(cr, self.context.uid, self, ctx)
if data:
self.content_length = len(data)
return data
@ -831,7 +830,7 @@ class node_content(node_class):
cntobj = self.context._dirobj.pool.get('document.directory.content')
ctx = self.context.context.copy()
ctx.update(self.dctx)
return cntobj.process_write(cr,self.context.uid,self, data,ctx)
return cntobj.process_write(cr, self.context.uid, self, data, ctx)
def _get_ttag(self,cr):
return 'cnt-%d%s' % (self.cnt_id,(self.act_id and ('-' + str(self.act_id))) or '')

View File

@ -44,7 +44,7 @@ class TxtIndex(indexer):
def _getExtensions(self):
return ['.txt', '.py']
def _doIndexContent(self,content):
def _doIndexContent(self, content):
return content
cntIndex.register(TxtIndex())
@ -56,7 +56,7 @@ class PptxIndex(indexer):
def _getExtensions(self):
return ['.pptx']
def _doIndexFile(self,fname):
def _doIndexFile(self, fname):
# pptx2txt.pl package not support in windows platform.
# Download pptx2txt package from http://sourceforge.net/projects/pptx2txt/" link.
# To install this tool, just copy pptx2txt.pl to appropriate place (e.g. /usr/bin directory)
@ -88,7 +88,7 @@ class DocxIndex(indexer):
def _getExtensions(self):
return ['.docx']
def _doIndexFile(self,fname):
def _doIndexFile(self, fname):
# docx2txt.pl package not support in windows platform.
# Download docx2txt package from "http://sourceforge.net/projects/docx2txt/" link.
# In case, you don't want to use Makefile for installation, you can follow these steps for manual installation.

Some files were not shown because too many files have changed in this diff Show More