bzr revid: hmo@tinyerp.com-20100618145602-hitjarz5yr5sbi6c
This commit is contained in:
Harry (OpenERP) 2010-06-18 20:26:02 +05:30
commit 9fd9c45e0b
920 changed files with 19382 additions and 56304 deletions

View File

@ -33,5 +33,4 @@ import product
import sequence
import company
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -23,7 +23,7 @@
{
"name" : "Accounting and Financial Management",
"version" : "1.1",
"depends" : ["product", "analytic", "process"],
"depends" : ["product", "analytic", "process","board"],
"author" : "Tiny",
"category": 'Generic Modules/Accounting',
"description": """Financial and accounting module that covers:
@ -34,10 +34,15 @@
Budgets
Customer and Supplier Invoices
Bank statements
Reconciliation process by partner
Creates a dashboards for accountants that includes:
* List of uninvoiced quotations
* Graph of aged receivables
* Graph of aged incomes
The processes like maintaining of general ledger is done through the defined financial Journals (entry move line or
grouping is maintained through journal) for a particular financial year and for preparation of vouchers there is a
module named account_voucherss
module named account_vouchers
""",
'website': 'http://www.openerp.com',
'init_xml': [],
@ -81,6 +86,7 @@ module named account_voucherss
'wizard/account_compare_account_balance_report_view.xml',
'wizard/account_third_party_ledger.xml',
'wizard/account_reconcile_view.xml',
'wizard/account_reconcile_partner_process_view.xml',
'wizard/account_automatic_reconcile_view.xml',
'project/wizard/project_account_analytic_line_view.xml',
'account_end_fy.xml',
@ -111,7 +117,8 @@ module named account_voucherss
'report/account_report_view.xml',
'report/account_analytic_report_view.xml',
'report/account_account_report_view.xml',
'report/account_analytic_entries_report_view.xml'
'report/account_analytic_entries_report_view.xml',
'board_account_view.xml',
],
'demo_xml': [
#'demo/price_accuracy00.yml',
@ -120,10 +127,19 @@ module named account_voucherss
'project/analytic_account_demo.xml',
'demo/account_minimal.xml',
'account_unit_test.xml',
'board_account_demo.xml',
],
'test': [
'test/account_customer_invoice.yml',
'test/account_supplier_invoice.yml',
'test/account_change_currency.yml',
'test/chart_of_account.yml',
'test/account_period_close.yml',
'test/account_fiscalyear_close_state.yml',
'test/account_invoice_state.yml',
'test/account_use_model.yml',
'test/account_validate_account_move.yml',
# 'test/account_fiscalyear_close.yml',
],
'installable': True,
'active': False,

View File

@ -18,21 +18,38 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import netsvc
from osv import fields, osv
import decimal_precision as dp
from tools.misc import currency
from tools.translate import _
import pooler
from datetime import datetime
from dateutil.relativedelta import relativedelta
from operator import itemgetter
import netsvc
import pooler
from osv import fields, osv
import decimal_precision as dp
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"
@ -62,7 +79,7 @@ class account_payment_term(osv.osv):
elif line.value == 'balance':
amt = round(amount, prec)
if amt:
next_date = datetime.strptime(date_ref, '%y-%m-%d') + relativedelta(days=line.days)
next_date = datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days)
if line.days2 < 0:
next_date += relativedelta(day=line.days2)
if line.days2 > 0:
@ -170,6 +187,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=[]
@ -229,65 +247,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 = {}
@ -392,8 +432,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
@ -509,8 +551,13 @@ class account_account(osv.osv):
def write(self, cr, uid, ids, vals, context=None):
if context is None:
context = {}
if 'company_id' in vals:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', ids)])
if move_lines:
raise osv.except_osv(_('Warning !'), _('You cannot modify Company of account as its related record exist in Entry Lines'))
if 'active' in vals and not vals['active']:
self._check_moves(cr, uid, ids, "write", context)
self._check_moves(cr, uid, ids, "write", context=context)
if 'type' in vals.keys():
self._check_allow_type_change(cr, uid, ids, vals['type'], context=context)
return super(account_account, self).write(cr, uid, ids, vals, context=context)
@ -557,42 +604,46 @@ class account_journal(osv.osv):
_name = "account.journal"
_description = "Journal"
_columns = {
'name': fields.char('Journal Name', size=64, required=True, translate=True),
'code': fields.char('Code', size=16),
'type': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True,
'name': fields.char('Journal Name', size=64, required=True, translate=True,help="Name of the journal"),
'code': fields.char('Code', size=16,required=True,help="Code of the journal"),
'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'),('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True,
help="Select 'Sale' for Sale journal to be used at the time of making invoice."\
" Select 'Purchase' for Purchase Journal to be used at the time of approving purchase order."\
" Select 'Cash' to be used at the time of making payment."\
" Select 'General' to be used at the time of stock input/output."\
" Select 'Situation' to be used at the time of making vouchers."),
'refund_journal': fields.boolean('Refund Journal', help='Fill this if the journal is to be used for refunds of invoices.'),
'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]),
'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the journal without removing it."),
'view_id': fields.many2one('account.journal.view', 'View', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells Open ERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."),
'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]"),
'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]"),
'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells Open ERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."),
'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]", help="It acts as a default account for credit amount"),
'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]", help="It acts as a default account for debit amount"),
'centralisation': fields.boolean('Centralised counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."),
'update_posted': fields.boolean('Allow Cancelling Entries'),
'update_posted': fields.boolean('Allow Cancelling Entries', help="Check this box if you want to allow the cancellation the entries related to this journal or of the invoice related to this journal"),
'group_invoice_lines': fields.boolean('Group invoice lines', help="If this box is checked, the system will try to group the accounting lines when generating them from invoices."),
'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="The sequence gives the display order for a list of journals", required=True),
'user_id': fields.many2one('res.users', 'User', help="The user responsible for this journal"),
'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'),
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want new account moves to pass through the \'draft\' state and instead goes directly to the \'posted state\' without any manual validation.'),
'company_id': fields.many2one('res.company', 'Company', required=True,select=1),
'company_id': fields.many2one('res.company', 'Company', required=True, select=1, help="Company related to this journal"),
'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \
help="The sequence used for invoice numbers in this journal."),
'allow_date':fields.boolean('Check Date not in the Period', help= 'If set to True then do not accept the entry if the entry date is not into the period dates'),
}
_defaults = {
'active': lambda *a: 1,
'user_id': lambda self,cr,uid,context: uid,
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
def write(self, cr, uid, ids, vals, context=None):
obj=[]
if 'company_id' in vals:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)])
if move_lines:
raise osv.except_osv(_('Warning !'), _('You cannot modify company of this journal as its related record exist in Entry Lines'))
return super(account_journal, self).write(cr, uid, ids, vals, context=context)
def create(self, cr, uid, vals, context={}):
journal_id = super(account_journal, self).create(cr, uid, vals, context)
# journal_name = self.browse(cr, uid, [journal_id])[0].code
@ -618,6 +669,15 @@ class account_journal(osv.osv):
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
return self.name_get(cr, user, ids, context=context)
def onchange_type(self, cr, uid, ids, type):
res={}
for line in self.browse(cr, uid, ids):
if type == 'situation':
res= {'value':{'centralisation': True}}
else:
res= {'value':{'centralisation': False}}
return res
account_journal()
class account_fiscalyear(osv.osv):
@ -711,7 +771,7 @@ class account_period(osv.osv):
'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True),
'state': fields.selection([('draft','Draft'), ('done','Done')], 'State', readonly=True,
help='When monthly periods are created. The state is \'Draft\'. At the end of monthly period it is in \'Done\' state.'),
'company_id': fields.many2one('res.company', 'Company', required=True)
'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True)
}
_defaults = {
'state': lambda *a: 'draft',
@ -784,6 +844,14 @@ class account_period(osv.osv):
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit)
return self.name_get(cr, user, ids, context=context)
def write(self, cr, uid, ids, vals, context=None):
obj=[]
if 'company_id' in vals:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('period_id', 'in', ids)])
if move_lines:
raise osv.except_osv(_('Warning !'), _('You cannot modify company of this period as its related record exist in Entry Lines'))
return super(account_period, self).write(cr, uid, ids, vals, context=context)
account_period()
class account_journal_period(osv.osv):
@ -809,7 +877,7 @@ class account_journal_period(osv.osv):
'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'State', required=True, readonly=True,
help='When journal period is created. The state is \'Draft\'. If a report is printed it comes to \'Printed\' state. When all transactions are done, it comes in \'Done\' state.'),
'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', string='Fiscal Year', type='many2one', relation='account.fiscalyear'),
'company_id' : fields.many2one('res.company', 'Company')
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company')
}
def _check(self, cr, uid, ids, context={}):
@ -883,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)
@ -982,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
@ -995,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={}):
@ -1114,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
@ -1268,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):
@ -1302,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']:
@ -1318,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'
@ -1366,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:
@ -1384,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'])
]
@ -1731,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 = {
@ -1741,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]
@ -1943,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."),
}
@ -1955,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'])
]
@ -1994,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
@ -2015,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])
@ -2036,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()
@ -2074,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'])
]
@ -2246,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={}):
@ -2259,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')
@ -2298,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
@ -2331,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,
@ -2369,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
@ -2385,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
@ -2421,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
@ -2500,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

@ -53,7 +53,7 @@
<notebook>
<page string="Line">
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.address_invoice_id, parent.currency_id, {'company_id': parent.company_id})"/>
<field name="uos_id"/>
<field name="uos_id" widget="selection" on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.address_invoice_id, parent.currency_id, {'company_id': parent.company_id})"/>
<field name="quantity"/>
<field name="price_unit"/>
<field name="discount"/>
@ -220,7 +220,8 @@
<field name="name"/>
<newline/>
<field name="origin" groups="base.group_extended"/>
<field colspan="4" domain="[('partner_id','=',partner_id)]" name="address_contact_id" groups="base.group_extended"/>
<field domain="[('partner_id','=',partner_id)]" name="address_contact_id" groups="base.group_extended"/>
<field name="user_id"/>
<field name="move_id"/>
<separator colspan="4" string="Additional Information"/>
<field colspan="4" name="comment" nolabel="1"/>
@ -404,7 +405,7 @@
<field name="view_id" ref="invoice_form"/>
<field name="act_window_id" ref="action_invoice_tree"/>
</record>
<menuitem name="Invoices" id="menu_finance_invoice" parent="account.menu_finance" sequence="2"/>
<!-- <menuitem name="Invoices" id="menu_finance_invoice" parent="account.menu_finance" sequence="2"/>-->
<record id="action_invoice_tree1" model="ir.actions.act_window">
<field name="name">Customer Invoices</field>
@ -427,10 +428,10 @@
<field name="view_id" ref="invoice_form"/>
<field name="act_window_id" ref="action_invoice_tree1"/>
</record>
<menuitem action="action_invoice_tree1" id="menu_action_invoice_tree1" parent="account.menu_finance_invoice"/>
<menuitem action="action_invoice_tree1" id="menu_action_invoice_tree1" parent="menu_finance_receivables"/>
<record id="action_invoice_tree2" model="ir.actions.act_window">
<field name="name">Supplier Invoices</field>
<field name="name">Vendor Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
@ -439,7 +440,7 @@
<field name="context">{'type':'in_invoice'}</field>
<field name="search_view_id" ref="view_account_invoice_filter"/>
</record>
<menuitem action="action_invoice_tree2" id="menu_action_invoice_tree2" parent="account.menu_finance_invoice"/>
<menuitem action="action_invoice_tree2" id="menu_action_invoice_tree2" parent="menu_finance_payables"/>
<record id="action_invoice_tree3" model="ir.actions.act_window">
<field name="name">Customer Refunds</field>
@ -465,10 +466,10 @@
<field name="act_window_id" ref="action_invoice_tree3"/>
</record>
<menuitem action="action_invoice_tree3" id="menu_action_invoice_tree3" parent="account.menu_finance_invoice"/>
<menuitem action="action_invoice_tree3" id="menu_action_invoice_tree3" parent="menu_finance_receivables"/>
<record id="action_invoice_tree4" model="ir.actions.act_window">
<field name="name">Supplier Refunds</field>
<field name="name">Vendor Refunds</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
@ -477,7 +478,7 @@
<field name="context">{'type':'in_refund'}</field>
<field name="search_view_id" ref="view_account_invoice_filter"/>
</record>
<menuitem action="action_invoice_tree4" id="menu_action_invoice_tree4" parent="account.menu_finance_invoice"/>
<menuitem action="action_invoice_tree4" id="menu_action_invoice_tree4" parent="menu_finance_payables"/>
<act_window domain="[('partner_id','=',active_id)]" id="act_res_partner_2_account_invoice_opened" name="Invoices" res_model="account.invoice" src_model="res.partner"/>

View File

@ -2,27 +2,51 @@
<openerp>
<data>
<menuitem icon="terp-account" id="menu_finance" name="Financial Management" sequence="1"/>
<menuitem id="menu_finance_receivables" name="Receivables" parent="menu_finance" sequence="2"/>
<menuitem id="menu_finance_payables" name="Payables" parent="menu_finance" sequence="3"/>
<menuitem id="menu_finance_bank_and_cash" name="Bank and Cash" parent="menu_finance" sequence="4"/>
<!-- <menuitem id="menu_accounting" name="Accounting" parent="menu_finance" sequence="5"/>-->
<menuitem id="menu_finance_periodical_processing" name="Periodical Processing" parent="menu_finance" sequence="8" groups="group_account_user"/>
<menuitem id="periodical_processing_journal_entries_validation" name="Journal Entries Validation" parent="menu_finance_periodical_processing"/>
<menuitem id="periodical_processing_reconciliation" name="Reconciliation" parent="menu_finance_periodical_processing"/>
<!-- <menuitem id="periodical_processing_recurrent_entries" name="Recurrent Entries" parent="menu_finance_periodical_processing"/>-->
<menuitem id="periodical_processing_invoicing" name="Invoicing" parent="menu_finance_periodical_processing"/>
<!-- <menuitem id="periodical_processing_end_of_period" name="End of Period" parent="menu_finance_periodical_processing"/>-->
<menuitem id="menu_finance_charts" name="Charts" parent="menu_finance" sequence="10"/>
<menuitem id="menu_finance_reporting" name="Reporting" parent="account.menu_finance" sequence="12"/>
<menuitem id="menu_finance_reporting_budgets" name="Budgets" parent="menu_finance_reporting"/>
<menuitem id="menu_generic_report" name="Management Reports" parent="menu_finance_reporting"/>
<menuitem id="menu_finance_legal_statement" name="Legal Reports" parent="menu_finance_reporting"/>
<menuitem id="menu_finance_management_belgian_reports" name="Belgian Reports" parent="menu_finance_reporting"/>
<menuitem id="menu_finance_configuration" name="Configuration" parent="menu_finance" sequence="13"/>
<menuitem id="menu_finance_accounting" name="Financial Accounting" parent="menu_finance_configuration"/>
<menuitem id="menu_analytic_accounting" name="Analytic Accounting" parent="menu_finance_configuration"/>
<menuitem id="menu_analytic" parent="menu_analytic_accounting" name="Accounts"/>
<menuitem id="menu_low_level" name="Low Level" parent="menu_finance_accounting"/>
<menuitem id="menu_configuration_misc" name="Miscelleanous" parent="menu_finance_configuration"/>
<menuitem id="base.menu_action_currency_form" parent="menu_configuration_misc" sequence="20"/>
<menuitem icon="terp-account" id="menu_finance" name="Financial Management" sequence="5"/>
<menuitem id="menu_finance_configuration" name="Configuration" parent="menu_finance" sequence="8"/>
<menuitem id="base.menu_action_currency_form" parent="menu_finance_configuration" sequence="20"/>
<menuitem id="menu_finance_accounting" name="Financial Accounting" parent="menu_finance_configuration"/>
<menuitem id="menu_analytic_accounting" name="Analytic Accounting" parent="menu_finance_configuration"/>
<!-- <menuitem id="menu_finance_configuration1" name="Configuration" parent="menu_finance" sequence="80"/>-->
<!-- <menuitem id="base.menu_action_currency_form" parent="menu_finance_configuration" sequence="20"/>-->
<!-- <menuitem id="menu_finance_accounting1" name="Financial Accounting" parent="menu_finance_configuration" sequence="80"/>-->
<!-- <menuitem id="menu_analytic_accounting1" name="Analytic Accounting" parent="menu_finance_configuration" sequence="80"/>-->
<menuitem id="menu_finance_reporting" name="Reporting" parent="account.menu_finance" sequence="7"/>
<menuitem id="menu_finance_generic_reporting" name="Generic Reporting" parent="account.menu_finance_reporting" sequence="1"/>
<menuitem id="menu_finance_legal_statement" name="Legal Statements" parent="account.menu_finance_reporting" sequence="2"/>
<menuitem id="menu_generic_report" name="Generic Reports" parent="account.menu_finance_legal_statement" sequence="8"/>
<!-- <menuitem id="menu_finance_reporting11" name="Reporting" parent="account.menu_finance" sequence="80"/>-->
<menuitem id="menu_finance_generic_reporting" name="Generic Reporting" parent="menu_finance_reporting" sequence="100"/>
<!-- <menuitem id="menu_finance_legal_statement1" name="Legal Statements" parent="account.menu_finance_reporting" sequence="200"/>-->
<!-- <menuitem id="menu_generic_report" name="Generic Reports" parent="account.menu_finance_legal_statement" sequence="8"/>-->
<menuitem id="menu_finance_entries" name="Accounting" parent="account.menu_finance" sequence="1"
<menuitem id="menu_finance_entries" name="Accounting" parent="menu_finance" sequence="1"
groups="group_account_user"/>
<menuitem id="account.menu_finance_recurrent_entries" name="Recurrent Entries" parent="account.menu_finance_entries" sequence="15"/>
<menuitem id="account.menu_finance_recurrent_entries" name="Recurrent Entries" parent="menu_finance_periodical_processing" sequence="15"/>
<menuitem id="menu_finance_periodical_processing" name="Periodical Processing" parent="account.menu_finance"
sequence="3"
groups="group_account_user"/>
<menuitem id="menu_account_end_year_treatments" name="End of Year Treatments" parent="account.menu_finance_periodical_processing" sequence="20"/>
<!-- <menuitem id="menu_finance_periodical_processing11" name="Periodical Processing" parent="account.menu_finance"-->
<!-- sequence="3"-->
<!-- groups="group_account_user"/>-->
<menuitem id="menu_account_end_year_treatments" name="End of Period" parent="menu_finance_periodical_processing"/>
<menuitem id="menu_finance_statistic_report_statement" name="Statistic Reports" parent="account.menu_finance_reporting" sequence="3"/>
<menuitem id="menu_finance_statistic_report_statement" name="Statistic Reports" parent="menu_finance_reporting" sequence="300"/>
</data>
</openerp>

View File

@ -18,13 +18,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from datetime import datetime
import netsvc
from osv import fields, osv
from tools.translate import _
from datetime import datetime
import decimal_precision as dp
import tools
@ -66,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)])
@ -87,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 "
@ -150,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
@ -298,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
@ -333,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')]
@ -433,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)
}
@ -469,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 = [
@ -498,9 +498,17 @@ class account_move_line(osv.osv):
return False
return True
def _check_company_id(self, cr, uid, ids):
lines = self.browse(cr, uid, ids)
for l in lines:
if l.company_id != l.account_id.company_id or l.company_id != l.period_id.company_id:
return False
return True
_constraints = [
(_check_no_view, 'You can not create move line on view account.', ['account_id']),
(_check_no_closed, 'You can not create move line on closed account.', ['account_id']),
(_check_company_id,'Company must be same for its related account and period.',['company_id'] ),
]
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
@ -569,11 +577,54 @@ class account_move_line(osv.osv):
# writeoff; entry generated for the difference between the lines
#
def reconcile_partial(self, cr, uid, ids, type='auto', context={}):
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context is None:
context = {}
if context and context.get('next_partner_only', False):
if not context.get('partner_id', False):
partner = self.get_next_partner_only(cr, uid, offset, context)
else:
partner = context.get('partner_id', False)
if not partner:
return []
args.append(('partner_id', '=', partner[0]))
return super(account_move_line, self).search(cr, uid, args, offset, limit, order, context, count)
def get_next_partner_only(self, cr, uid, offset=0, context=None):
cr.execute(
"""
SELECT p.id
FROM res_partner p
RIGHT JOIN (
SELECT l.partner_id as partner_id, SUM(l.debit) as debit, SUM(l.credit) as credit
FROM account_move_line l
LEFT JOIN account_account a ON (a.id = l.account_id)
LEFT JOIN res_partner p ON (l.partner_id = p.id)
WHERE a.reconcile IS TRUE
AND l.reconcile_id IS NULL
AND (p.last_reconciliation_date IS NULL OR l.date > p.last_reconciliation_date)
AND l.state <> 'draft'
GROUP BY l.partner_id
) AS s ON (p.id = s.partner_id)
ORDER BY p.last_reconciliation_date LIMIT 1 OFFSET %s""", (offset,)
)
return cr.fetchone()
def reconcile_partial(self, cr, uid, ids, type='auto', context=None):
merges = []
unmerge = []
total = 0.0
merges_rec = []
company_list = []
if context is None:
context = {}
for line in self.browse(cr, uid, ids, context=context):
if company_list and not line.company_id.id in company_list:
raise osv.except_osv(_('Warning !'), _('To reconcile the entries company should be the same for all entries'))
company_list.append(line.company_id.id)
for line in self.browse(cr, uid, ids, context):
if line.reconcile_id:
raise osv.except_osv(_('Warning'), _('Already Reconciled!'))
@ -587,6 +638,7 @@ class account_move_line(osv.osv):
else:
unmerge.append(line.id)
total += (line.debit or 0.0) - (line.credit or 0.0)
if not total:
res = self.reconcile(cr, uid, merges+unmerge, context=context)
return res
@ -597,13 +649,22 @@ class account_move_line(osv.osv):
self.pool.get('account.move.reconcile').reconcile_partial_check(cr, uid, [r_id] + merges_rec, context=context)
return True
def reconcile(self, cr, uid, ids, type='auto', writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False, context={}):
def reconcile(self, cr, uid, ids, type='auto', writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False, context=None):
lines = self.browse(cr, uid, ids, context=context)
unrec_lines = filter(lambda x: not x['reconcile_id'], lines)
credit = debit = 0.0
currency = 0.0
account_id = False
partner_id = False
if context is None:
context = {}
company_list = []
for line in self.browse(cr, uid, ids, context=context):
if company_list and not line.company_id.id in company_list:
raise osv.except_osv(_('Warning !'), _('To reconcile the entries company should be the same for all entries'))
company_list.append(line.company_id.id)
for line in unrec_lines:
if line.state <> 'valid':
raise osv.except_osv(_('Error'),
@ -620,10 +681,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):
@ -701,6 +763,11 @@ class account_move_line(osv.osv):
# because of the way the line_id are defined: (4, x, False)
for id in ids:
wf_service.trg_trigger(uid, 'account.move.line', id, cr)
if lines and lines[0]:
partner_id = lines[0].partner_id.id
if context and context.get('stop_reconcile', False):
self.pool.get('res.partner').write(cr, uid, [partner_id], {'last_reconciliation_date': time.strftime('%Y-%m-%d %H:%M:%S')})
return r_id
def view_header_get(self, cr, user, view_id, view_type, context):
@ -809,13 +876,14 @@ class account_move_line(osv.osv):
journal_id = m.journal_id.id
period_id = m.period_id.id
else:
journal_id = context['journal_id']
period_id = context['period_id']
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]
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 !'))
journal_id = context.get('journal_id',False)
period_id = context.get('period_id',False)
if journal_id:
journal = self.pool.get('account.journal').browse(cr, uid, [journal_id])[0]
if journal.allow_date and period_id:
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:
return True
@ -836,7 +904,7 @@ class account_move_line(osv.osv):
if vals.get('date', False):
todo_date = vals['date']
del vals['date']
for line in self.browse(cr, uid, ids,context=context):
ctx = context.copy()
if ('journal_id' not in ctx):
@ -848,8 +916,8 @@ class account_move_line(osv.osv):
if line.move_id:
ctx['period_id'] = line.move_id.period_id.id
else:
ctx['period_id'] = line.period_id.id
#Check for centralisation
ctx['period_id'] = line.period_id.id
#Check for centralisation
journal = self.pool.get('account.journal').browse(cr, uid, ctx['journal_id'], context=ctx)
if journal.centralisation:
self._check_moves(cr, uid, context=ctx)

View File

@ -163,13 +163,13 @@
</record>
<record id="action_account_form" model="ir.actions.act_window">
<field name="name">List of Accounts</field>
<field name="name">Accounts</field>
<field name="res_model">account.account</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="search_view_id" ref="view_account_search"/>
</record>
<menuitem id="account_account_menu" name="Financial Accounts" parent="account.menu_finance_accounting"/>
<menuitem id="account_account_menu" name="Accounts" parent="menu_finance_accounting"/>
<menuitem action="action_account_form" id="menu_action_account_form" parent="account_account_menu"/>
<record id="view_account_tree" model="ir.ui.view">
@ -197,7 +197,7 @@
<field name="view_id" ref="view_account_tree"/>
<field name="domain">[('parent_id','=',False)]</field>
</record>
<menuitem action="action_account_tree" id="menu_action_account_tree" parent="account.account_account_menu"/>
<!-- <menuitem action="action_account_tree" id="menu_action_account_tree" parent="account.account_account_menu"/>-->
<!--
Journal
@ -272,22 +272,19 @@
<group colspan="4" col="6">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="active" select="1"/>
<field name="type"/>
<field name="type" on_change="onchange_type(type)"/>
<field name="refund_journal" attrs="{'readonly':[('type','=','general'),('type','=','cash'),('type','=','situation')]}"/>
</group>
<notebook colspan="4">
<notebook colspan="4">
<page string="General Information">
<group colspan="2" col="2">
<separator string="Journal View" colspan="4"/>
<field name="view_id"/>
<field name="view_id" widget="selection"/>
</group>
<group colspan="2" col="2">
<separator string="Sequence" colspan="4"/>
<field name="sequence_id"/>
<field name="invoice_sequence_id"/>
</group>
<group colspan="2" col="2">
@ -296,7 +293,7 @@
<field name="default_credit_account_id" attrs="{'required':[('type','=','cash')]}" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
</group>
<group colspan="2" col="2">
<group colspan="2" col="2">
<separator string="Validations" colspan="4"/>
<field name="allow_date" groups="base.group_extended"/>
</group>
@ -307,15 +304,19 @@
<field name="user_id" groups="base.group_extended"/>
<field name="currency"/>
</group>
<group colspan="2" col="2">
<separator string="Other Configuration" colspan="4"/>
<field name="centralisation"/>
<field name="group_invoice_lines"/>
<field name="update_posted"/>
<field name="centralisation" groups="base.group_extended"/>
<field name="entry_posted"/>
<group colspan="2" col="2">
<separator string="Invoicing Data" colspan="4"/>
<field name="invoice_sequence_id"/>
<field name="group_invoice_lines"/>
</group>
</group>
</page>
<page string="Entry Controls">
<page string="Entry Controls" groups="base.group_extended">
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>
<field colspan="4" name="type_control_ids" nolabel="1"/>
<separator colspan="4" string="Accounts Allowed (empty for no control)"/>
@ -326,12 +327,12 @@
</field>
</record>
<record id="action_account_journal_form" model="ir.actions.act_window">
<field name="name">Financial Journals</field>
<field name="name">Journals</field>
<field name="res_model">account.journal</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_account_journal_form" id="menu_action_account_journal_form" parent="menu_finance_accounting"/>
<menuitem action="action_account_journal_form" id="menu_action_account_journal_form" parent="account_account_menu"/>
<record id="view_bank_statement_tree" model="ir.ui.view">
<field name="name">account.bank.statement.tree</field>
@ -415,12 +416,12 @@
</field>
</record>
<record id="action_bank_statement_tree" model="ir.actions.act_window">
<field name="name">Entries by Statements</field>
<field name="name">Bank Statements</field>
<field name="res_model">account.bank.statement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_bank_statement_tree" id="menu_bank_statement_tree" parent="menu_finance_entries" sequence="7"/>
<menuitem string="Bank Statements" action="action_bank_statement_tree" id="menu_bank_statement_tree" parent="menu_finance_bank_and_cash" sequence="7"/>
<record id="action_bank_statement_draft_tree" model="ir.actions.act_window">
<field name="name">Draft statements</field>
@ -517,7 +518,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_account_type_form" groups="base.group_extended" id="menu_action_account_type_form" parent="account.account_account_menu"/>
<menuitem action="action_account_type_form" groups="base.group_extended" id="menu_action_account_type_form" parent="menu_low_level"/>
<!--
Entries
-->
@ -609,7 +610,7 @@
<field name="view_id" ref="view_tax_code_tree"/>
</record>
<menuitem id="next_id_27" name="Taxes" parent="account.menu_finance_accounting"/>
<menuitem action="action_tax_code_list" id="menu_action_tax_code_list" parent="next_id_27" sequence="12"/>
<menuitem action="action_tax_code_list" id="menu_action_tax_code_list" parent="menu_low_level" sequence="12"/>
<!--
@ -841,7 +842,9 @@
<separator orientation="vertical"/>
<field name="date" select='1'/>
<field name="account_id" select='1'/>
<field name="partner_id" select='1'/>
<field name="partner_id" select='1'>
<filter help="Next Partner Entries to reconcile" name="next_partner" string="Next Partner to reconcile" context="{'next_partner_only': 1}" icon="terp-partner" domain="[('account_id.reconcile','=',True),('reconcile_id','=',False)]"/>
</field>
<field name="balance" string="Debit/Credit" select='1'/>
</group>
</search>
@ -1006,11 +1009,22 @@
<field name="view_id" ref="view_move_tree"/>
<field name="search_view_id" ref="view_account_move_filter"/>
</record>
<record id="action_move_to_review" model="ir.actions.act_window">
<field name="name">Journal Entries to Review</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.move</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_move_tree"/>
<field name="search_view_id" ref="view_account_move_filter"/>
<field name="domain">[('to_check','=',True)]</field>
</record>
<menuitem action="action_move_to_review" id="menu_action_move_to_review" parent="periodical_processing_journal_entries_validation"/>
<menuitem id="next_id_29" name="Search Entries" parent="account.menu_finance_entries" sequence="40"/>
<menuitem action="action_move_line_form" id="menu_action_move_line_form" parent="next_id_29"/>
<record id="action_move_line_form_encode_by_move" model="ir.actions.act_window">
<field name="name">Journal Entries</field>
<field name="name">Journal Vouchers</field>
<field name="res_model">account.move</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
@ -1020,6 +1034,30 @@
<menuitem action="action_move_line_form_encode_by_move" id="menu_encode_entries_by_move" parent="menu_finance_entries"/>
<record id="action_account_moves_sale" model="ir.actions.act_window">
<field name="name">Receivable Entries</field>
<field name="res_model">account.move</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_move_tree"/>
<field name="search_view_id" ref="view_account_move_filter"/>
<field name="domain">[('journal_id.type', '=', 'sale')]</field>
</record>
<menuitem action="action_account_moves_sale" id="menu_eaction_account_moves_sale" parent="menu_finance_receivables"/>
<record id="action_account_moves_purchase" model="ir.actions.act_window">
<field name="name">Payable Entries</field>
<field name="res_model">account.move</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_move_tree"/>
<field name="search_view_id" ref="view_account_move_filter"/>
<field name="domain">[('journal_id.type', '=', 'purchase')]</field>
</record>
<menuitem action="action_account_moves_purchase" id="menu_eaction_account_moves_purchase" parent="menu_finance_payables"/>
<record id="action_move_line_search" model="ir.actions.act_window">
<field name="name">Entry Lines</field>
<field name="type">ir.actions.act_window</field>
@ -1040,6 +1078,29 @@
<field name="view_mode">form</field>
<field name="act_window_id" ref="action_move_line_search"/>
</record>
<record id="action_move_line_search_view3" model="ir.actions.act_window">
<field name="name">Cash Register</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.move.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_move_line_tree"/>
<field name="search_view_id" ref="view_account_move_line_filter"/>
<field name="domain">[('journal_id.type', '=', 'cash')]</field>
</record>
<record id="action_move_line_search_view4" model="ir.actions.act_window">
<field name="name">Checks Register</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.move.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_move_line_tree"/>
<field name="search_view_id" ref="view_account_move_line_filter"/>
<field name="domain">[('journal_id.type', '=', 'bank')]</field>
</record>
<menuitem action="action_move_line_search_view3" id="journal_cash_move_lines" parent="menu_finance_bank_and_cash"/>
<menuitem action="action_move_line_search_view4" id="journal_bank_move_lines" parent="menu_finance_bank_and_cash"/>
<menuitem action="action_move_line_search" id="menu_action_move_line_search" parent="account.next_id_29"/>
<menuitem id="menu_finance_charts" name="Charts" parent="account.menu_finance" sequence="4"/>
@ -1108,20 +1169,32 @@
<field name="view_mode">form,tree</field>
<field name="view_id" ref="view_bank_statement_reconcile_form"/>
</record>
<menuitem
<!-- <menuitem
id="next_id_30"
name="Bank Reconciliation"
parent="account.menu_finance_periodical_processing"
groups="group_account_user"/>
parent="menu_finance_periodical_processing"
groups="group_account_user"/> -->
<menuitem action="action_bank_statement_reconciliation_form" id="menu_action_account_bank_reconcile_tree" parent="next_id_30"/>
<!-- <menuitem action="action_bank_statement_reconciliation_form" id="menu_action_account_bank_reconcile_tree" parent="next_id_30"/>-->
<!-- <wizard id="action_account_bank_reconcile_tree" menu="False" model="account.move.line" name="account.move.bank.reconcile" string="Bank reconciliation"/> -->
<!-- <menuitem action="action_account_bank_reconcile_tree" id="menu_action_account_bank_reconcile_check_tree" parent="account.next_id_30" type="wizard"/> -->
<!-- bank reconsilation -->
<menuitem action="action_account_bank_reconcile_tree"
id="menu_action_account_bank_reconcile_check_tree"
parent="account.next_id_30" />
parent="periodical_processing_reconciliation" groups="group_account_user" />
<act_window
context="{'search_default_next_partner':1}"
id="action_account_manual_reconcile" name="Entry Lines"
res_model="account.move.line"
/>
<menuitem
name="Manual Reconcilication" icon="STOCK_EXECUTE"
action="action_account_manual_reconcile"
id="menu_manual_reconcile"
parent="account.periodical_processing_reconciliation"/>
<act_window
@ -1244,12 +1317,12 @@
</field>
</record>
<record id="action_model_form" model="ir.actions.act_window">
<field name="name">Models Definition</field>
<field name="name">Define Models</field>
<field name="res_model">account.model</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_model_form" id="menu_action_model_form" parent="menu_finance_configuration"/>
<menuitem action="action_model_form" id="menu_action_model_form" parent="account.menu_finance_recurrent_entries"/>
<!--
@ -1312,7 +1385,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_payment_term_form" id="menu_action_payment_term_form" parent="menu_finance_configuration"/>
<menuitem action="action_payment_term_form" id="menu_action_payment_term_form" parent="menu_configuration_misc"/>
<!--
# Account Subscriptions
@ -1392,7 +1465,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_subscription_form" id="menu_action_subscription_form" parent="account.menu_finance_recurrent_entries"/>
<!-- <menuitem action="action_subscription_form" id="menu_action_subscription_form" parent="account.menu_finance_recurrent_entries"/>-->
<record id="action_subscription_form_running" model="ir.actions.act_window">
<field name="name">Running Subscriptions</field>
@ -1525,8 +1598,18 @@
<menuitem
id="account_template_folder"
name="Templates"
parent="account.menu_finance_accounting"
parent="menu_finance_accounting"
groups="base.group_multi_company"/>
<menuitem
id="account_template_taxes"
name="Taxes"
parent="account_template_folder"
groups="base.group_multi_company" sequence="2"/>
<menuitem
id="account_template_accounts"
name="Accounts"
parent="account_template_folder"
groups="base.group_multi_company" sequence="1"/>
<record id="view_account_template_form" model="ir.ui.view">
@ -1577,7 +1660,7 @@
</record>
<menuitem action="action_account_template_form" id="menu_action_account_template_form" parent="account_template_folder"/>
<menuitem action="action_account_template_form" id="menu_action_account_template_form" parent="account_template_accounts"/>
<!-- Chart of Accounts Templates -->
@ -1622,7 +1705,7 @@
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_account_chart_template_form" id="menu_action_account_chart_template_form" parent="account_template_folder"/>
<menuitem action="action_account_chart_template_form" id="menu_action_account_chart_template_form" parent="account_template_accounts"/>
<!-- Account Tax Templates -->
@ -1698,7 +1781,7 @@
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_account_tax_template_form" id="menu_action_account_tax_template_form" parent="account_template_folder" sequence="13"/>
<menuitem action="action_account_tax_template_form" id="menu_action_account_tax_template_form" parent="account_template_taxes" sequence="13"/>
<!-- Account Tax Code Templates -->
<record id="view_tax_code_template_tree" model="ir.ui.view">
@ -1736,7 +1819,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_account_tax_code_template_form" id="menu_action_account_tax_code_template_form" parent="account_template_folder" sequence="14"/>
<menuitem action="action_account_tax_code_template_form" id="menu_action_account_tax_code_template_form" parent="account_template_taxes" sequence="14"/>
<!-- Wizard for Multi Charts of Accounts -->
@ -1783,7 +1866,6 @@
</tree>
</field>
</group>
<xpath expr='//button[@name="action_skip"]' position='replace'/>
</data>
</field>
</record>

View File

@ -33,7 +33,7 @@
-->
<!-- automatic reconcile -->
<menuitem id="next_id_20" name="Reconciliation" parent="menu_finance_periodical_processing"/>
<!-- <menuitem id="next_id_20" name="Reconciliation" parent="menu_finance_periodical_processing"/>-->
<!-- <wizard id="wizard_automatic_reconcile" menu="False" model="account.account" name="account.automatic.reconcile" string="Automatic reconciliation"/>
<menuitem action="wizard_automatic_reconcile" id="menu_automatic_reconcile" parent="next_id_20" type="wizard"/>-->
@ -52,18 +52,15 @@
<!-- <wizard id="wizard_reconcile_unreconcile" model="account.move.reconcile" name="account.reconcile.unreconcile" string="Unreconcile Entries"/>-->
<!-- <wizard id="wizard_reconcile_select" menu="False" model="account.move.line" name="account.move.line.reconcile.select" string="Reconcile entries"/>
<menuitem action="wizard_reconcile_select" id="menu_reconcile_select" parent="account.next_id_20" type="wizard"/>
-->
<!-- <wizard id="wizard_reconcile_select" menu="False" model="account.move.line" name="account.move.line.reconcile.select" string="Reconcile entries"/> -->
<!-- <menuitem action="wizard_reconcile_select" id="menu_reconcile_select" parent="account.next_id_20" type="wizard"/> -->
<!-- unreconcile -->
<!-- <wizard id="wizard_unreconcile" model="account.move.line" name="account.move.line.unreconcile" string="Unreconcile Entries"/>-->
<!-- unreconcile
<wizard id="wizard_unreconcile_select" menu="False" model="account.move.line" name="account.move.line.unreconcile.select" string="Unreconcile entries"/>
<menuitem action="wizard_unreconcile_select" id="menu_unreconcile_select" parent="account.next_id_20" type="wizard"/>
-->
<!-- <wizard id="wizard_unreconcile_select" menu="False" model="account.move.line" name="account.move.line.unreconcile.select" string="Unreconcile entries"/> -->
<!-- <menuitem action="wizard_unreconcile_select" id="menu_unreconcile_select" parent="account.next_id_20" type="wizard"/> -->
<!-- subscriptions -->
<!--

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!--
Administrator shortcut
Demo user startup menu

View File

@ -6,13 +6,6 @@
<field name="name">Accountants</field>
</record>
<record id="action_account_analytic_line_to_invoice" model="ir.actions.act_window">
<field name="name">Costs to invoice</field>
<field name="res_model">report.account.analytic.line.to.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
</record>
<record id="action_aged_receivable" model="ir.actions.act_window">
<field name="name">Receivable Accounts</field>
<field name="res_model">report.account.receivable</field>
@ -28,9 +21,6 @@
<field name="domain">[('type','=','income')]</field>
</record>
<act_window domain="[('state','&lt;&gt;','close'),('partner_id','&lt;&gt;',False),('to_invoice', '&lt;&gt;', False)]" id="act_my_account" name="Accounts to invoice" res_model="account.analytic.account" src_model="res.users" view_mode="tree,form" view_type="form"/>
<record id="board_account_form" model="ir.ui.view">
<field name="name">board.account.form</field>
<field name="model">board.board</field>
@ -38,25 +28,12 @@
<field name="arch" type="xml">
<form string="Account Board">
<hpaned>
<child1>
<action colspan="4" height="160" name="%(hr_timesheet_invoice.action_analytic_account_tree)d" string="Analytic accounts to close" width="510"/>
<action colspan="4" height="160" name="%(act_my_account)d" string="Accounts to invoice" width="510"/>
<action colspan="4" height="160" name="%(account.action_invoice_tree1)d" string="Draft Customer Invoices" domain="[('state','=','draft'),('type','=','out_invoice')]"/>
</child1>
<child2>
<button colspan="4" icon="terp-purchase" name="%(account_report.action_account_report_tree_view_indicator)d" string="My indicators" type="action"/>
<action colspan="4" height="220" name="%(action_account_analytic_line_to_invoice)d" string="Costs to invoice"/>
<action colspan="4" height="220" name="%(action_aged_receivable)d" string="Aged receivables"/>
<action colspan="4" height="220" name="%(action_aged_income)d" string="Aged income"/>
</child2>
</hpaned>
</form>
@ -71,6 +48,7 @@
<field name="usage">menu</field>
<field name="view_id" ref="board_account_form"/>
</record>
<menuitem icon="terp-graph" id="base.dashboard" name="Dashboards" sequence="2" parent="base.reporting_menu"/>
<menuitem id="next_id_68" name="Accounting" parent="base.dashboard"
groups="account.group_account_manager"/>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 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/>.
#
##############################################################################
@ -33,3 +33,5 @@ out after this mail was sent, please consider the present one as \
void. Do not hesitate to contact our accounting department'
}
res_company()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -21,12 +21,12 @@
import time
import datetime
from dateutil.relativedelta import relativedelta
from tools.translate import _
from os.path import join as opj
from operator import itemgetter
from tools.translate import _
from osv import fields, osv
import netsvc
import tools
from os.path import join as opj
class account_installer(osv.osv_memory):
_name = 'account.installer'
@ -99,7 +99,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')
@ -108,7 +108,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
@ -133,7 +133,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
@ -166,7 +166,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,
@ -204,7 +204,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]
@ -328,8 +328,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
@ -426,7 +426,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),
@ -445,7 +445,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),
@ -457,7 +457,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():
@ -775,8 +777,14 @@ class account_invoice(osv.osv):
if inv.type in ('in_invoice', 'in_refund'):
ref = inv.reference
entry_type = 'journal_pur_voucher'
if inv.type == 'in_refund':
entry_type = 'cont_voucher'
else:
ref = self._convert_ref(cr, uid, inv.number)
entry_type = 'journal_sale_vou'
if inv.type == 'out_refund':
entry_type = 'cont_voucher'
diff_currency_p = inv.currency_id.id <> company_currency
# create one move line for the total and possibly adjust the other lines amount
@ -847,10 +855,10 @@ class account_invoice(osv.osv):
line = self.finalize_invoice_move_lines(cr, uid, inv, line)
move = {'ref': inv.number, 'line_id': line, 'journal_id': journal_id, 'date': date}
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:
@ -889,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:
@ -937,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
###################
@ -1070,10 +1079,20 @@ class account_invoice(osv.osv):
else:
amount_currency = False
currency_id = False
pay_journal = self.pool.get('account.journal').read(cr, uid, pay_journal_id, ['type'], context=context)
if invoice.type in ('in_invoice', 'out_invoice'):
if pay_journal['type'] == 'bank':
entry_type = 'bank_pay_voucher' # Bank payment
else:
entry_type = 'pay_voucher' # Cash payment
else:
entry_type = 'cont_voucher'
if invoice.type in ('in_invoice', 'in_refund'):
ref = invoice.reference
else:
ref = self._convert_ref(cr, uid, invoice.number)
# Pay attention to the sign for both debit/credit AND amount_currency
l1 = {
'debit': direction * pay_amount>0 and direction * pay_amount,
@ -1104,7 +1123,7 @@ class account_invoice(osv.osv):
l2['name'] = name
lines = [(0, 0, l1), (0, 0, l2)]
move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date, 'type': entry_type}
move_id = self.pool.get('account.move').create(cr, uid, move, context=context)
line_ids = []
@ -1113,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:
@ -1130,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')
@ -1215,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
@ -1230,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
@ -1239,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
@ -1255,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]
@ -1285,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)
@ -1300,7 +1321,7 @@ class account_invoice_line(osv.osv):
result['name'] = res.partner_ref
domain = {}
result['uos_id'] = uom or res.uom_id.id or False
result['uos_id'] = res.uom_id.id or uom or False
if result['uos_id']:
res2 = res.uom_id.category_id.id
if res2 :
@ -1323,8 +1344,22 @@ class account_invoice_line(osv.osv):
if company.currency_id.id != currency.id:
new_price = res_final['value']['price_unit'] * currency.rate
res_final['value']['price_unit'] = new_price
if uom:
uom = self.pool.get('product.uom').browse(cr, uid, uom, context=context)
if res.uom_id.category_id.id == uom.category_id.id:
new_price = res_final['value']['price_unit'] * uom.factor_inv
res_final['value']['price_unit'] = new_price
return res_final
def uos_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None):
res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context)
if 'uos_id' in res['value']:
del res['value']['uos_id']
if not uom:
res['value']['price_unit'] = 0.0
return res
def move_line_get(self, cr, uid, invoice_id, context=None):
res = []
tax_grouped = {}
@ -1409,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'
@ -117,27 +115,33 @@ class res_partner(osv.osv):
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,
@ -183,6 +187,7 @@ class res_partner(osv.osv):
help="This payment term will be used instead of the default one for the current partner"),
'ref_companies': fields.one2many('res.company', 'partner_id',
'Companies that refers to partner'),
'last_reconciliation_date': fields.datetime('Last Reconciliation Date', help='Date on which partner account entries reconciled last time')
}
res_partner()

View File

@ -57,7 +57,7 @@
<menuitem
action="action_account_fiscal_position_form"
id="menu_action_account_fiscal_position_form"
parent="account.menu_finance_accounting" sequence="20"/>
parent="next_id_27" sequence="20"/>
<!--
Partners Extension
@ -122,10 +122,10 @@
</notebook>
</field>
</record>
<!-- Partners info tab view-->
<act_window
<act_window
id="action_analytic_open"
name="Analytic Accounts"
res_model="account.analytic.account"
@ -134,5 +134,16 @@
view_type="form"
view_mode="tree,form,graph,calendar"/>
<record id="view_res_partner_reconcile" model="ir.ui.view">
<field name="name">res.partner.form.reconcile</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="credit_limit" position="after">
<field name="last_reconciliation_date"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@ -39,7 +39,7 @@
</record>
<record id="process_node_invoiceinvoice0" model="process.node">
<field name="menu_id" ref="account.menu_finance_invoice"/>
<field name="menu_id" ref="account.menu_finance_receivables"/>
<field name="model_id" ref="account.model_account_invoice"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Create Invoice&quot;&quot;&quot;" name="name"/>

View File

@ -39,7 +39,7 @@
</record>
<record id="process_node_supplierinvoiceinvoice0" model="process.node">
<field name="menu_id" ref="account.menu_finance_invoice"/>
<field name="menu_id" ref="account.menu_finance_payables"/>
<field name="model_id" ref="account.model_account_invoice"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Create Invoice&quot;&quot;&quot;" name="name"/>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 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

@ -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/>.
#
##############################################################################
@ -46,7 +46,7 @@ class account_journal(osv.osv):
_inherit="account.journal"
_columns = {
'analytic_journal_id':fields.many2one('account.analytic.journal','Analytic Journal'),
'analytic_journal_id':fields.many2one('account.analytic.journal','Analytic Journal',help="Journal for analytic entries"),
}
account_journal()

View File

@ -101,7 +101,7 @@
<field name="search_view_id" ref="account.view_account_analytic_account_search"/>
</record>
<!--<menuitem id="menu_analytic_account" name="Analytic Accounts" parent="account.menu_analytic_accounting"/>-->
<menuitem action="action_account_analytic_account_form" id="account_analytic_def_account" parent="account.menu_analytic_accounting"/>
<menuitem action="action_account_analytic_account_form" id="account_analytic_def_account" parent="menu_analytic"/>
<record id="act_account_renew_view" model="ir.actions.act_window">
<field name="name">Accounts to Renew</field>
@ -114,7 +114,7 @@
</record>
<record id="action_account_analytic_account_tree2" model="ir.actions.act_window">
<field name="name">Analytic Chart of Accounts</field>
<field name="name">Chart of Analytic Accounts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.analytic.account</field>
<field name="domain">[('parent_id','=',False)]</field>
@ -122,10 +122,10 @@
<field name="view_mode">form,graph</field>
<field name="view_id" ref="view_account_analytic_account_tree"/>
</record>
<menuitem
action="action_account_analytic_account_tree2"
id="account_analytic_def_chart"
parent="account_analytic_def_account"/>
<!-- <menuitem-->
<!-- action="action_account_analytic_account_tree2"-->
<!-- id="account_analytic_def_chart"-->
<!-- parent="account_analytic_def_account"/>-->
<!-- <menuitem action="action_account_analytic_account_tree2" id="account_analytic_chart" parent="account.menu_finance_charts"/>-->
<!-- <wizard id="wizard_analytic_account_chart" menu="False" model="account.analytic.account" name="account.analytic.account.chart" string="Analytic Chart of Accounts"/>
@ -206,14 +206,14 @@
<field name="context">{"search_default_user_id":uid}</field>
<field name="view_id" ref="view_account_analytic_line_tree"/>
</record>
<wizard id="action_account_analytic_line" menu="False" model="account.analytic.line" name="account.analytic.line" string="Entries by Line"/>
<menuitem id="next_id_41" name="Analytic Entries" parent="account.menu_finance_entries"/>
<!-- <wizard id="action_account_analytic_line" menu="False" model="account.analytic.line" name="account.analytic.line" string="Entries by Line"/>-->
<!-- <menuitem id="next_id_41" name="Analytic Entries" parent="account.menu_finance_entries"/>-->
<!-- Entries by Line -->
<menuitem icon="STOCK_JUSTIFY_FILL"
action="action_project_account_analytic_line_form"
id="account_entries_analytic_entries"
parent="next_id_41"/>
<!-- <menuitem icon="STOCK_JUSTIFY_FILL"-->
<!-- action="action_project_account_analytic_line_form"-->
<!-- id="account_entries_analytic_entries"-->
<!-- parent="next_id_41"/>-->
<record id="action_account_tree1" model="ir.actions.act_window">
<field name="name">Analytic Entries</field>
@ -293,31 +293,49 @@
</field>
</record>
<record id="action_account_analytic_journal_form" model="ir.actions.act_window">
<field name="name">Analytic Journal Definition</field>
<field name="name">Analytic Journals</field>
<field name="res_model">account.analytic.journal</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_account_analytic_journal_form" id="account_def_analytic_journal" parent="account.menu_analytic_accounting"/>
<menuitem action="action_account_analytic_journal_form" id="account_def_analytic_journal" parent="menu_analytic"/>
#
# Open journal entries
#
<record id="action_account_analytic_journal_open_form" model="ir.actions.act_window">
<field name="name">Entries of Open Analytic Journals</field>
<field name="name">Analytic Journal Items</field>
<field name="res_model">account.analytic.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('journal_id','=',active_id)]</field>
</record>
<record id="ir_open_account_journal_analytic" model="ir.values">
<field eval="'tree_but_open'" name="key2"/>
<field eval="'account.analytic.journal'" name="model"/>
<field name="name">Open Analytic Journal</field>
<field eval="'ir.actions.act_window,%d'%action_account_analytic_journal_open_form" name="value"/>
<field eval="True" name="object"/>
</record>
<menuitem action="action_account_analytic_journal_open_form" id="account_analytic_journal_entries" parent="menu_finance_entries"/>
<!-- <record id="action_account_analytic_journal_open_form" model="ir.actions.act_window">
<field name="name">Check Register</field>
<field name="res_model">account.analytic.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('journal_id','=',active_id)]</field>
</record> -->
<!-- <menuitem action="action_account_analytic_journal_open_form" id="account_analytic_journal_entries" parent="menu_finance_bank_and_cash"/>-->
<!-- <record id="action_account_analytic_journal_open_form" model="ir.actions.act_window">
<field name="name">Checks Register</field>
<field name="res_model">account.analytic.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('journal_id','=',active_id)]</field>
</record> -->
<!-- <menuitem action="action_account_analytic_journal_open_form" id="account_analytic_journal_entries" parent="menu_finance_bank_and_cash"/>-->
<!-- <record id="ir_open_account_journal_analytic" model="ir.values">-->
<!-- <field eval="'tree_but_open'" name="key2"/>-->
<!-- <field eval="'account.analytic.journal'" name="model"/>-->
<!-- <field name="name">Open Analytic Journal</field>-->
<!-- <field eval="'ir.actions.act_window,%d'%action_account_analytic_journal_open_form" name="value"/>-->
<!-- <field eval="True" name="object"/>-->
<!-- </record>-->
#
# Reporting
@ -331,13 +349,13 @@
<menuitem action="action_account_analytic_journal_tree" id="account_analytic_journal_print" parent="account.next_id_40"/>
<record id="action_account_analytic_journal_tree2" model="ir.actions.act_window">
<field name="name">Analytic Entries by Journal</field>
<field name="res_model">account.analytic.journal</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_account_analytic_journal_tree"/>
</record>
<menuitem action="action_account_analytic_journal_tree2" id="account_analytic_journal_entries" parent="account.next_id_41"/>
<!-- <record id="action_account_analytic_journal_tree2" model="ir.actions.act_window">-->
<!-- <field name="name">Analytic Entries by Journal</field>-->
<!-- <field name="res_model">account.analytic.journal</field>-->
<!-- <field name="view_type">tree</field>-->
<!-- <field name="view_id" ref="view_account_analytic_journal_tree"/>-->
<!-- </record>-->
<!-- <menuitem action="action_account_analytic_journal_tree2" id="account_analytic_journal_entries" parent="account.next_id_41"/>-->
#
# Statistics

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 = {
@ -55,51 +55,3 @@ class account_analytic_cost_ledger_journal_report(osv.osv_memory):
account_analytic_cost_ledger_journal_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
#import time
#import wizard
#
#_form = '''<?xml version="1.0"?>
#<form string="Select period">
# <separator string="Cost Legder for period" colspan="4"/>
# <field name="date1"/>
# <field name="date2"/>
# <separator string="and Journals" colspan="4"/>
# <field name="journal" colspan="4"/>
#</form>'''
#
#_fields = {
# 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
# 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
# 'journal': {'string':'Journals','type':'many2many', 'relation':'account.analytic.journal'},
#}
#
#
#class wizard_report(wizard.interface):
# states = {
# 'init': {
# 'actions': [],
# 'result': {
# 'type': 'form',
# 'arch': _form,
# 'fields': _fields,
# 'state': [
# ('end','Cancel'),
# ('report','Print')
# ]
# }
# },
# 'report': {
# 'actions': [],
# 'result': {
# 'type': 'print',
# 'report': 'account.analytic.account.quantity_cost_ledger',
# 'state': 'end'
# }
# },
# }
#
#wizard_report('account.analytic.account.quantity_cost_ledger.report')
#
## vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -32,26 +32,26 @@ class project_account_analytic_line(osv.osv_memory):
def action_open_window(self, cr, uid, ids, context={}):
mod_obj =self.pool.get('ir.model.data')
domain = []
for data in self.read(cr, uid, ids, context=context):
from_date = data['from_date']
to_date = data['to_date']
if from_date and to_date:
domain = [('date','>=',from_date), ('date','<=',to_date)]
elif from_date:
domain = [('date','>=',from_date)]
elif to_date:
domain = [('date','<=',to_date)]
result = mod_obj._get_id(cr, uid, 'account', 'view_account_analytic_line_filter')
id = mod_obj.read(cr, uid, result, ['res_id'], context=context)
return {
'name': _('Analytic Entries by line'),
'view_type': 'form',
"view_mode": 'tree,form',
'res_model': 'account.analytic.line',
'type': 'ir.actions.act_window',
'domain': domain,
'search_view_id': id['res_id'],
}
data = self.read(cr, uid, ids, [])[0]
from_date = data['from_date']
to_date = data['to_date']
if from_date and to_date:
domain = [('date','>=',from_date), ('date','<=',to_date)]
elif from_date:
domain = [('date','>=',from_date)]
elif to_date:
domain = [('date','<=',to_date)]
result = mod_obj._get_id(cr, uid, 'account', 'view_account_analytic_line_filter')
id = mod_obj.read(cr, uid, result, ['res_id'], context=context)
return {
'name': _('Analytic Entries by line'),
'view_type': 'form',
"view_mode": 'tree,form',
'res_model': 'account.analytic.line',
'type': 'ir.actions.act_window',
'domain': domain,
'search_view_id': id['res_id'],
}
project_account_analytic_line()

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

@ -24,7 +24,11 @@
<field eval="[(6,0,[ref('group_account_manager')])]" name="groups_id"/>
</record>
<record id="menu_finance_invoice" model="ir.ui.menu">
<record id="menu_finance_receivables" model="ir.ui.menu">
<field eval="[(6,0,[ref('group_account_invoice')])]" name="groups_id"/>
</record>
<record id="menu_finance_payables" model="ir.ui.menu">
<field eval="[(6,0,[ref('group_account_invoice')])]" name="groups_id"/>
</record>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,11 +15,10 @@
# 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/>.
#
##############################################################################
from osv import fields,osv
class ir_sequence_fiscalyear(osv.osv):

View File

@ -0,0 +1,84 @@
-
In order to test change currency wizard I create an invoice with currency "EUR" and change it to "USD" using the wizard
-
!record {model: account.invoice, id: account_invoice_currency}:
account_id: account.a_recv
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
company_id: base.main_company
currency_id: base.EUR
invoice_line:
- account_id: account.a_sale
name: '[PC1] Basic PC'
price_unit: 450.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: base.res_partner_desertic_hispafuentes
reference_type: none
-
I check that Initially customer invoice is in the draft state
-
!assert {model: account.invoice, id: account_invoice_currency, string: Customer Invoice is in Draft state}:
- state == 'draft'
-
I change the state of invoice to proforma2 by clicking PRO-FORMA button
-
!workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_currency}
-
I check that now customer invoice is in the "proforma2" state
-
!assert {model: account.invoice, id: account_invoice_currency}:
- state == 'proforma2'
-
Now I select USD as new currency
-
!record {model: account.change.currency, id: account_change_currency_0}:
currency_id: base.USD
-
I clicked on Change Currency button to change the currency
-
!python {model: account.change.currency}: |
try:
self.view_init(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
"active_model": "account.invoice", "tz": False, "record_id": 4, "active_ids":
[ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
})
self.change_currency(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
"active_model": "account.invoice", "tz": False, "record_id": 4, "active_ids":
[ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
})
except:
print "You can not change currency for Open Invoice !"
-
I can't change the currency of invoice when it is not in draft state so i change the state to cancel
-
!workflow {model: account.invoice, action: invoice_cancel, ref: account_invoice_currency}
-
I change the state to "Draft"
-
!python {model: account.invoice}: |
self.action_cancel_draft(cr, uid, [ref("account_invoice_currency")], {"lang": 'en_US',
"tz": False, "active_model": "ir.ui.menu", "active_ids": [ref("account.menu_action_invoice_tree1")],
"type": "out_invoice", "active_id": ref("account.menu_action_invoice_tree1"),
})
-
I change the currency.
-
!record {model: account.change.currency, id: account_change_currency_0}:
currency_id: base.USD
-
I clicked on Change Currency button to change the currency
-
!python {model: account.change.currency}: |
self.change_currency(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
"active_model": "account.invoice", "tz": False, "record_id": 4, "active_ids":
[ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
})
-
I check that the currency is changed successfully
-
!assert {model: account.invoice, id: account_invoice_currency, string: Currency changed from EUR to USD}:
- currency_id.id == ref("base.USD")

View File

@ -1,9 +1,7 @@
-
In order to test account invoice i create a new customer invoice
In order to test account invoice I create a new customer invoice
-
Creating a account.invoice record
-
!record {model: account.invoice, id: account_invoice_0}:
!record {model: account.invoice, id: account_invoice_customer0}:
account_id: account.a_recv
address_contact_id: base.res_partner_address_zen
address_invoice_id: base.res_partner_address_zen
@ -21,36 +19,30 @@
partner_id: base.res_partner_3
reference_type: none
-
I check that Initially customer invoice is in the draft state
I check that Initially customer invoice is in the "Draft" state
-
!assert {model: account.invoice, id: account_invoice_0}:
!assert {model: account.invoice, id: account_invoice_customer0}:
- state == 'draft'
-
I change the state of invoice to proforma2 by clicking PRO-FORMA button
I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
-
Performing a workflow action invoice_proforma2 on module account.invoice
!workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_customer0}
-
!workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_0}
I check that the invoice state is now "Proforma2"
-
I check that the invoice state is now proforma2
-
!assert {model: account.invoice, id: account_invoice_0}:
!assert {model: account.invoice, id: account_invoice_customer0}:
- state == 'proforma2'
-
I create invoice by clicking on Create button
-
Performing a workflow action invoice_open on module account.invoice
!workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer0}
-
!workflow {model: account.invoice, action: invoice_open, ref: account_invoice_0}
I check that the invoice state is "Open"
-
I check that the invoice state is now open
-
!assert {model: account.invoice, id: account_invoice_0}:
!assert {model: account.invoice, id: account_invoice_customer0}:
- state == 'open'
-
I make a partial payment of 1000 by clicking on Pay Invoice button
-
Creating a account.invoice.pay record
I create a record for partial payment of 1000 EUR.
-
!record {model: account.invoice.pay, id: account_invoice_pay_first0}:
amount: 1000.0
@ -58,25 +50,21 @@
journal_id: account.sales_journal
name: First payment for [PC3] Medium PC to Distrib PC
period_id: account.period_5
-
Performing an osv_memory action pay_and_reconcile on module account.invoice.pay
I make partial payment by clicking on Partial Payment button
-
!python {model: account.invoice.pay}: |
self.pay_and_reconcile(cr, uid, [ref("account_invoice_pay_first0")], {"lang":
'en_US', "active_model": "account.invoice", "tz": False, "record_id": 3, "active_ids":
[ref("account_invoice_0")], "type": "out_invoice", "active_id": ref("account_invoice_0"),
[ref("account_invoice_customer0")], "type": "out_invoice", "active_id": ref("account_invoice_customer0"),
})
-
I check that the invoice state is still open
-
!assert {model: account.invoice, id: account_invoice_0}:
!assert {model: account.invoice, id: account_invoice_customer0}:
- state == 'open'
-
I make second partial payment of 6000 by clicking on Pay Invoice button
-
Creating a account.invoice.pay record
I make second partial payment of 6000 EUR.
-
!record {model: account.invoice.pay, id: account_invoice_pay_second0}:
amount: 6000.0
@ -84,19 +72,17 @@
journal_id: account.sales_journal
name: Second payment for [PC3] Medium PC to Distrib PC
period_id: account.period_5
-
Performing an osv_memory action pay_and_reconcile on module account.invoice.pay
I make partial payment by clicking on Partial Payment button
-
!python {model: account.invoice.pay}: |
self.pay_and_reconcile(cr, uid, [ref("account_invoice_pay_second0")], {"lang":
'en_US', "active_model": "account.invoice", "tz": False, "record_id": 3, "active_ids":
[ref("account_invoice_0")], "type": "out_invoice", "active_id": ref("account_invoice_0"),
[ref("account_invoice_customer0")], "type": "out_invoice", "active_id": ref("account_invoice_customer0"),
})
-
I make final partial payment of 2000 by clicking on Pay Invoice button
-
Creating a account.invoice.pay record
I make final partial payment of 2000 EUR
-
!record {model: account.invoice.pay, id: account_invoice_pay_final0}:
amount: 2000.0
@ -105,39 +91,39 @@
name: Final payment for [PC3] Medium PC to Distrib PC
period_id: account.period_5
-
Performing an osv_memory action pay_and_reconcile on module account.invoice.pay
I make partial payment by clicking on Partial Payment button
-
!python {model: account.invoice.pay}: |
self.pay_and_reconcile(cr, uid, [ref("account_invoice_pay_final0")], {"lang":
'en_US', "active_model": "account.invoice", "tz": False, "record_id": 3, "active_ids":
[ref("account_invoice_0")], "type": "out_invoice", "active_id": ref("account_invoice_0"),
[ref("account_invoice_customer0")], "type": "out_invoice", "active_id": ref("account_invoice_customer0"),
})
-
I check that the invoice state is now Done
-
!assert {model: account.invoice, id: account_invoice_0}:
!assert {model: account.invoice, id: account_invoice_customer0}:
- state == 'paid'
-
I check that an payment entry gets created in the account.move.line
-
!python {model: account.invoice}: |
acc_id=self.browse(cr, uid, ref("account_invoice_0"))
acc_id=self.browse(cr, uid, ref("account_invoice_customer0"))
assert(acc_id.move_id)
#-
# I refund the invoice
#-
# Creating a account.invoice.refund record
#-
# !record {model: account.invoice.refund, id: account_invoice_refund_0}:
# description: Refund
#
#-
# Performing an osv_memory action invoice_refund on module account.invoice.refund
#-
# !python {model: account.invoice.refund}: |
# self.invoice_refund(cr, uid, [ref("account_invoice_refund_0")], {"lang": 'en_US', "tz": False, "active_model": "account.invoice", "active_ids": [ref("account.account_invoice_0")], "type": "out_invoice", "active_id": ref("account.account_invoice_0"), })
# return self.compute_refund(cr, uid, [ref("account_invoice_refund_0")], "refund" {"lang": 'en_US',"tz": False, "active_model": "account.invoice", "active_ids": [ref("account.account_invoice_0")], "type": "out_invoice", "active_id": ref("account.account_invoice_0"), })
-
I refund the invoice Using Credit Note
-
!record {model: account.invoice.refund, id: account_invoice_refund_0}:
description: Refund To China Export
period: account.period_5
-
I clicked on refund button
-
!python {model: account.invoice.refund}: |
self.invoice_refund(cr, uid, [ref("account_invoice_refund_0")], {"lang": 'en_US', "tz": False, "active_model": "account.invoice", "active_ids": [ref("account.account_invoice_customer0")], "type": "out_invoice", "active_id": ref("account.account_invoice_customer0"), })
-
I checked that a new entry with state "Draft" created in account move line

View File

@ -0,0 +1,91 @@
-
In order to test Generate Fiscalyear Opening Entries wizard of OpenERP I first create a fiscalyear "Fiscal Year 2011" to which the entries will move
-
!record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}:
code: FY2011
company_id: base.main_company
date_start: '2011-01-01'
date_stop: '2011-12-31'
name: Fiscal Year 2011
-
I create a period "Jan2011" for the new fiscalyear
-
!record {model: account.period, id: account_period_jan11}:
company_id: base.main_company
date_start: '2011-01-01'
date_stop: '2011-12-31'
fiscalyear_id: account_fiscalyear_fiscalyear0
name: Jan2011
special: 1
-
I made modification in journal so it can move entries
-
!record {model: account.journal, id: account.sales_journal}:
centralisation: 1
-
I called the Generate Fiscalyear Opening Entries wizard
-
!record {model: account.fiscalyear.close, id: account_fiscalyear_close_0}:
fy2_id: account_fiscalyear_fiscalyear0
fy_id: account.data_fiscalyear
journal_id: account.sales_journal
period_id: account_period_jan11
report_name: End of Fiscal Year Entry
sure: 1
-
I clicked on create Button
-
!python {model: account.fiscalyear.close}: |
self.data_save(cr, uid, [ref("account_fiscalyear_close_0")], {"lang": 'en_US',
"active_model": "ir.ui.menu", "active_ids": [ref("account.menu_wizard_fy_close")],
"tz": False, "active_id": ref("account.menu_wizard_fy_close"), })
-
I check the opening entries By using "Entries by Line wizard"
-
!record {model: account.move.journal, id: account_move_journal_0}:
journal_id: account.sales_journal
period_id: account_period_jan11
-
I clicked on Open Journal Button to check the entries
-
!python {model: account.move.journal}: |
self.action_open_window(cr, uid, [ref("account_move_journal_0")], {"lang": 'en_US',
"active_model": "ir.ui.menu", "active_ids": [ref("account.menu_action_move_journal_line_form")],
"tz": False, "active_id": ref("account.menu_action_move_journal_line_form"),
})
-
In order to test Cancel Opening Entries I cancelled the opening entries created for "Fiscal Year 2011"
-
!record {model: account.open.closed.fiscalyear, id: account_open_closed_fiscalyear_1}:
fyear_id: account.data_fiscalyear
-
I clicked on Open button
-
!python {model: account.open.closed.fiscalyear}: |
self.remove_entries(cr, uid, [ref("account_open_closed_fiscalyear_1")], {"lang":
'en_US', "active_model": "ir.ui.menu", "active_ids": [ref("account.menu_wizard_open_closed_fy")],
"tz": False, "active_id": ref("account.menu_wizard_open_closed_fy"), })
-
I check the opening entries By using "Entries by Line wizard"
-
!record {model: account.move.journal, id: account_move_journal_2}:
journal_id: account.sales_journal
period_id: account_period_jan11
-
I checked the Opening entries are cancelled successfully
-
!python {model: account.move.journal}: |
self.action_open_window(cr, uid, [ref("account_move_journal_2")], {"lang": 'en_US',
"active_model": "ir.ui.menu", "active_ids": [ref("account.menu_action_move_journal_line_form")],
"tz": False, "active_id": ref("account.menu_action_move_journal_line_form"),
})

View File

@ -0,0 +1,46 @@
-
In order to check the Close a Fiscal Year wizard in OpenERP I first create a Fiscalyear
-
!record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}:
code: FY2011
company_id: base.main_company
date_start: '2011-01-01'
date_stop: '2011-12-31'
name: Fiscal Year 2011
-
I create monthly Periods for this fiscalyear
-
!python {model: account.fiscalyear}: |
self.create_period(cr, uid, [ref("account_fiscalyear_fiscalyear0")], {"lang":
'en_US', "active_model": "ir.ui.menu", "active_ids": [ref("account.menu_action_account_fiscalyear_form")],
"tz": False, "active_id": ref("account.menu_action_account_fiscalyear_form"),
})
-
I check that the fiscalyear state is "Draft"
-
!assert {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0, string: Fiscal Year is in Draft state}:
- state == 'draft'
-
I run the Close a Fiscalyear wizard to close this fiscalyear
-
!record {model: account.fiscalyear.close.state, id: account_fiscalyear_close_state_0}:
fy_id: account_fiscalyear_fiscalyear0
sure: 1
-
I clicked on Close States Button to close fiscalyear
-
!python {model: account.fiscalyear.close.state}: |
self.data_save(cr, uid, [ref("account_fiscalyear_close_state_0")], {"lang": 'en_US',
"active_model": "ir.ui.menu", "active_ids": [ref("account.menu_wizard_fy_close_state")],
"tz": False, "active_id": ref("account.menu_wizard_fy_close_state"), })
-
I check that the fiscalyear state is now "Done"
-
!assert {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0, string: Fiscal Year is in Done state}:
- state == 'done'

View File

@ -0,0 +1,68 @@
-
In order to test Confirm Draft Invoice wizard I create an invoice and confirm it with this wizard
-
!record {model: account.invoice, id: account_invoice_state}:
account_id: account.a_recv
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
company_id: base.main_company
currency_id: base.EUR
invoice_line:
- account_id: account.a_sale
name: '[PC1] Basic PC'
price_unit: 450.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.bank_journal
partner_id: base.res_partner_desertic_hispafuentes
reference_type: none
-
I check that Initially customer invoice state is "Draft"
-
!assert {model: account.invoice, id: account_invoice_state}:
- state == 'draft'
-
I called the "Confirm Draft Invoices" wizard
-
!record {model: account.invoice.confirm, id: account_invoice_confirm_0}:
{}
-
I clicked on Confirm Invoices Button
-
!python {model: account.invoice.confirm}: |
self.invoice_confirm(cr, uid, [ref("account_invoice_confirm_0")], {"lang": 'en_US',
"tz": False, "active_model": "account.invoice", "active_ids": [ref("account_invoice_state")],
"type": "out_invoice", "active_id": ref("account_invoice_state"), })
-
I check that customer invoice state is "Open"
-
!assert {model: account.invoice, id: account_invoice_state}:
- state == 'open'
-
I Modified the journal record so it can cancel invoice
-
!record {model: account.journal, id: account.bank_journal}:
update_posted: 1
-
In order to check the "Cancel Selected Invoices" wizard in openerp I cancelled this open invoice using this wizard
-
!record {model: account.invoice.cancel, id: account_invoice_cancel_0}:
{}
-
I clicked on Cancel Invoices Button
-
!python {model: account.invoice.cancel}: |
self.invoice_cancel(cr, uid, [ref("account_invoice_cancel_0")], {"lang": 'en_US',
"tz": False, "active_model": "account.invoice", "active_ids": [ref("account_invoice_state")],
"type": "out_invoice", "active_id": ref("account_invoice_state"), })
-
I check that customer invoice is in the cancel state
-
!assert {model: account.invoice, id: account_invoice_state}:
- state == 'cancel'

View File

@ -0,0 +1,35 @@
-
In order to test close period wizard I create a period then close it and checked it's state
-
!record {model: account.period, id: account_period_jan0}:
company_id: base.main_company
date_start: '2010-01-01'
date_stop: '2010-01-31'
fiscalyear_id: account.data_fiscalyear
name: Jan-2010
special: 1
-
I check that the period state is "Draft"
-
!assert {model: account.period, id: account_period_jan0, string: Period is in Draft state}:
- state == 'draft'
-
I use "Close a Period" wizard to close period Jan-2010
-
!record {model: account.period.close, id: account_period_close_0}:
sure: 1
-
I clicked on Close Period Button to close Period
-
!python {model: account.period.close}: |
self.data_save(cr, uid, [ref("account_period_close_0")], {"lang": 'en_US', "active_model":
"account.period", "active_ids": [ref("account_period_jan0")], "tz": False, "active_id":
ref("account_period_jan0"), })
-
I check that the period state is "Done"
-
!assert {model: account.period, id: account_period_jan0, string: Period is in Done state}:
- state == 'done'

View File

@ -1,9 +1,7 @@
-
In order to test account invoice i create a new supplier invoice
In order to test account invoice I create a new supplier invoice
-
Creating a account.invoice record
-
!record {model: account.invoice, id: account_invoice_1}:
!record {model: account.invoice, id: account_invoice_supplier0}:
account_id: account.a_pay
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
@ -22,25 +20,21 @@
reference_type: none
type: in_invoice
-
I check that Initially supplier invoice is in the draft state
I check that Initially supplier invoice state is "Draft"
-
!assert {model: account.invoice, id: account_invoice_1}:
!assert {model: account.invoice, id: account_invoice_supplier0}:
- state == 'draft'
-
I change the state of invoice to open by clicking Validate button
-
Performing a workflow action invoice_open on module account.invoice
!workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier0}
-
!workflow {model: account.invoice, action: invoice_open, ref: account_invoice_1}
I check that the invoice state is now "Open"
-
I check that the invoice state is now open
-
!assert {model: account.invoice, id: account_invoice_1}:
!assert {model: account.invoice, id: account_invoice_supplier0}:
- state == 'open'
-
I make a partial payment of 2000 by clicking on Pay Invoice button
-
Creating a account.invoice.pay record
I make a partial payment of 2000 EUR
-
!record {model: account.invoice.pay, id: account_invoice_pay_firstpaymenttoaxelorforbasicpc0}:
amount: 2000.0
@ -48,24 +42,21 @@
journal_id: account.sales_journal
name: First Payment to Axelor for Basic PC
period_id: account.period_5
-
Performing an osv_memory action pay_and_reconcile on module account.invoice.pay
I make partial payment by clicking on Partial Payment button
-
!python {model: account.invoice.pay}: |
self.pay_and_reconcile(cr, uid, [ref("account_invoice_pay_firstpaymenttoaxelorforbasicpc0")],
{"lang": 'en_US', "active_model": "account.invoice", "tz": False, "record_id":
25, "active_ids": [ref("account_invoice_1")], "type": "in_invoice", "active_id":
ref("account_invoice_1"), })
25, "active_ids": [ref("account_invoice_supplier0")], "type": "in_invoice", "active_id":
ref("account_invoice_supplier0"), })
-
I check that the invoice state is still open
I check that the invoice state is still "Open"
-
!assert {model: account.invoice, id: account_invoice_1}:
!assert {model: account.invoice, id: account_invoice_supplier0}:
- state == 'open'
-
I make final partial payment of 1000 by clicking on Pay Invoice button
-
Creating a account.invoice.pay record
I make final partial payment of 1000 EUR
-
!record {model: account.invoice.pay, id: account_invoice_pay_finalpaymenttoaxelorforbasicpc0}:
amount: 1000.0
@ -73,45 +64,23 @@
journal_id: account.sales_journal
name: Final Payment to Axelor for Basic PC
period_id: account.period_5
-
Performing an osv_memory action pay_and_reconcile on module account.invoice.pay
I make partial payment by clicking on Partial Payment button
-
!python {model: account.invoice.pay}: |
self.pay_and_reconcile(cr, uid, [ref("account_invoice_pay_finalpaymenttoaxelorforbasicpc0")],
{"lang": 'en_US', "active_model": "account.invoice", "tz": False, "record_id":
25, "active_ids": [ref("account_invoice_1")], "type": "in_invoice", "active_id":
ref("account_invoice_1"), })
25, "active_ids": [ref("account_invoice_supplier0")], "type": "in_invoice", "active_id":
ref("account_invoice_supplier0"), })
-
I check that the invoice state is now Done
I check that the invoice state is now "Done"
-
!assert {model: account.invoice, id: account_invoice_1}:
!assert {model: account.invoice, id: account_invoice_supplier0}:
- state == 'paid'
-
I check that an payment entry gets created in the account.move.line
I check that an payment entry gets created in the account move line
-
!python {model: account.invoice}: |
acc_id=self.browse(cr, uid, ref("account_invoice_1"))
acc_id=self.browse(cr, uid, ref("account_invoice_supplier0"))
assert(acc_id.move_id)
#-
# I refund the invoice
#-
# Creating a account.invoice.refund record
#-
# !record {model: account.invoice.refund, id: account_invoice_refund_0}:
# date: '2010-06-22'
# description: 'Refund By Axelor '
#
#
#-
# Performing an osv_memory action invoice_refund on module account.invoice.refund
#-
# !python {model: account.invoice.refund}: |
# self.invoice_refund(cr, uid, [ref("account_invoice_refund_0")], {"lang": 'en_US',
# "tz": False, "active_model": "account.invoice", "active_ids": [ref("account_invoice_1")],
# "type": "in_invoice", "active_id": ref("account_invoice_1"), })

View File

@ -0,0 +1,44 @@
-
In order to test account use models wizard in OpenERP I create an account model record
-
!record {model: account.model, id: account_model_mymodelonyears0}:
journal_id: account.expenses_journal
lines_id:
- account_id: account.a_recv
credit: 0.0
debit: 0.0
name: test1
sequence: 0.0
date: today
quantity: 0.0
name: My Model on %(year)s
-
I create an account use model record
-
!record {model: account.use.model, id: account_use_model_0}:
{}
-
I create entries.
-
!python {model: account.use.model}: |
self.create_entries(cr, uid, [ref("account_use_model_0")], {"lang": 'en_US', "active_model":
"account.model", "active_ids": [ref("account_model_mymodelonyears0")], "tz":
False, "active_id": ref("account_model_mymodelonyears0"), })
-
I create an account use model record
-
!record {model: account.use.model, id: account_use_model_1}:
{}
-
I checked that Moves are created successfully
-
!python {model: account.use.model}: |
self.open_moves(cr, uid, [ref("account_use_model_1")], {"lang": 'en_US', "move_ids":
[], "tz": False, "active_model": "account.model", "active_ids": [ref("account_model_mymodelonyears0")],
"active_id": ref("account_model_mymodelonyears0"), })

View File

@ -0,0 +1,60 @@
-
In order to test Validate Ledger Postings wizard in OpenERP I created a account move
-
!record {model: account.move, id: account_move_0}:
date: '2010-06-07'
journal_id: account.bank_journal
line_id:
- account_id: account.cash
amount_currency: 0.0
credit: 2000.0
date: '2010-06-07'
debit: 0.0
journal_id: account.bank_journal
name: Basic Computer
partner_id: base.res_partner_desertic_hispafuentes
period_id: account.period_6
ref: '2010010'
tax_amount: 0.0
- journal_id: account.bank_journal
period_id: account.period_6
ref: '2010010'
tax_amount: 0.0
account_id: account.a_recv
amount_currency: 0.0
credit: 0.0
date: '2010-06-07'
debit: 2000.0
name: Basic Computer
partner_id: base.res_partner_desertic_hispafuentes
quantity: 0.0
name: /
period_id: account.period_6
ref: '2010010'
state: draft
-
I check that Initially account move state is "Draft"
-
!assert {model: account.move, id: account_move_0}:
- state == 'draft'
-
I validate this account move by using Validate Ledger Postings
-
!record {model: validate.account.move, id: validate_account_move_0}:
journal_id: account.bank_journal
period_id: account.period_6
-
I clicked on validate Button
-
!python {model: validate.account.move}: |
self.validate_move(cr, uid, [ref("validate_account_move_0")], {"lang": "en_US",
"active_model": "ir.ui.menu", "active_ids": [ref("account.menu_validate_account_moves")],
"tz": False, "active_id": ref("account.menu_validate_account_moves"), })
-
I check that the invoice state is now "Posted"
-
!assert {model: account.move, id: account_move_0}:
- state == 'posted'

View File

@ -0,0 +1,75 @@
-
In order to check the Chart of Accounts wizard I run the wizard with target move set as all
-
!record {model: account.chart, id: account_chart_0}:
target_move: all
-
I clicked on Open chart Button to open the chart
-
!python {model: account.chart}: |
self.account_chart_open_window(cr, uid, [ref("account_chart_0")], {"lang": 'en_US',
"active_model": "ir.ui.menu", "active_ids": [ref("account.menu_action_account_tree2")],
"tz": False, "active_id": ref("account.menu_action_account_tree2"), })
-
I create chart of account with target move set as posted
-
!record {model: account.chart, id: account_chart_0}:
target_move: posted
-
I clicked on Open chart Button to open the chart
-
!python {model: account.chart}: |
self.account_chart_open_window(cr, uid, [ref("account_chart_0")], {"lang": 'en_US',
"active_model": "ir.ui.menu", "active_ids": [ref("account.menu_action_account_tree2")],
"tz": False, "active_id": ref("account.menu_action_account_tree2"), })
-
In order to test Account Move Line Wizard I check the move line entries using this wizard
-
!record {model: account.move.line.select, id: account_move_line_select_0}:
{}
-
I clicked on Button to open the account move lines
-
!python {model: account.move.line.select}: |
self.open_window(cr, uid, [ref("account_move_line_select_0")], {"lang": 'en_US',
"state": "all", "tz": False, "active_model": "account.account", "active_ids":
[ref("account.a_recv")], "fiscalyear": 1, "active_id": ref("account.a_recv"),
})
-
In order to test the Analytic Charts of Account wizard I will generate chart
-
!record {model: account.analytic.chart, id: account_analytic_chart_0}:
from_date: '2010-01-01'
to_date: '2010-06-30'
-
I clicked on Open chart Button to open the charts
-
!python {model: account.analytic.chart}: |
self.analytic_account_chart_open_window(cr, uid, [ref("account_analytic_chart_0")],
{"lang": 'en_US', "active_model": "ir.ui.menu", "active_ids": [ref("account.menu_action_analytic_account_tree2")],
"tz": False, "active_id": ref("account.menu_action_analytic_account_tree2"),
})
-
In order to test Account Journal Select wizard I open journal entries using this wizard
-
!record {model: account.journal.select, id: account_journal_select_0}:
{}
-
I clicked on Open Journal Button to open the entries
-
!python {model: account.journal.select}: |
self.action_open_window(cr, uid, [ref("account_journal_select_0")], {"lang":
'en_US', "active_model": "account.journal.period", "active_ids": [ref("account.a_recv")],
"tz": False, "active_id": ref("account.a_recv"), })
-
I check that the entries open successfully

View File

@ -22,6 +22,7 @@
import account_automatic_reconcile
import account_move_line_reconcile_select
import account_move_line_unreconcile_select
import account_reconcile_partner_process
import account_reconcile
import account_unreconcile
import account_invoice_refund

View File

@ -31,15 +31,16 @@ class account_automatic_reconcile(osv.osv_memory):
_columns = {
'account_ids': fields.many2many('account.account', 'reconcile_account_rel', 'reconcile_id', 'account_id', 'Account to reconcile', domain = [('reconcile','=',1)], \
help = 'If no account is specified, the reconciliation will be made using every accounts that can be reconcilied'),
'writeoff_acc_id': fields.many2one('account.account', 'Account', required=True),
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
'period_id': fields.many2one('account.period', 'Period', required=True),
'writeoff_acc_id': fields.many2one('account.account', 'Account'),
'journal_id': fields.many2one('account.journal', 'Journal'),
'period_id': fields.many2one('account.period', 'Period'),
'max_amount': fields.float('Maximum write-off amount'),
'power': fields.selection([(p, str(p)) for p in range(2, 10)], 'Power', required=True),
'power': fields.selection([(p, str(p)) for p in range(2, 10)], 'Power', required=True, help='Number of partial amounts that can be combined to find a balance point can be chosen as the power of the automatic reconciliation'),
'date1': fields.date('Start of period', required=True),
'date2': fields.date('End of period', required=True),
'reconciled': fields.integer('Reconciled transactions', readonly=True),
'unreconciled': fields.integer('Not reconciled transactions', readonly=True),
'allow_write_off': fields.boolean('Allow write off')
}
def _get_reconciled(self, cr, uid, context={}):
@ -145,16 +146,18 @@ class account_automatic_reconcile(osv.osv_memory):
if not form['account_ids']:
raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile'))
for account_id in form['account_ids']:
if not context.get('allow_write_off', False):
query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \
AND state <> 'draft' GROUP BY partner_id \
HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0)
# query="SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \
# AND state <> 'draft' GROUP BY partner_id AND debit = credi"%(account_id)
else:
query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \
AND state <> 'draft' GROUP BY partner_id \
HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0)
# reconcile automatically all transactions from partners whose balance is 0
cr.execute(
"SELECT partner_id " \
"FROM account_move_line " \
"WHERE account_id=%s " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"GROUP BY partner_id " \
"HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0",
(account_id, max_amount or 0.0))
cr.execute(query)
partner_ids = [id for (id,) in cr.fetchall()]
for partner_id in partner_ids:
cr.execute(
@ -167,63 +170,67 @@ class account_automatic_reconcile(osv.osv_memory):
(account_id, partner_id))
line_ids = [id for (id,) in cr.fetchall()]
if len(line_ids):
move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
reconciled += len(line_ids)
if not context.get('allow_write_off', False):
move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={})
else:
move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
# get the list of partners who have more than one unreconciled transaction
cr.execute(
"SELECT partner_id " \
"FROM account_move_line " \
"WHERE account_id=%s " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"AND partner_id IS NOT NULL " \
"GROUP BY partner_id " \
"HAVING count(*)>1",
(account_id,))
partner_ids = [id for (id,) in cr.fetchall()]
#filter?
for partner_id in partner_ids:
# get the list of unreconciled 'debit transactions' for this partner
cr.execute(
"SELECT id, debit " \
"FROM account_move_line " \
"WHERE account_id=%s " \
"AND partner_id=%s " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"AND debit > 0",
(account_id, partner_id))
debits = cr.fetchall()
# get the list of partners who have more than one unreconciled transaction
cr.execute(
"SELECT partner_id " \
"FROM account_move_line " \
"WHERE account_id=%s " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"AND partner_id IS NOT NULL " \
"GROUP BY partner_id " \
"HAVING count(*)>1",
(account_id,))
partner_ids = [id for (id,) in cr.fetchall()]
#filter?
for partner_id in partner_ids:
# get the list of unreconciled 'debit transactions' for this partner
cr.execute(
"SELECT id, debit " \
"FROM account_move_line " \
"WHERE account_id=%s " \
"AND partner_id=%s " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"AND debit > 0",
(account_id, partner_id))
debits = cr.fetchall()
# get the list of unreconciled 'credit transactions' for this partner
cr.execute(
"SELECT id, credit " \
"FROM account_move_line " \
"WHERE account_id=%s " \
"AND partner_id=%s " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"AND credit > 0",
(account_id, partner_id))
credits = cr.fetchall()
# get the list of unreconciled 'credit transactions' for this partner
cr.execute(
"SELECT id, credit " \
"FROM account_move_line " \
"WHERE account_id=%s " \
"AND partner_id=%s " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"AND credit > 0",
(account_id, partner_id))
credits = cr.fetchall()
(rec, unrec) = self.do_reconcile(cr, uid, credits, debits, max_amount, power, form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
reconciled += rec
unreconciled += unrec
(rec, unrec) = self.do_reconcile(cr, uid, credits, debits, max_amount, power, form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
reconciled += rec
unreconciled += unrec
# add the number of transactions for partners who have only one
# unreconciled transactions to the unreconciled count
partner_filter = partner_ids and 'AND partner_id not in (%s)' % ','.join(map(str, filter(None, partner_ids))) or ''
cr.execute(
"SELECT count(*) " \
"FROM account_move_line " \
"WHERE account_id=%s " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " + partner_filter,
(account_id,))
additional_unrec = cr.fetchone()[0]
context.update({'reconciled': reconciled, 'unreconciled': unreconciled + additional_unrec})
# add the number of transactions for partners who have only one
# unreconciled transactions to the unreconciled count
partner_filter = partner_ids and 'AND partner_id not in (%s)' % ','.join(map(str, filter(None, partner_ids))) or ''
cr.execute(
"SELECT count(*) " \
"FROM account_move_line " \
"WHERE account_id=%s " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " + partner_filter,
(account_id,))
additional_unrec = cr.fetchone()[0]
unreconciled = unreconciled + additional_unrec
context.update({'reconciled': reconciled, 'unreconciled': unreconciled})
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','account_automatic_reconcile_view1')])
resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
return {
@ -239,4 +246,4 @@ class account_automatic_reconcile(osv.osv_memory):
account_automatic_reconcile()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -8,21 +8,29 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Reconciliation">
<group width="660" height="430">
<separator string="Options" colspan="4"/>
<group>
<field name="account_ids" colspan="4" domain="[('reconcile','=',1)]"/>
<field name="date1"/>
<field name="date2"/>
<field name="power"/>
<separator string="Write-Off Move" colspan="4"/>
<field name="max_amount"/>
<field name="writeoff_acc_id"/>
<field name="journal_id"/>
<field name="period_id"/>
<field name="allow_write_off"/>
</group>
<newline/>
<group attrs="{'readonly':[('allow_write_off', '!=', True)]}">
<separator string="Write-Off Move" colspan="4"/>
<field name="max_amount"/>
<field name="writeoff_acc_id" attrs="{ 'required':[('allow_write_off', '=', True)]}"/>
<field name="journal_id" attrs="{ 'required':[('allow_write_off', '=', True)]}"/>
<field name="period_id" attrs="{ 'required':[('allow_write_off', '=', True)]}"/>
</group>
<separator string ="" colspan="4"/>
<group colspan="2" col="4">
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="reconcile" string="Reconcile" type="object" icon="terp-stock_effects-object-colorize"/>
</group>
</group>
</form>
</field>
</record>
@ -40,10 +48,10 @@
<menuitem
icon="STOCK_EXECUTE"
name="Automatic reconciliation"
name="Automatic Reconciliation"
action="action_account_automatic_reconcile"
id="menu_automatic_reconcile"
parent="next_id_20"/>
parent="periodical_processing_reconciliation"/>
<record id="account_automatic_reconcile_view1" model="ir.ui.view">
<field name="name">Automatic reconcile unreconcile</field>
@ -64,4 +72,3 @@
</data>
</openerp>

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

@ -2,18 +2,18 @@
<openerp>
<data>
<record id="view_account_chart" model="ir.ui.view">
<record id="view_account_chart" model="ir.ui.view">
<field name="name">account.chart.form</field>
<field name="model">account.chart</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account charts">
<group colspan="4" >
<field name="fiscalyear"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal years)"/>
<field name="target_move"/>
<group colspan="4" >
<field name="fiscalyear"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal years)"/>
<field name="target_move"/>
</group>
<separator string="" colspan="4" />
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel" />
@ -22,7 +22,7 @@
</group>
</form>
</field>
</record>
</record>
<record id="action_account_chart" model="ir.actions.act_window">
<field name="name">Chart of Accounts</field>
@ -34,7 +34,7 @@
</record>
<menuitem icon="STOCK_INDENT" action="action_account_chart"
id="menu_action_account_tree2"
parent="account.menu_finance_charts" />
id="menu_action_account_tree2"
parent="account.menu_finance_charts" />
</data>
</openerp>
</openerp>

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

@ -31,7 +31,7 @@
</record>
<record id="action_account_fiscalyear_close" model="ir.actions.act_window">
<field name="name">Generate Fiscal Year Opening Entries</field>
<field name="name">Generate Opening Entries</field>
<field name="res_model">account.fiscalyear.close</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>

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

@ -8,8 +8,8 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Journal Select">
<label string="Are you sure you want to open Journal Entries!" colspan="4"/>
<separator string="" colspan="4" />
<label string="Are you sure you want to open Journal Entries!" colspan="4"/>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="terp-gtk-stop" special="cancel" string="Cancel"/>
<button icon="terp-gtk-go-back-rtl" string="Open Entries" name="action_open_window" type="object"/>

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

@ -32,10 +32,10 @@
<field name="target">new</field>
</record>
<menuitem icon="STOCK_JUSTIFY_FILL"
action="action_account_move_journal_line_form"
id="menu_action_move_journal_line_form"
parent="account.menu_finance_entries" sequence="5" />
<!-- <menuitem icon="STOCK_JUSTIFY_FILL"-->
<!-- action="action_account_move_journal_line_form"-->
<!-- id="menu_action_move_journal_line_form"-->
<!-- parent="account.menu_finance_entries" sequence="5" />-->
</data>
</openerp>

View File

@ -31,8 +31,8 @@
<field name="target">new</field>
</record>
<menuitem action="action_account_reconcile_select"
id="menu_reconcile_select" parent="account.next_id_20" />
<!-- <menuitem action="action_account_reconcile_select"
id="menu_reconcile_select" parent="periodical_processing_reconciliation" /> -->
</data>
</openerp>

View File

@ -43,7 +43,6 @@ class account_move_line_select(osv.osv_memory):
else:
fiscalyear_ids = [context['fiscalyear']]
fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')])
fiscalyears = fiscalyear_obj.browse(cr, uid, fiscalyear_ids)
period_ids = []

View File

@ -31,8 +31,8 @@
<field name="target">new</field>
</record>
<menuitem action="action_account_unreconcile_select"
id="menu_unreconcile_select" parent="account.next_id_20" />
<!-- <menuitem action="action_account_unreconcile_select"
id="menu_unreconcile_select" parent="periodical_processing_reconciliation" /> -->
</data>
</openerp>

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

@ -29,9 +29,9 @@
<field name="target">new</field>
</record>
<menuitem action="action_account_open_closed_fiscalyear"
id="menu_wizard_open_closed_fy" sequence="2"
parent="account.menu_account_end_year_treatments" />
<!-- <menuitem action="action_account_open_closed_fiscalyear"-->
<!-- id="menu_wizard_open_closed_fy" sequence="2"-->
<!-- parent="account.menu_account_end_year_treatments" />-->
</data>
</openerp>

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):
@ -56,11 +56,11 @@ class account_move_line_reconcile(osv.osv_memory):
if 'trans_nbr' in fields:
res.update({'trans_nbr':data['trans_nbr']})
if 'credit' in fields:
res.update({'trans_nbr':data['credit']})
res.update({'credit':data['credit']})
if 'debit' in fields:
res.update({'trans_nbr':data['debit']})
res.update({'debit':data['debit']})
if 'writeoff' in fields:
res.update({'trans_nbr':data['writeoff']})
res.update({'writeoff':data['writeoff']})
return res
def partial_check(self, cr, uid, ids, context=None):

View File

@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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/>.
#
##############################################################################
import time
from osv import osv, fields
from tools.translate import _
class account_partner_reconcile_process(osv.osv_memory):
_name = 'account.partner.reconcile.process'
_description = 'Reconcilation Process partner by partner'
def _get_to_reconcile(self, cr, uid, context=None):
cr.execute(
"SELECT l.partner_id " \
"FROM account_move_line AS l LEFT JOIN res_partner p ON (p.id = l.partner_id) " \
"WHERE l.reconcile_id IS NULL " \
"AND (%s > to_char(p.last_reconciliation_date, 'YYYY-MM-DD') " \
"OR p.last_reconciliation_date IS NULL ) " \
"AND l.state <> 'draft' " \
"GROUP BY l.partner_id ",(time.strftime('%Y-%m-%d'),)
)
return len(map(lambda x: x[0], cr.fetchall())) - 1
def _get_today_reconciled(self, cr, uid, context=None):
cr.execute(
"SELECT l.partner_id " \
"FROM account_move_line AS l LEFT JOIN res_partner p ON (p.id = l.partner_id) " \
"WHERE l.reconcile_id IS NULL " \
"AND %s = to_char(p.last_reconciliation_date, 'YYYY-MM-DD') " \
"AND l.state <> 'draft' " \
"GROUP BY l.partner_id ",(time.strftime('%Y-%m-%d'),)
)
return len(map(lambda x: x[0], cr.fetchall())) + 1
def _get_partner(self, cr, uid, context=None):
partner = self.pool.get('account.move.line').get_next_partner_only(cr, uid, offset=1, context=context)
if not partner:
return False
return partner[0]
def data_get(self, cr, uid, to_reconcile, today_reconciled, context=None):
return {'progress': (100 / float(to_reconcile + today_reconciled)) * today_reconciled}
def default_get(self, cr, uid, fields, context=None):
res = super(account_partner_reconcile_process, self).default_get(cr, uid, fields, context=context)
if 'to_reconcile' in res and 'today_reconciled' in res:
data = self.data_get(cr, uid, res['to_reconcile'], res['today_reconciled'], context)
res.update(data)
return res
def next_partner(self, cr, uid, ids, context=None):
partner_id = self.pool.get('account.move.line').read(cr, uid, context['active_id'], ['partner_id'])['partner_id'][0]
self.pool.get('res.partner').write(cr, uid, partner_id, {'last_reconciliation_date': time.strftime('%Y-%m-%d')}, context)
#TODO: we have to find a way to update the context of the current tab (we could open a new tab with the context but it's not really handy)
#TODO: remove that comments when the client side dev is done
#context.update({'partner_id': self.browse(cr, uid, ids, context)[0].next_partner_id})
#return {'context': context,
# 'target': 'opener',
# 'name': 'reconciliation process',
# 'view_type': 'form',
# 'view_mode': 'tree,form',
# 'res_model': 'account.move.line',
# 'type': 'ir.actions.act_window'
#}
return {}
_columns = {
'to_reconcile': fields.float('Remaining Partners', readonly=True, help='This is the remaining partners for who you should check if there is something to reconcile or not. This figure already count the current partner as reconciled.'),
'today_reconciled': fields.float('Partners Reconciled Today', readonly=True, help='This figure depicts the total number of partners that have gone throught the reconciliation process today. The current partner is counted as already processed.'),
'progress': fields.float('Progress', readonly=True, help='Shows you the progress made today on the reconciliation process. Given by \nPartners Reconciled Today \ (Remaining Partners + Partners Reconciled Today)'),
'next_partner_id': fields.many2one('res.partner', 'Next Partner to Reconcile', readonly=True, help='This field shows you the next partner that will be automatically chosen by the system to go through the reconciliation process, based on the latest day it have been reconciled.'), # TODO: remove the readonly=True when teh client side will allow to update the context of existing tab, so that the user can change this value if he doesn't want to follow openerp proposal
}
_defaults = {
'to_reconcile': _get_to_reconcile,
'today_reconciled': _get_today_reconciled,
'next_partner_id': _get_partner,
}
account_partner_reconcile_process()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="account_partner_reconcile_view" model="ir.ui.view">
<field name="name">Partner Reconcilation Process</field>
<field name="model">account.partner.reconcile.process</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Partner Reconciliation">
<field name="progress" widget="progressbar" colspan="4"/>
<field name="today_reconciled"/>
<field name="to_reconcile"/>
<newline/>
<field name="next_partner_id" colspan="4"/>
<newline/>
<group colspan="4" col="4">
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="next_partner" icon="gtk-go-forward" type="object" string="Go to next partner" />
</group>
</form>
</field>
</record>
<record id="action_account_partner_reconcile" model="ir.actions.act_window">
<field name="name">Reconciliation: Go to Next Partner</field>
<field name="res_model">account.partner.reconcile.process</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="account_partner_reconcile_view"/>
<field name="context">{'record_id':active_id}</field>
<field name="target">new</field>
</record>
<record model="ir.values" id="action_partner_reconcile_actino">
<field name="model_id" ref="account.model_account_move_line" />
<field name="object" eval="1" />
<field name="name">Partner reconciliation</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_partner_reconcile'))" />
<field name="key">action</field>
<field name="model">account.move.line</field>
</record>
<!-- <menuitem
icon="STOCK_EXECUTE"
name="Partner reconciliation"
action="action_account_partner_reconcile"
id="menu_partner_reconcile"
parent="account.next_id_20"/>
-->
</data>
</openerp>

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

@ -32,7 +32,7 @@
<field name="target">new</field>
</record>
<menuitem action="action_account_subscription_generate" id="menu_generate_subscription" parent="account.menu_finance_periodical_processing" />
<menuitem action="action_account_subscription_generate" id="menu_generate_subscription" parent="menu_finance_periodical_processing" />
</data>
</openerp>

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

@ -7,15 +7,17 @@
<field name="model">account.use.model</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create Entries From Models">
<group colspan="4" >
<field name="model"/>
</group>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Create Entries" name="create_entries" type="object"/>
</group>
</form>
<form string="Create Entries From Models">
<group height="240" width="510">
<separator string="This wizard will create entries from Models" colspan="4"/>
<field name="model"/>
<separator colspan="4"/>
<group colspan="4" col="2">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Create Entries" name="create_entries" type="object"/>
</group>
</group>
</form>
</field>
</record>

View File

@ -34,7 +34,7 @@
<menuitem
name="Validate Ledger Postings"
parent="account.menu_finance_periodical_processing"
parent="periodical_processing_journal_entries_validation"
action="action_validate_account_move"
id="menu_validate_account_moves"
/>

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

@ -1,6 +1,6 @@
<openerp>
<data>
<menuitem icon="terp-project" id="base.menu_main_pm" name="Project Management" sequence="1"/>
<menuitem icon="terp-project" id="base.menu_main_pm" name="Project" sequence="10"/>
<!-- <menuitem id="next_id_71" name="Financial Project Management" parent="base.menu_main_pm" groups="account.group_account_invoice" sequence="20"/>-->
<menuitem id="menu_invoicing" name="Billing" parent="base.menu_main_pm" sequence="4"/>

View File

@ -42,10 +42,10 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
action="action_analytic_default_form"
id="menu_analytic_defaul_form"
parent="account.menu_analytic_accounting"/>
<!-- <menuitem-->
<!-- action="action_analytic_default_form"-->
<!-- id="menu_analytic_defaul_form"-->
<!-- parent="account.menu_analytic_accounting"/>-->
<act_window
domain="[('account_id', '=', active_id)]" id="act_account_acount_move_line_open" name="Entries" res_model="account.move.line" src_model="account.account"/>

View File

@ -83,20 +83,22 @@ 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"),
}
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
if context is None:
context = {}
if context.get('journal_id', False):
journal = self.pool.get('account.journal').browse(cr, user, [context['journal_id']], context=context)[0]
analytic_journal = journal.analytic_journal_id and journal.analytic_journal_id.id or False
@ -184,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)))
@ -206,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)
@ -230,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 = {
@ -252,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()
@ -260,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):
@ -286,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):
@ -355,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

@ -129,10 +129,10 @@
src_model="account.analytic.plan"
id="account_analytic_instance_model_open"/>
<menuitem
name="Analytic Distribution's models" parent="account.account_def_analytic_journal"
id="menu_account_analytic_plan_instance_action"
action="account_analytic_plan_instance_action"/>
<!-- <menuitem-->
<!-- name="Analytic Distribution's models" parent="account.account_def_analytic_journal"-->
<!-- id="menu_account_analytic_plan_instance_action"-->
<!-- action="account_analytic_plan_instance_action"/>-->
<record model="ir.ui.view" id="account_analytic_plan_instance_line_form">
<field name="name">account.analytic.plan.instance.line.form</field>
@ -192,11 +192,16 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
parent="account.account_analytic_def_account"
id="menu_account_analytic_plan_action"
action="account_analytic_plan_form_action"/>
<menuitem
parent="account.menu_analytic"
name="Multi Plans"
id="menu_account_analytic_multi_plan_action"
/>
<menuitem
parent="menu_account_analytic_multi_plan_action"
id="menu_account_analytic_plan_action"
action="account_analytic_plan_form_action"/>
<record model="ir.ui.view" id="account_analytic_plan_line_form">
<field name="name">account.analytic.plan.line.form</field>

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

@ -1,5 +1,5 @@
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@ -14,7 +14,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/>.
#
##############################################################################
{
@ -22,11 +22,11 @@
"version" : "1.2",
"author" : "Tiny, Veritos",
"website" : "http://tinyerp.com - http://veritos.nl",
"description" : """This module will support the Anglo-Saxons accounting methodology by
changing the accounting logic with stock transactions. The difference between the Anglo-Saxon accounting countries
and the Rhine or also called Continental accounting countries is the moment of taking the Cost of Goods Sold versus Cost of Sales.
Anglo-Saxons accounting does take the cost when sales invoice is created, Continental accounting will take the cost at he moment the goods are shipped.
This module will add this functionality by using a interim account, to store the value of shipped goods and will contra book this interim account
"description" : """This module will support the Anglo-Saxons accounting methodology by
changing the accounting logic with stock transactions. The difference between the Anglo-Saxon accounting countries
and the Rhine or also called Continental accounting countries is the moment of taking the Cost of Goods Sold versus Cost of Sales.
Anglo-Saxons accounting does take the cost when sales invoice is created, Continental accounting will take the cost at the moment the goods are shipped.
This module will add this functionality by using a interim account, to store the value of shipped goods and will contra book this interim account
when the invoice is created to transfer this amount to the debtor or creditor account.
Secondly, price differences between actual purchase price and fixed product standard price are booked on a seperate account""",
"depends" : ["product", "account", "sale", "purchase", "stock"],

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

@ -62,6 +62,10 @@ Three reports are available:
'wizard/account_budget_crossovered_report_view.xml',
],
'demo_xml': ['crossovered_budget_demo.xml'],
'test':[
# 'test/account_budget_spread.yml',
'test/account_budget.yml',
],
'installable': True,
'active': False,
'certificate': '0043819694157',

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

@ -316,7 +316,7 @@
menu="False"/>-->
<!--Menu for project management-->
<menuitem icon="terp-project" id="base.menu_main_pm" name="Project Management" sequence="1"/>
<menuitem icon="terp-project" id="base.menu_main_pm" name="Project" sequence="10"/>
<menuitem id="base.menu_pm_invoicing" name="Billing" parent="base.menu_main_pm" sequence="7"/>
<menuitem id="menu_pm_budget" name="Budgets" parent="base.menu_pm_invoicing"/>
<menuitem action="open_budget_post_form" id="menu_pm_budget_post_form" parent="menu_pm_budget"/>

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={}

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