diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index d4731fa0215..cea696f590f 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -107,8 +107,11 @@ module named account_voucherss 'company_view.xml', 'account_installer.xml', 'report/account_invoice_report_view.xml', + 'report/account_entries_report_view.xml', 'report/account_report_view.xml', 'report/account_analytic_report_view.xml', + 'report/account_account_report_view.xml', + 'report/account_analytic_entries_report_view.xml' ], 'demo_xml': [ #'demo/price_accuracy00.yml', diff --git a/addons/account/account.py b/addons/account/account.py index 969f843bec9..5181028c17b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -122,6 +122,16 @@ class account_account_type(osv.osv): 'partner_account': fields.boolean('Partner account'), 'close_method': fields.selection([('none', 'None'), ('balance', 'Balance'), ('detail', 'Detail'), ('unreconciled', 'Unreconciled')], 'Deferral Method', required=True), 'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign on Reports', required=True, help='Allows you to change the sign of the balance amount displayed in the reports, so that you can see positive figures instead of negative ones in expenses accounts.'), + 'report_type':fields.selection([ + ('none','/'), + ('income','Profilt & Loss (Income Accounts)'), + ('expanse','Profilt & Loss (Expanse Accounts)'), + ('asset','Balance Sheet (Assets Accounts)'), + ('liabilities','Balance Sheet (Liabilities Accounts)') + ],'Type Heads', select=True, readonly=False, help="According value related accounts will be display on respective reports (Balance Sheet Profit & Loss Account)"), + 'parent_id':fields.many2one('account.account.type', 'Parent Type', required=False), + 'child_ids':fields.one2many('account.account.type', 'parent_id', 'Child Types', required=False), + 'note': fields.text('Description'), } _defaults = { 'close_method': lambda *a: 'none', @@ -129,6 +139,15 @@ class account_account_type(osv.osv): 'sign': lambda *a: 1, } _order = "sequence" + + def _check_recursion(self, cr, uid, ids): + #TODO: Need to check for recusrion + return True + + _constraints = [ + (_check_recursion, 'Error ! You can not create recursive types.', ['parent_id']) + ] + account_account_type() def _code_get(self, cr, uid, context={}): @@ -212,9 +231,9 @@ class account_account(osv.osv): aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) wheres = [""] - if query: + if query.strip(): wheres.append(query.strip()) - if aml_query: + if aml_query.strip(): wheres.append(aml_query.strip()) query = " AND ".join(wheres) @@ -232,6 +251,7 @@ class account_account(osv.osv): # consolidate accounts with direct children + ids2.reverse() brs = list(self.browse(cr, uid, ids2, context=context)) sums = {} while brs: @@ -251,8 +271,9 @@ class account_account(osv.osv): 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[id] + res[id] = sums.get(id, null_result) return res def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}): @@ -294,7 +315,7 @@ class account_account(osv.osv): 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, help="These types are defined according to your country. The type contains more information "\ "about the account and its specificities."), - 'parent_id': fields.many2one('account.account', 'Parent', ondelete='cascade'), + 'parent_id': fields.many2one('account.account', 'Parent', ondelete='cascade', domain=[('type','=','view')]), 'child_parent_ids': fields.one2many('account.account','parent_id','Children'), 'child_consol_ids': fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children'), 'child_id': fields.function(_get_child_ids, method=True, type='many2many', relation="account.account", string="Child Accounts"), @@ -431,18 +452,42 @@ class account_account(osv.osv): def _check_moves(self, cr, uid, ids, method, context): line_obj = self.pool.get('account.move.line') account_ids = self.search(cr, uid, [('id', 'child_of', ids)]) + if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]): if method == 'write': raise osv.except_osv(_('Error !'), _('You cannot deactivate an account that contains account moves.')) elif method == 'unlink': raise osv.except_osv(_('Error !'), _('You cannot remove an account which has account entries!. ')) + #Checking whether the account is set as a property to any Partner or not + value = 'account.account,' + str(ids[0]) + partner_prop_acc = self.pool.get('ir.property').search(cr, uid, [('value_reference','=',value)], context=context) + if partner_prop_acc: + raise osv.except_osv(_('Warning !'), _('You cannot remove/deactivate an account which is set as a property to any Partner.')) + return True + + def _check_allow_type_change(self, cr, uid, ids, new_type, context): + group1 = ['payable', 'receivable', 'other'] + group2 = ['consolidation','view'] + line_obj = self.pool.get('account.move.line') + for account in self.browse(cr, uid, ids, context=context): + old_type = account.type + account_ids = self.search(cr, uid, [('id', 'child_of', [account.id])]) + if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]): + #Check for 'Closed' type + if old_type == 'closed' and new_type !='closed': + raise osv.except_osv(_('Warning !'), _("You cannot change the type of account from 'Closed' to any other type which contains account entries!")) + #Check for change From group1 to group2 and vice versa + if (old_type in group1 and new_type in group2) or (old_type in group2 and new_type in group1): + raise osv.except_osv(_('Warning !'), _("You cannot change the type of account from '%s' to '%s' type as it contains account entries!") % (old_type,new_type,)) return True def write(self, cr, uid, ids, vals, context=None): - if not context: + if context is None: context = {} if 'active' in vals and not vals['active']: self._check_moves(cr, uid, ids, "write", 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) def unlink(self, cr, uid, ids, context={}): @@ -515,6 +560,7 @@ class account_journal(osv.osv): 'company_id': fields.many2one('res.company', 'Company', required=True,select=1), '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 = { @@ -537,15 +583,16 @@ class account_journal(osv.osv): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: - args=[] - if not context: - context={} + args = [] + if context is None: + context = {} ids = [] if name: - ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit) + ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit, context=context) if not ids: - ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) + ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context) return self.name_get(cr, user, ids, context=context) + account_journal() class account_fiscalyear(osv.osv): @@ -611,6 +658,19 @@ class account_fiscalyear(osv.osv): else: return False return ids[0] + + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): + if args is None: + args = [] + if context is None: + context = {} + ids = [] + if name: + ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit) + if not ids: + ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) + return self.name_get(cr, user, ids, context=context) + account_fiscalyear() class account_period(osv.osv): @@ -686,12 +746,24 @@ class account_period(osv.osv): cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) cr.execute('update account_period set state=%s where id=%s', (mode, id)) return True + + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): + if args is None: + args = [] + if context is None: + context = {} + ids = [] + if name: + ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit) + if not ids: + ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) + return self.name_get(cr, user, ids, context=context) account_period() class account_journal_period(osv.osv): _name = "account.journal.period" - _description = "Journal - Period" + _description = "Journal Period" def _icon_get(self, cr, uid, ids, field_name, arg=None, context={}): result = {}.fromkeys(ids, 'STOCK_NEW') @@ -930,7 +1002,6 @@ class account_move(osv.osv): l[2]['period_id'] = default_period context['period_id'] = default_period - accnt_journal = self.pool.get('account.journal').browse(cr, uid, vals['journal_id']) if 'line_id' in vals: c = context.copy() c['novalidate'] = True @@ -1228,7 +1299,7 @@ class account_tax_code(osv.osv): _description = 'Tax Code' _rec_name = 'code' _columns = { - 'name': fields.char('Tax Case Name', size=64, required=True), + 'name': fields.char('Tax Case Name', size=64, required=True, translate=True), 'code': fields.char('Case Code', size=64), 'info': fields.text('Description'), 'sum': fields.function(_sum_year, method=True, string="Year Sum"), @@ -1242,6 +1313,15 @@ class account_tax_code(osv.osv): } + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): + if not args: + args = [] + if context is None: + context = {} + ids = self.search(cr, user, ['|',('name',operator,name),('code',operator,name)] + args, limit=limit, context=context) + return self.name_get(cr, user, ids, context) + + def name_get(self, cr, uid, ids, context=None): if not len(ids): return [] @@ -1270,7 +1350,15 @@ class account_tax_code(osv.osv): return False level -= 1 return True + + def copy(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} + default = default.copy() + default.update({'line_ids': []}) + return super(account_tax_code, self).copy(cr, uid, id, default, context) + _constraints = [ (_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']) ] diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index ce6341cc9b2..ba33185119e 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -30,7 +30,7 @@ from tools import config class account_analytic_line(osv.osv): _inherit = 'account.analytic.line' - _description = 'Analytic lines' + _description = 'Analytic Line' _columns = { 'product_uom_id' : fields.many2one('product.uom', 'UoM'), 'product_id' : fields.many2one('product.product', 'Product'), @@ -42,7 +42,7 @@ class account_analytic_line(osv.osv): } _defaults = { 'date': lambda *a: time.strftime('%Y-%m-%d'), - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', c), + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c), } _order = 'date' @@ -118,7 +118,7 @@ account_analytic_line() class timesheet_invoice(osv.osv): _name = "report.hr.timesheet.invoice.journal" - _description = "Analytic account costs and revenues" + _description = "Analytic Account Costs and Revenues" _auto = False _columns = { 'name': fields.char('Year',size=64,required=False, readonly=True), @@ -167,7 +167,7 @@ class res_partner(osv.osv): _columns = { 'contract_ids': fields.one2many('account.analytic.account', \ - 'partner_id', 'Contracts'), + 'partner_id', 'Contracts', readonly=True), } res_partner() diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index deb010c7cd0..81b6e3157a1 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -387,7 +387,7 @@ account_bank_statement() class account_bank_statement_reconcile(osv.osv): _name = "account.bank.statement.reconcile" - _description = "Statement reconcile" + _description = "Statement Reconcile" def _total_entry(self, cursor, user, ids, name, attr, context=None): result = {} @@ -558,35 +558,40 @@ class account_bank_statement_line(osv.osv): def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context={}): + res = {'value': {}} if not partner_id: - return {} - res_currency_obj = self.pool.get('res.currency') - res_users_obj = self.pool.get('res.users') - - company_currency_id = res_users_obj.browse(cursor, user, user, - context=context).company_id.currency_id.id - - if not currency_id: - currency_id = company_currency_id - - part = self.pool.get('res.partner').browse(cursor, user, partner_id, + return res + line = self.browse(cursor, user, line_id) + + if not line or (line and not line[0].account_id): + part = self.pool.get('res.partner').browse(cursor, user, partner_id, context=context) - if type == 'supplier': - account_id = part.property_account_payable.id - else: - account_id = part.property_account_receivable.id + if type == 'supplier': + account_id = part.property_account_payable.id + else: + account_id = part.property_account_receivable.id + res['value']['account_id'] = account_id - cursor.execute('SELECT sum(debit-credit) \ + if not line or (line and not line[0].amount): + res_users_obj = self.pool.get('res.users') + res_currency_obj = self.pool.get('res.currency') + company_currency_id = res_users_obj.browse(cursor, user, user, + context=context).company_id.currency_id.id + if not currency_id: + currency_id = company_currency_id + + cursor.execute('SELECT sum(debit-credit) \ FROM account_move_line \ WHERE (reconcile_id is null) \ AND partner_id = %s \ AND account_id=%s', (partner_id, account_id)) - res = cursor.fetchone() - balance = res and res[0] or 0.0 + pgres = cursor.fetchone() + balance = pgres and pgres[0] or 0.0 - balance = res_currency_obj.compute(cursor, user, company_currency_id, + balance = res_currency_obj.compute(cursor, user, company_currency_id, currency_id, balance, context=context) - return {'value': {'amount': balance, 'account_id': account_id}} + res['value']['amount'] = balance + return res def _reconcile_amount(self, cursor, user, ids, name, args, context=None): if not ids: @@ -625,7 +630,7 @@ class account_bank_statement_line(osv.osv): 'statement_id': fields.many2one('account.bank.statement', 'Statement', select=True, required=True, ondelete='cascade'), 'reconcile_id': fields.many2one('account.bank.statement.reconcile', - 'Reconcile', states={'confirm':[('readonly',True)]}), + 'Reconcile'), 'move_ids': fields.many2many('account.move', 'account_bank_statement_line_move_rel', 'move_id','statement_id', 'Moves'), @@ -633,7 +638,7 @@ class account_bank_statement_line(osv.osv): 'note': fields.text('Notes'), 'reconcile_amount': fields.function(_reconcile_amount, string='Amount reconciled', method=True, type='float'), - 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of bank statement line."), + 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of bank statement lines."), } _defaults = { 'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'), diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 16e3cc656cd..ac11b019ec2 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -351,7 +351,7 @@ - + @@ -479,22 +479,7 @@ - + - - res.partner.invoice.info.inherit - res.partner - form - - - - - - - - - - - diff --git a/addons/account/account_invoice_workflow.xml b/addons/account/account_invoice_workflow.xml index 374a436e9ac..4c919765596 100644 --- a/addons/account/account_invoice_workflow.xml +++ b/addons/account/account_invoice_workflow.xml @@ -50,7 +50,7 @@ write({'state':'open'}) paid - write({'state':'paid'}) + confirm_paid() function subflow.paid diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 37d539a4b25..4cdcb7787b6 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -22,6 +22,7 @@ groups="group_account_user"/> + diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index b9aa089942e..36b65d20dca 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -30,7 +30,7 @@ import tools class account_move_line(osv.osv): _name = "account.move.line" - _description = "Entry lines" + _description = "Entry Lines" def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') @@ -577,11 +577,12 @@ class account_move_line(osv.osv): merges_rec = [] for line in self.browse(cr, uid, ids, context): if line.reconcile_id: - raise osv.except_osv(_('Already Reconciled'), _('Already Reconciled')) + raise osv.except_osv(_('Warning'), _('Already Reconciled!')) if line.reconcile_partial_id: for line2 in line.reconcile_partial_id.line_partial_ids: if not line2.reconcile_id: - merges.append(line2.id) + if line2.id not in merges: + merges.append(line2.id) total += (line2.debit or 0.0) - (line2.credit or 0.0) merges_rec.append(line.reconcile_partial_id.id) else: @@ -774,6 +775,17 @@ class account_move_line(osv.osv): result['fields'] = self.fields_get(cr, uid, fields, context) return result + def _check_moves(self, cr, uid, context): + # use the first move ever created for this journal and period + cr.execute('select id, state, name from account_move where journal_id=%s and period_id=%s order by id limit 1', (context['journal_id'],context['period_id'])) + res = cr.fetchone() + if res: + if res[1] != 'draft': + raise osv.except_osv(_('UserError'), + _('The account move (%s) for centralisation ' \ + 'has been confirmed!') % res[2]) + return res + def unlink(self, cr, uid, ids, context={}, check=True): self._update_check(cr, uid, ids, context) result = False @@ -785,12 +797,35 @@ class account_move_line(osv.osv): self.pool.get('account.move').validate(cr, uid, [line.move_id.id], context=context) return result + def _check_date(self, cr, uid, vals, context=None, check=True): + if context is None: + context = {} + if 'date' in vals.keys(): + if 'journal_id' in vals and 'journal_id' not in context: + journal_id = vals['journal_id'] + if 'period_id' in vals and 'period_id' not in context: + period_id = vals['period_id'] + elif 'journal_id' not in context and 'move_id' in vals: + m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) + 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 !')) + else: + return True + def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): - if not context: + if context is None: context={} if vals.get('account_tax_id', False): raise osv.except_osv(_('Unable to change tax !'), _('You can not change the tax, you should remove and recreate lines !')) - + self._check_date(cr, uid, vals, context, check) account_obj = self.pool.get('account.account') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) @@ -802,6 +837,24 @@ 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): + if line.move_id: + ctx['journal_id'] = line.move_id.journal_id.id + else: + ctx['journal_id'] = line.journal_id.id + if ('period_id' not in ctx): + if line.move_id: + ctx['period_id'] = line.move_id.period_id.id + else: + 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) + result = super(account_move_line, self).write(cr, uid, ids, vals, context) if check: @@ -844,10 +897,11 @@ class account_move_line(osv.osv): return True def create(self, cr, uid, vals, context=None, check=True): - if not context: - context={} account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') + if context is None: + context = {} + self._check_date(cr, uid, vals, context, check) if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals and 'journal_id' not in context: @@ -867,14 +921,9 @@ class account_move_line(osv.osv): is_new_move = False if not move_id: if journal.centralisation: - # use the first move ever created for this journal and period - cr.execute('select id, state, name from account_move where journal_id=%s and period_id=%s order by id limit 1', (context['journal_id'],context['period_id'])) - res = cr.fetchone() + #Check for centralisation + res = self._check_moves(cr, uid, context) if res: - if res[1] != 'draft': - raise osv.except_osv(_('UserError'), - _('The Ledger Posting (%s) for centralisation ' \ - 'has been confirmed!') % res[2]) vals['move_id'] = res[0] if not vals.get('move_id', False): @@ -902,7 +951,7 @@ class account_move_line(osv.osv): break if journal.account_control_ids and not ok: for a in journal.account_control_ids: - if a.id==vals['account_id']: + if a.id == vals['account_id']: ok = True break if (account.currency_id) and 'amount_currency' not in vals and account.currency_id.id <> company_currency: @@ -917,7 +966,7 @@ class account_move_line(osv.osv): if not ok: raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal !')) - if 'analytic_account_id' in vals and vals['analytic_account_id']: + if vals.get('analytic_account_id',False): if journal.analytic_journal_id: vals['analytic_lines'] = [(0,0, { 'name': vals['name'], @@ -937,8 +986,8 @@ class account_move_line(osv.osv): result = super(osv.osv, self).create(cr, uid, vals, context) # CREATE Taxes - if 'account_tax_id' in vals and vals['account_tax_id']: - tax_id=tax_obj.browse(cr,uid,vals['account_tax_id']) + if vals.get('account_tax_id',False): + tax_id = tax_obj.browse(cr, uid, vals['account_tax_id']) total = vals['debit'] - vals['credit'] if journal.refund_journal: base_code = 'ref_base_code_id' @@ -954,7 +1003,7 @@ class account_move_line(osv.osv): tax_sign = 'tax_sign' tmp_cnt = 0 - for tax in tax_obj.compute(cr,uid,[tax_id],total,1.00): + for tax in tax_obj.compute(cr, uid, [tax_id], total, 1.00): #create the base movement if tmp_cnt == 0: if tax[base_code]: @@ -1007,7 +1056,7 @@ class account_move_line(osv.osv): # if context and ('__last_update' in context): # del context['__last_update'] # self.pool.get('account.move').write(cr, uid, [move_id], {'date':vals['date']}, context=context) - if check and not context.get('no_store_function'): + if check and ((not context.get('no_store_function')) or journal.entry_posted): tmp = self.pool.get('account.move').validate(cr, uid, [vals['move_id']], context) if journal.entry_posted and tmp: self.pool.get('account.move').button_validate(cr,uid, [vals['move_id']],context) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 38b628ab594..1edb56d6044 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -284,11 +284,11 @@ + - @@ -351,7 +351,7 @@ - + @@ -467,12 +467,24 @@ form
- - - - - - + + + + + + + + + + + + + + + + + + @@ -519,7 +531,10 @@ + + + @@ -539,6 +554,7 @@ +
@@ -550,7 +566,7 @@
- + @@ -636,9 +652,9 @@ - + - + @@ -1441,9 +1457,11 @@ - + - + + + Account Add wizard diff --git a/addons/account/i18n/eu.po b/addons/account/i18n/eu.po index 65746716cc9..84652c621ae 100644 --- a/addons/account/i18n/eu.po +++ b/addons/account/i18n/eu.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-05-14 15:45+0000\n" -"Last-Translator: Jon A. Ortuondo (Euskotec) \n" +"PO-Revision-Date: 2010-05-23 09:59+0000\n" +"Last-Translator: ninaiz \n" "Language-Team: Basque \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-05-15 04:58+0000\n" +"X-Launchpad-Export-Date: 2010-05-24 03:46+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -66,7 +66,7 @@ msgstr "" #. module: account #: wizard_view:account_use_models,init_form:0 msgid "Select Message" -msgstr "Mexua Aukeratu" +msgstr "Mezua aurkeratu" #. module: account #: help:product.category,property_account_income_categ:0 @@ -236,7 +236,7 @@ msgstr "" #: field:account.tax.template,amount:0 #: xsl:account.transfer:0 msgid "Amount" -msgstr "" +msgstr "Kopurua" #. module: account #: model:ir.actions.report.xml,name:account.account_3rdparty_ledger @@ -338,7 +338,7 @@ msgstr "" #: field:account.invoice,amount_tax:0 #: field:account.move.line,account_tax_id:0 msgid "Tax" -msgstr "" +msgstr "Zerga" #. module: account #: rml:account.general.journal:0 @@ -465,7 +465,7 @@ msgstr "" #. module: account #: rml:account.invoice:0 msgid "Disc.(%)" -msgstr "" +msgstr "Desk. (%)" #. module: account #: rml:account.general.ledger:0 diff --git a/addons/account/i18n/fr.po b/addons/account/i18n/fr.po index 1785d79bf38..e6bddde1647 100644 --- a/addons/account/i18n/fr.po +++ b/addons/account/i18n/fr.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 5.0.1\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-02-18 09:24+0000\n" -"Last-Translator: Olivier Dony (OpenERP) \n" +"PO-Revision-Date: 2010-05-21 17:48+0000\n" +"Last-Translator: Christophe Chauvet - http://www.syleam.fr/ \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-04-17 04:06+0000\n" +"X-Launchpad-Export-Date: 2010-05-22 04:00+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -2495,7 +2495,8 @@ msgid "Analytic Entry" msgstr "Ecriture analytique" #. module: account -#: view:res.company:0 field:res.company,overdue_msg:0 +#: view:res.company:0 +#: field:res.company,overdue_msg:0 msgid "Overdue Payments Message" msgstr "Message pour les paiements en retard" @@ -2784,7 +2785,7 @@ msgstr "Ouvrir journal" #. module: account #: rml:account.analytic.account.journal:0 msgid "KI" -msgstr "" +msgstr "KI" #. module: account #: model:ir.actions.wizard,name:account.action_account_analytic_line @@ -3034,7 +3035,7 @@ msgstr "-" #. module: account #: rml:account.analytic.account.journal:0 msgid "asgfas" -msgstr "" +msgstr "asgfas" #. module: account #: model:ir.actions.act_window,name:account.action_account_analytic_account_tree2 @@ -6082,3 +6083,6 @@ msgid "" msgstr "" "Cochez cette case si l'utilisateur peut réconcilier les entrées dans ce " "compte." + +#~ msgid "account.config.wizard" +#~ msgstr "account.config.wizard" diff --git a/addons/account/i18n/oc.po b/addons/account/i18n/oc.po index 53532fba0ac..e757e240d9a 100644 --- a/addons/account/i18n/oc.po +++ b/addons/account/i18n/oc.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-03-13 10:33+0000\n" -"Last-Translator: Cédric VALMARY (Per Tot en òc) \n" +"PO-Revision-Date: 2010-05-24 12:19+0000\n" +"Last-Translator: Cédric VALMARY (Tot en òc) \n" "Language-Team: Occitan (post 1500) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-04-17 04:07+0000\n" +"X-Launchpad-Export-Date: 2010-05-25 03:42+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -118,7 +118,7 @@ msgstr "Parent" #. module: account #: selection:account.move,type:0 msgid "Journal Voucher" -msgstr "" +msgstr "Jornal dels chèques" #. module: account #: field:account.invoice,residual:0 @@ -175,7 +175,7 @@ msgstr "" #. module: account #: view:account.move:0 msgid "Total Credit" -msgstr "Total crrdit" +msgstr "Credit Total" #. module: account #: field:account.config.wizard,charts:0 @@ -225,7 +225,7 @@ msgstr "" #. module: account #: model:ir.ui.menu,name:account.menu_finance_recurrent_entries msgid "Recurrent Entries" -msgstr "" +msgstr "Escrituras recurentas" #. module: account #: field:account.analytic.line,amount:0 @@ -255,7 +255,7 @@ msgstr "Taxas provesidors" #. module: account #: view:account.move:0 msgid "Total Debit" -msgstr "Total debit" +msgstr "Debit Total" #. module: account #: rml:account.tax.code.entries:0 @@ -423,7 +423,7 @@ msgstr "Negatiu" #. module: account #: rml:account.partner.balance:0 msgid "(Account/Partner) Name" -msgstr "" +msgstr "Nom (Compte/Partenari)" #. module: account #: selection:account.move,type:0 @@ -493,7 +493,7 @@ msgstr "" #. module: account #: model:ir.ui.menu,name:account.menu_finance_periodical_processing msgid "Periodical Processing" -msgstr "" +msgstr "Tractaments periodics" #. module: account #: view:report.hr.timesheet.invoice.journal:0 @@ -504,12 +504,12 @@ msgstr "" #: model:ir.actions.act_window,name:account.action_account_tax_code_template_form #: model:ir.ui.menu,name:account.menu_action_account_tax_code_template_form msgid "Tax Code Templates" -msgstr "" +msgstr "Modèl de còde de taxa" #. module: account #: view:account.invoice:0 msgid "Supplier invoice" -msgstr "" +msgstr "Factura del provesidor" #. module: account #: model:process.transition,name:account.process_transition_reconcilepaid0 @@ -808,7 +808,6 @@ msgstr "" msgid "Move Lines" msgstr "" - #. module: account #: model:ir.actions.act_window,name:account.report_account_analytic_journal_tree #: model:ir.ui.menu,name:account.report_account_analytic_journal_print @@ -2136,7 +2135,8 @@ msgid "Analytic Entry" msgstr "" #. module: account -#: view:res.company:0 field:res.company,overdue_msg:0 +#: view:res.company:0 +#: field:res.company,overdue_msg:0 msgid "Overdue Payments Message" msgstr "" diff --git a/addons/account/i18n/th.po b/addons/account/i18n/th.po index 320fdc82290..7389cdda788 100644 --- a/addons/account/i18n/th.po +++ b/addons/account/i18n/th.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-03-15 03:12+0000\n" +"PO-Revision-Date: 2010-05-20 07:09+0000\n" "Last-Translator: Songpon Phusing \n" "Language-Team: Thai \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-04-17 04:08+0000\n" +"X-Launchpad-Export-Date: 2010-05-21 03:38+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -51,7 +51,7 @@ msgstr "" #. module: account #: model:account.account.type,name:account.account_type_asset msgid "Asset" -msgstr "" +msgstr "สินทรัพย์" #. module: account #: constraint:ir.actions.act_window:0 @@ -106,7 +106,7 @@ msgstr "" #: model:ir.actions.wizard,name:account.wizard_vat_declaration #: model:ir.ui.menu,name:account.menu_wizard_vat_declaration msgid "Print Taxes Report" -msgstr "" +msgstr "พิมพ์รายงานภาษี" #. module: account #: field:account.account,parent_id:0 @@ -2133,7 +2133,8 @@ msgid "Analytic Entry" msgstr "" #. module: account -#: view:res.company:0 field:res.company,overdue_msg:0 +#: view:res.company:0 +#: field:res.company,overdue_msg:0 msgid "Overdue Payments Message" msgstr "" diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 63cfc2d4071..d8205ababa7 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -23,8 +23,7 @@ import time import decimal_precision as dp import netsvc -from osv import fields, osv -import ir +from osv import fields, osv, orm import pooler from tools import config from tools.translate import _ @@ -217,6 +216,7 @@ class account_invoice(osv.osv): _name = "account.invoice" _description = 'Invoice' _order = "number" + _log_create = True _columns = { '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."), @@ -330,11 +330,18 @@ class account_invoice(osv.osv): return res except Exception,e: if '"journal_id" viol' in e.args[0]: - raise except_orm(_('Configuration Error!'), + raise orm.except_orm(_('Configuration Error!'), _('There is no Accounting Journal of type Sale/Purchase defined!')) else: - raise except_orm(_('UnknownError'), str(e)) - + raise orm.except_orm(_('UnknownError'), str(e)) + + 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): + message = _('Document ') + " '" + name + "' "+ _("has been paid.") + self.log(cr, uid, id, message) + return True + def unlink(self, cr, uid, ids, context=None): invoices = self.read(cr, uid, ids, ['state']) unlink_ids = [] @@ -350,7 +357,7 @@ class account_invoice(osv.osv): # res = self.pool.get('res.partner').address_get(cr, uid, [part], ['invoice']) # return [{}] def onchange_partner_id(self, cr, uid, ids, type, partner_id, - date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): + date_invoice=False, payment_term=False, partner_bank=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False @@ -415,7 +422,7 @@ class account_invoice(osv.osv): else: result['value']['date_due'] = False - if partner_bank_id != bank_id: + if partner_bank != bank_id: to_update = self.onchange_partner_bank(cr, uid, ids, bank_id) result['value'].update(to_update['value']) return result @@ -450,7 +457,7 @@ class account_invoice(osv.osv): def onchange_invoice_line(self, cr, uid, ids, lines): return {} - def onchange_partner_bank(self, cursor, user, ids, partner_bank_id): + def onchange_partner_bank(self, cursor, user, ids, partner_bank): return {'value': {}} def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): @@ -650,6 +657,16 @@ class account_invoice(osv.osv): self.write(cr, uid, [inv.id], res['value']) return True + def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines): + """finalize_invoice_move_lines(cr, uid, invoice, move_lines) -> move_lines + Hook method to be overridden in additional modules to verify and possibly alter the + move lines to be created by an invoice, for special cases. + :param invoice_browse: browsable record of the invoice that is generating the move lines + :param move_lines: list of dictionaries with the account.move.lines (as for create()) + :return: the (possibly updated) final move_lines to create for this invoice + """ + return move_lines + def check_tax_lines(self, cr, uid, inv, compute_taxes, ait_obj): if not inv.tax_line: for tax in compute_taxes.values(): @@ -912,7 +929,12 @@ class account_invoice(osv.osv): # will be automatically deleted too account_move_obj.unlink(cr, uid, [i['move_id'][0]]) if i['payment_ids']: - self.pool.get('account.move.line').write(cr, uid, i['payment_ids'], {'reconcile_partial_id': False}) + account_move_line_obj = self.pool.get('account.move.line') + pay_ids = account_move_line_obj.browse(cr, uid , i['payment_ids']) + for move_line in pay_ids: + if move_line.reconcile_partial_id and move_line.reconcile_partial_id.line_partial_ids: + 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') return True @@ -929,23 +951,8 @@ class account_invoice(osv.osv): return taxes.values() def _log_event(self, cr, uid, ids, factor=1.0, name='Open Invoice'): - invs = self.read(cr, uid, ids, ['type','partner_id','amount_untaxed']) - for inv in invs: - part=inv['partner_id'] and inv['partner_id'][0] - pc = pr = 0.0 - cr.execute('select sum(quantity*price_unit) from account_invoice_line where invoice_id=%s', (inv['id'],)) - total = inv['amount_untaxed'] - if inv['type'] in ('in_invoice','in_refund'): - partnertype='supplier' - eventtype = 'purchase' - pc = total*factor - else: - partnertype = 'customer' - eventtype = 'sale' - pr = total*factor - if self.pool.get('res.partner.event.type').check(cr, uid, 'invoice_open'): - self.pool.get('res.partner.event').create(cr, uid, {'name':'Invoice: '+name, 'som':False, 'description':name+' '+str(inv['id']), 'document':name, 'partner_id':part, 'date':time.strftime('%Y-%m-%d %H:%M:%S'), 'canal_id':False, 'user_id':uid, 'partner_type':partnertype, 'probability':1.0, 'planned_revenue':pr, 'planned_cost':pc, 'type':eventtype}) - return len(invs) + #TODO: implement messages system + return True def name_get(self, cr, uid, ids, context=None): if not len(ids): @@ -1147,14 +1154,14 @@ class account_invoice_line(osv.osv): t = t - (p * l[2].get('quantity')) taxes = l[2].get('invoice_line_tax_id') if len(taxes[0]) >= 3 and taxes[0][2]: - taxes=tax_obj.browse(cr, uid, taxes[0][2]) + taxes = tax_obj.browse(cr, uid, taxes[0][2]) for tax in tax_obj.compute(cr, uid, taxes, p,l[2].get('quantity'), context.get('address_invoice_id', False), l[2].get('product_id', False), context.get('partner_id', False)): t = t - tax['amount'] return t return 0 _name = "account.invoice.line" - _description = "Invoice line" + _description = "Invoice Line" _columns = { 'name': fields.char('Description', size=256, required=True), 'origin': fields.char('Origin', size=256, help="Reference of the document that produced this invoice."), @@ -1200,8 +1207,8 @@ class account_invoice_line(osv.osv): part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False - lang=part.lang - context.update({'lang': lang}) + if part.lang: + context.update({'lang': part.lang}) result = {} res = self.pool.get('product.product').browse(cr, uid, product, context=context) @@ -1500,9 +1507,9 @@ account_invoice_tax() class res_partner(osv.osv): """ Inherits partner and adds invoice information in the partner form """ _inherit = 'res.partner' - + _columns = { - 'invoice_ids': fields.one2many('account.invoice.line', 'partner_id', 'Invoices'), + 'invoice_ids': fields.one2many('account.invoice.line', 'partner_id', 'Invoices', readonly=True), } res_partner() diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index d3b61f34f31..e1e43420d6e 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -74,13 +74,13 @@ - + - + @@ -113,14 +113,34 @@ + +
+ + + + res.partner.account.info.inherit + res.partner + form + + + + + + + + + + + + diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index 71e57cb82e2..b4a7b67a05a 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -25,13 +25,13 @@ - + @@ -67,7 +67,7 @@ - + @@ -97,6 +97,7 @@ form tree,graph,form + {"search_default_user_id":uid} @@ -152,7 +153,7 @@ - + @@ -177,7 +178,7 @@ - + @@ -188,11 +189,11 @@ - + @@ -202,6 +203,7 @@ ir.actions.act_window account.analytic.line form + {"search_default_user_id":uid} @@ -286,7 +288,7 @@ - + @@ -441,21 +443,6 @@ - - - - - res.partner.contract.info.inherit - res.partner - form - - - - - - - - diff --git a/addons/account/project/report/analytic_check.py b/addons/account/project/report/analytic_check.py index 54fbaddc4d9..458827d8bf3 100644 --- a/addons/account/project/report/analytic_check.py +++ b/addons/account/project/report/analytic_check.py @@ -54,12 +54,12 @@ class account_analytic_analytic_check(report_sxw.rml_parse): self.cr.execute("SELECT abs(sum(amount)) AS balance \ FROM account_analytic_line \ - WHERE date>=%s AND date<=%s AND amount>0 AND general_account_id = %s", (date1, date2, a['id'])) + WHERE date>=%s AND date<=%s AND amount<0 AND general_account_id = %s", (date1, date2, 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<0 AND general_account_id = %s", (date1, date2, a['id'])) + WHERE date>=%s AND date<=%s AND amount>0 AND general_account_id = %s", (date1, date2, a['id'])) (ac,) = self.cr.fetchone() ac = ac or 0.0 diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index 09ff866d1a8..5d1d7a33c97 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -30,13 +30,14 @@ import invoice import overdue import aged_trial_balance import tax_report -import general_ledger_landscape import account_tax_code import account_balance_landscape import compare_account_balance import account_invoice_report import account_report import account_analytic_report - +import account_account_report +import account_entries_report +import account_analytic_entries_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_account_report.py b/addons/account/report/account_account_report.py new file mode 100644 index 00000000000..55e5d7030c7 --- /dev/null +++ b/addons/account/report/account_account_report.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import tools +from osv import fields,osv + +class account_account_report(osv.osv): + _name = "account.account.report" + _description = "Account Report" + _auto = False + _columns = { + 'name': fields.char('Name', size=128, readonly=True), + 'code': fields.char('Code', size=64, readonly=True), + 'type': fields.selection([ + ('receivable', 'Receivable'), + ('payable', 'Payable'), + ('view', 'View'), + ('consolidation', 'Consolidation'), + ('other', 'Others'), + ('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), + 'quantity': fields.float('Quantity', readonly=True), + 'amount_total': fields.float('Total Amount', readonly=True), + 'credit': fields.float('Credit', readonly=True), + 'debit': fields.float('Debit', readonly=True), + 'balance': fields.float('Balance', readonly=True), + 'nbr': fields.integer('#Accounts', readonly=True), + 'parent_account_id': fields.many2one('account.account', 'Parent Account', required=True), + } + def init(self, cr): + tools.drop_view_if_exists(cr, 'account_account_report') + cr.execute(""" + create or replace view account_account_report as ( + select + min(a.id) as id, + count(distinct a.id) as nbr, + a.name, + a.code, + a.type as type, + a.company_id as company_id, + a.currency_mode as currency_mode, + a.user_type as user_type, + a.parent_id as parent_account_id, + sum(ail.quantity) as quantity, + sum(ail.price_subtotal) as amount_total, + sum(m.credit) as credit, + sum(m.debit) as debit, + (sum(m.credit)-sum(m.debit)) as balance + from + account_account as a + left join account_move_line as m on m.account_id=a.id + left join account_invoice_line as ail on ail.account_id=a.id + left join account_invoice as ai on ai.account_id=a.id + group by + a.name, + a.code, + a.type, + a.company_id, + a.currency_mode, + a.user_type, + m.account_id, + a.parent_id + ) + """) +account_account_report() diff --git a/addons/account/report/account_account_report_view.xml b/addons/account/report/account_account_report_view.xml new file mode 100644 index 00000000000..137fa0c69ae --- /dev/null +++ b/addons/account/report/account_account_report_view.xml @@ -0,0 +1,94 @@ + + + + + account.account.report.tree + account.account.report + tree + + + + + + + + + + + + + + + + + + + + + account.account.report.graph + account.account.report + graph + + + + + + + + + + + + account.account.report.search + account.account.report + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Accounts Analysis + account.account.report + form + tree,graph + {"search_default_Account":1,"search_default_At Date":1,'group_by_no_leaf':1,'group_by':[]} + + + + + + + diff --git a/addons/account/report/account_analytic_entries_report.py b/addons/account/report/account_analytic_entries_report.py new file mode 100644 index 00000000000..2a1b4ad993b --- /dev/null +++ b/addons/account/report/account_analytic_entries_report.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import tools +from osv import fields,osv + +class analytic_entries_report(osv.osv): + _name = "analytic.entries.report" + _description = "Analytic Entries Statistics" + _auto = False + _columns = { + 'date': fields.date('Date', 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), + 'user_id' : fields.many2one('res.users', 'User',readonly=True), + 'name': fields.char('Description', size=64, readonly=True), + 'company_id': fields.many2one('res.company', 'Company', required=True), + 'currency_id': fields.many2one('res.currency', 'Currency', required=True), + 'account_id': fields.many2one('account.analytic.account', 'Account', required=True), + 'general_account_id': fields.many2one('account.account', 'General Account', required=True), + 'journal_id': fields.many2one('account.analytic.journal', 'Journal', required=True), + 'move_id': fields.many2one('account.move.line', 'Move', required=True), + 'product_id': fields.many2one('product.product', 'Product', required=True), + 'product_uom_id': fields.many2one('product.uom', 'Product UOM', required=True), + 'amount': fields.float('Amount', readonly=True), + 'unit_amount': fields.float('Unit Amount', readonly=True), + 'amount_currency': fields.float('Amount Currency', readonly=True), + 'nbr': fields.integer('#Entries', readonly=True), + } + def init(self, cr): + tools.drop_view_if_exists(cr, 'analytic_entries_report') + cr.execute(""" + create or replace view analytic_entries_report as ( + select + min(a.id) as id, + count(distinct a.id) as nbr, + a.create_date as date, + to_char(a.create_date, 'YYYY') as year, + to_char(a.create_date, 'MM') as month, + to_char(a.create_date, 'YYYY-MM-DD') as day, + a.user_id as user_id, + a.name as name, + a.company_id as company_id, + a.currency_id as currency_id, + a.account_id as account_id, + a.general_account_id as general_account_id, + a.journal_id as journal_id, + a.move_id as move_id, + a.product_id as product_id, + a.product_uom_id as product_uom_id, + sum(a.amount) as amount, + sum(a.unit_amount) as unit_amount, + sum(a.amount_currency) as amount_currency + from + account_analytic_line a + group by + a.create_date, a.user_id,a.name,company_id,a.currency_id, + a.account_id,a.general_account_id,a.journal_id, + a.move_id,a.product_id,a.product_uom_id + ) + """) +analytic_entries_report() diff --git a/addons/account/report/account_analytic_entries_report_view.xml b/addons/account/report/account_analytic_entries_report_view.xml new file mode 100644 index 00000000000..82a063256c1 --- /dev/null +++ b/addons/account/report/account_analytic_entries_report_view.xml @@ -0,0 +1,112 @@ + + + + + analytic.entries.report.tree + analytic.entries.report + tree + + + + + + + + + + + + + + + + + + + + + + + + + analytic.entries.report.search + analytic.entries.report + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + account.analytic.entries.graph + analytic.entries.report + graph + + + + + + + + + + + Analytic Entries Analysis + analytic.entries.report + form + tree,graph + {'search_default_month':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]} + + + + + + + diff --git a/addons/account/report/account_analytic_report.py b/addons/account/report/account_analytic_report.py index 45057d950bd..87912b4a3ef 100644 --- a/addons/account/report/account_analytic_report.py +++ b/addons/account/report/account_analytic_report.py @@ -35,7 +35,7 @@ class analytic_report(osv.osv): '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), - 'quantity': fields.float('Quantity',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), @@ -43,6 +43,11 @@ class analytic_report(osv.osv): 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), + 'day': fields.char('Day', size=128, readonly=True), + 'nbr':fields.integer('# of Lines', readonly=True), + 'company_id': fields.many2one('res.company', 'Company', readonly=True), + 'type': fields.selection([('view','View'), ('normal','Normal')], 'Account Type'), + 'state': fields.selection([('draft','Draft'), ('open','Open'), ('pending','Pending'), @@ -50,6 +55,7 @@ class analytic_report(osv.osv): ('close','Close'), ('template', 'Template')], 'State', readonly=True), + } _order = 'date_start desc' def init(self, cr): @@ -60,15 +66,18 @@ class analytic_report(osv.osv): min(s.id) as id, to_char(s.create_date, 'YYYY') as year, to_char(s.create_date, 'MM') as month, + to_char(s.create_date, 'YYYY-MM-DD') as day, l.journal_id, l.product_id, s.parent_id, s.date_start, s.date as date_end, s.user_id, + s.company_id, + s.type, s.name, s.partner_id, - s.quantity, + sum(s.quantity) as total_quantity, s.debit, s.credit, s.balance, @@ -77,7 +86,8 @@ class analytic_report(osv.osv): from account_analytic_account s left join account_analytic_line l on (s.id=l.account_id) GROUP BY s.create_date,s.state,l.journal_id,s.name, - s.partner_id,s.date_start,s.date,s.user_id,s.quantity, + s.partner_id,s.date_start,s.date,s.user_id, + s.company_id,s.type, s.debit,s.credit,s.balance,s.parent_id,l.product_id ) """) diff --git a/addons/account/report/account_analytic_report_view.xml b/addons/account/report/account_analytic_report_view.xml index de97bfcb798..f853b809867 100644 --- a/addons/account/report/account_analytic_report_view.xml +++ b/addons/account/report/account_analytic_report_view.xml @@ -6,55 +6,50 @@ analytic.report tree - + - - - - - - - - - - - + + + + + + + + + + + + + + + - analytic.report.search analytic.report search - + - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + - - + + + + + + - - + + - + + + + + + + + + + + + - + + account.analytic.report.graph + analytic.report + graph + + + + + + + + + + - Analytic Accounts + Analytic Accounts Analysis analytic.report form - tree - {'search_default_User':1,'search_default_user_id':uid} + tree,graph + {'search_default_This Month':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]} - - + diff --git a/addons/account/report/account_entries_report.py b/addons/account/report/account_entries_report.py new file mode 100644 index 00000000000..85ba8a058f7 --- /dev/null +++ b/addons/account/report/account_entries_report.py @@ -0,0 +1,123 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import tools +from osv import fields,osv + +class account_entries_report(osv.osv): + _name = "account.entries.report" + _description = "Entries" + _auto = False + _rec_name = 'date' + _columns = { + 'date': fields.date('Effective Date', readonly=True), + 'date_created': fields.date('Date Created', readonly=True), + '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), + '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), + '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, + 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.'), + 'partner_id': fields.many2one('res.partner','Partner', readonly=True), + 'period_id2': fields.many2one('account.period', 'Move Line Period', readonly=True), + 'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account', readonly=True), + 'journal_id2': fields.many2one('account.journal', 'Move Line Journal', readonly=True), + 'type': fields.selection([ + ('pay_voucher','Cash Payment'), + ('bank_pay_voucher','Bank Payment'), + ('rec_voucher','Cash Receipt'), + ('bank_rec_voucher','Bank Receipt'), + ('cont_voucher','Contra'), + ('journal_sale_vou','Journal Sale'), + ('journal_pur_voucher','Journal Purchase'), + ('journal_voucher','Journal Voucher'), + ],'Type',readonly=True), + 'quantity': fields.float('Products Quantity', digits=(16,2), readonly=True), + 'company_id': fields.many2one('res.company', 'Company', readonly=True), + } + _order = 'date desc' + + def init(self, cr): + tools.drop_view_if_exists(cr, 'account_entries_report') + cr.execute(""" + create or replace view account_entries_report as ( + select + min(l.id) as id, + am.ref as ref, + sum(l.quantity) as quantity, + am.state as state, + l.state as state_2, + am.date as date, + count(l.id) as nbr, + count(distinct am.id) as nbl, + l.debit as amount, + to_char(am.date, 'YYYY') as year, + to_char(am.date, 'MM') as month, + to_char(am.date, 'YYYY-MM-DD') as day, + am.company_id as company_id, + l.account_id as account_id, + l.analytic_account_id as analytic_account_id, + l.date_created as date_created, + l.date_maturity as date_maturity, + am.journal_id as journal_id, + l.journal_id as journal_id2, + l.period_id as period_id2, + am.period_id as period_id, + l.partner_id as partner_id, + l.product_id as product_id, + am.type as type + from + account_move_line l + left join + account_move am on (am.id=l.move_id) + group by am.ref, + am.state, + am.date, + am.company_id, + am.journal_id, + l.journal_id, + am.period_id, + l.period_id, + am.type, + l.partner_id, + l.analytic_account_id, + l.product_id, + l.date_created, + l.date_maturity, + l.account_id, + l.state, + l.debit + ) + """) + +account_entries_report() diff --git a/addons/account/report/account_entries_report_view.xml b/addons/account/report/account_entries_report_view.xml new file mode 100644 index 00000000000..5d1b99b578e --- /dev/null +++ b/addons/account/report/account_entries_report_view.xml @@ -0,0 +1,126 @@ + + + + + account.entries.report.tree + account.entries.report + tree + + + + + + + + + + + + + + + + + + + + + + + + + + + + + account.entries.report.graph + account.entries.report + graph + + + + + + + + + account.entries.report.search + account.entries.report + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Entries Analysis + account.entries.report + form + tree,graph + {'search_default_This Month':1,'search_default_Journal':1,'group_by_no_leaf':1,'group_by':[]} + + + + + diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 36fa5a0d132..cd1477e79cf 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -61,6 +61,13 @@ class account_invoice_report(osv.osv): ('paid','Done'), ('cancel','Cancelled') ], 'Order State', readonly=True), + 'date_due': fields.date('Due Date', readonly=True), + 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address Name', readonly=True), + 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address Name', readonly=True), + 'account_id': fields.many2one('account.account', 'Account',readonly=True), + 'partner_bank': fields.many2one('res.partner.bank', 'Bank Account',readonly=True), + 'residual':fields.float('Total Residual', readonly=True), + 'delay_to_pay':fields.float('Avg. Delay To Pay', readonly=True, group_operator="avg"), } _order = 'date desc' def init(self, cr): @@ -87,12 +94,24 @@ class account_invoice_report(osv.osv): (sum(l.quantity*l.price_unit)/sum(l.quantity * u.factor))::decimal(16,2) as price_average, count(*) as nbr, s.type as type, - s.state - from + s.state, + s.date_due as date_due, + s.address_contact_id as address_contact_id, + s.address_invoice_id as address_invoice_id, + s.account_id as account_id, + s.partner_bank as partner_bank, + s.residual as residual, + case when s.state != 'paid' then null else + extract(epoch from avg(am.date_created-l.create_date))/(24*60*60)::decimal(16,2) + end as delay_to_pay + from account_invoice_line l left join account_invoice s on (s.id=l.invoice_id) - left join product_uom u on (u.id=l.uos_id) + left join product_uom u on (u.id=l.uos_id), + account_move_line am left join account_invoice i on (i.move_id=am.move_id) + where + am.account_id=i.account_id group by s.type, s.date_invoice, @@ -101,12 +120,18 @@ class account_invoice_report(osv.osv): l.uos_id, s.user_id, s.state, + s.residual, s.company_id, s.payment_term, s.period_id, s.fiscal_position, s.currency_id, - s.journal_id + s.journal_id, + s.date_due, + s.address_contact_id, + s.address_invoice_id, + s.account_id, + s.partner_bank ) """) account_invoice_report() diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 5a833e454fb..94f181cd587 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -6,7 +6,7 @@ account.invoice.report tree - + @@ -17,16 +17,20 @@ - - - + + + + + + + @@ -36,7 +40,7 @@ account.invoice.report graph - + @@ -48,15 +52,15 @@ account.invoice.report search - - - + + - + + help="Invoices of last 30 days"/> + help = "Draft Invoices"/> + help = "Pro-forma Invoices"/> + help = "open Invoices"/> + - - - + + - - - - + help="My Invoices" + domain="[('user_id','=',uid)]"/> + + - - - - - - - - - - - - - - - - - + + - - - - + - - + + + + + + + - - + - + + + + + + + + + + + + + + + + + + + + + + - Invoices + Invoices Analysis account.invoice.report form tree,graph @@ -145,7 +148,7 @@ - + diff --git a/addons/account/report/account_report_view.xml b/addons/account/report/account_report_view.xml index f0f67b477e3..9b1688730aa 100644 --- a/addons/account/report/account_report_view.xml +++ b/addons/account/report/account_report_view.xml @@ -47,7 +47,7 @@ form tree,graph - + @@ -116,7 +116,7 @@ - + report.account.sales.tree @@ -169,7 +169,7 @@ graph,tree - + @@ -237,7 +237,7 @@ graph,tree - + diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 00031a77ed8..e2c24fe96d2 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -33,8 +33,6 @@ import pooler class general_ledger(rml_parse.rml_parse): _name = 'report.account.general.ledger' - - def set_context(self, objects, data, ids, report_type = None): ## self.borne_date = self.get_min_date(data['form']) @@ -42,6 +40,7 @@ class general_ledger(rml_parse.rml_parse): new_ids = [] if (data['model'] == 'account.account'): new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] + #new_ids = ids else: new_ids.append(data['form']['Account_list']) @@ -70,39 +69,6 @@ class general_ledger(rml_parse.rml_parse): 'sum_currency_amount_account': self._sum_currency_amount_account }) self.context = context - def _calc_contrepartie(self,cr,uid,ids, context={}): - result = {} - #for id in ids: - # result.setdefault(id, False) - - for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): - # For avoid long text in the field we will limit it to 5 lines - # - # - # - result[account_line.id] = ' ' - num_id_move = str(account_line.move_id.id) - num_id_line = str(account_line.id) - account_id = str(account_line.account_id.id) - # search the basic account - # We have the account ID we will search all account move line from now until this time - # We are in the case of we are on the top of the account move Line - cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' ,(num_id_move,account_id,)) - res_mv = cr.dictfetchall() - # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line - if (len(res_mv) >=1): - concat = '' - rup_id = 0 - for move_rest in res_mv: - concat = concat + move_rest['code_rest'] + '|' - result[account_line.id] = concat - if rup_id >5: - # we need to stop the computing and to escape but before we will add "..." - result[account_line.id] = concat + '...' - break - rup_id+=1 - return result def get_min_date(self,form): @@ -118,12 +84,17 @@ class general_ledger(rml_parse.rml_parse): if form['state'] == 'byperiod': ## This function will return the most aged date periods = form['periods'] + #periods = form['periods'][0][2] if not periods: - self.cr.execute(""" - 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""",(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 = """ + str(form['fiscalyear']) + """ + """ else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + 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 + """) + """ + self.cr.execute(sql) res = self.cr.dictfetchall() borne_min = res[0]['start_date'] borne_max = res[0]['stop_date'] @@ -132,15 +103,17 @@ class general_ledger(rml_parse.rml_parse): borne_max = form['date_to'] elif form['state'] == 'all': periods = form['periods'] + #periods = form['periods'][0][2] if not periods: - if form['fiscalyear'] == False: - fiscalyears = self.pool.get('account.fiscalyear').search(self.cr, self.uid, [('state', '=', 'draft')]) - else: - fiscalyears = [form['fiscalyear']] - self.cr.execute("select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id =ANY(%s)" ,(fiscalyears,)) + 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']) + """ + """ else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + 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 + """) + """ + self.cr.execute(sql) res = self.cr.dictfetchall() period_min = res[0]['start_date'] period_max = res[0]['stop_date'] @@ -167,9 +140,6 @@ class general_ledger(rml_parse.rml_parse): } return self.date_borne - - - def get_children_accounts(self, account, form): self.child_ids = self.pool.get('account.account').search(self.cr, self.uid, @@ -184,6 +154,8 @@ class general_ledger(rml_parse.rml_parse): if form.has_key('fiscalyear'): ctx['fiscalyear'] = form['fiscalyear'] ctx['periods'] = form['periods'] + #ctx['periods'] = form['periods'][0][2] + else: ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] @@ -224,8 +196,8 @@ class general_ledger(rml_parse.rml_parse): else: ## We will now compute solde initiaux for move in res: - self.cr.execute("""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""",(move.id,self.borne_date['max_date'],self.borne_date['min_date'])) + 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) resultat = self.cr.dictfetchall() if resultat[0] : if resultat[0]['sum_debit'] == None: @@ -248,56 +220,60 @@ class general_ledger(rml_parse.rml_parse): return res def lines(self, account, form): - inv_types = { - 'out_invoice': 'CI: ', - 'in_invoice': 'SI: ', - 'out_refund': 'OR: ', - 'in_refund': 'SR: ', - } + """ Return all the account_move_line of account with their account code counterparts """ - if form['sortbydate'] == 'sort_date': - sorttag = 'l.date' - else: - sorttag = 'j.code' + # First compute all counterpart strings for every move_id where this account appear sql = """ - SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name , COALESCE(l.debit,0) as debit, COALESCE(l.credit,0) as credit, l.period_id - FROM account_move_line as l - LEFT JOIN res_currency c on (l.currency_id=c.id) - JOIN account_journal j on (l.journal_id=j.id) - AND account_id = %%s - AND %s - WHERE l.date<=%%s - AND l.date>=%%s - ORDER by %s""" % (self.query, sorttag) - - self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'],)) + SELECT m1.move_id, + array_to_string(ARRAY(SELECT DISTINCT a.code FROM account_move_line m2 LEFT JOIN account_account a ON (m2.account_id=a.id) WHERE m2.move_id = m1.move_id AND m2.account_id<>%%s), ', ') AS counterpart + FROM (SELECT move_id FROM account_move_line l WHERE %s AND l.account_id = %%s AND l.date<=%%s AND l.date>=%%s GROUP BY move_id) m1 + """ % self.query + self.cr.execute(sql, (account.id, account.id, self.date_borne['max_date'], self.date_borne['min_date'])) + counterpart_res = self.cr.dictfetchall() + counterpart_accounts = {} + for i in counterpart_res: + counterpart_accounts[i['move_id']]=i['counterpart'] + del counterpart_res + # Then select all account_move_line of this account + if form['sortbydate'] == 'sort_date': + sql_sort='l.date' + else: + sql_sort='j.code' + sql = """ + SELECT l.id, l.date, j.code, l.amount_currency,l.ref, l.name, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, l.period_id, l.partner_id, + m.name AS move_name, m.id AS move_id, + c.code AS currency_code, + i.id AS invoice_id, i.type AS invoice_type, i.number AS invoice_number, + p.name AS partner_name + FROM account_move_line l + LEFT JOIN account_move m on (l.move_id=m.id) + LEFT JOIN res_currency c on (l.currency_id=c.id) + LEFT JOIN res_partner p on (l.partner_id=p.id) + LEFT JOIN account_invoice i on (m.id =i.move_id) + JOIN account_journal j on (l.journal_id=j.id) + WHERE %s AND l.account_id = %%s AND l.date<=%%s AND l.date>=%%s ORDER by %s + """ % (self.query, sql_sort) + self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'])) res = self.cr.dictfetchall() - sum = 0.0 + account_sum = 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') + inv_types = { 'out_invoice': 'CI', 'in_invoice': 'SI', 'out_refund': 'OR', 'in_refund': 'SR', } + for l in res: - line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) - l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) - tmpres = self.cr.dictfetchall() - if len(tmpres) > 0 : - inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) - l['ref'] = inv_types[inv.type] + ': '+str(inv.number) - if line.partner_id : - l['partner'] = line.partner_id.name - else : - l['partner'] = '' - sum = l['debit'] - l ['credit'] -# c = time.strptime(l['date'],"%Y-%m-%d") -# l['date'] = time.strftime("%d-%m-%Y",c) - l['progress'] = sum - l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] + l['move']=l['move_name'] + if l['invoice_id']: + 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") + #l['date'] = time.strftime("%d-%m-%Y",c) + l['progress'] = account_sum + l['line_corresp'] = counterpart_accounts[l['move_id']] # Modification du amount Currency - if (l['credit'] > 0): + if l['credit'] > 0: if l['amount_currency'] != None: l['amount_currency'] = abs(l['amount_currency']) * -1 - - # if l['amount_currency'] != None: self.tot_currency = self.tot_currency + l['amount_currency'] return res @@ -306,7 +282,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) + "WHERE l.account_id = %s AND %s "%(account.id, self.query)) ## Add solde init to the result # sum_debit = self.cr.fetchone()[0] or 0.0 @@ -320,7 +296,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 "+ self.query,(account.id,)) + "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 @@ -334,7 +310,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 "+ self.query,(account.id,)) + "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 @@ -346,7 +322,7 @@ 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 =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) sum_debit = self.cr.fetchone()[0] or 0.0 return sum_debit @@ -355,7 +331,7 @@ 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 =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -366,14 +342,14 @@ 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 =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) sum_solde = self.cr.fetchone()[0] or 0.0 return sum_solde def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.code as code "\ "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) + "WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id)) result = self.cr.fetchone() if result: self.account_currency = result[0] @@ -392,6 +368,7 @@ class general_ledger(rml_parse.rml_parse): currency_total = self.tot_currency = 0.0 return currency_total - report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/general_ledger.rml', parser=general_ledger, header=False) +report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger, header=False) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/general_ledger.rml b/addons/account/report/general_ledger.rml index 75cb086b343..c69c981e35c 100644 --- a/addons/account/report/general_ledger.rml +++ b/addons/account/report/general_ledger.rml @@ -105,7 +105,7 @@
[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] @@ -156,7 +156,7 @@
[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] diff --git a/addons/account/report/general_ledger_landscape.py b/addons/account/report/general_ledger_landscape.py deleted file mode 100644 index 472f0675519..00000000000 --- a/addons/account/report/general_ledger_landscape.py +++ /dev/null @@ -1,396 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (c) 2005-2006 CamptoCamp -# -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company -# -# This program is Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################## - -import time -from report import report_sxw -import xml -import rml_parse -import pooler - -class general_ledger_landscape(rml_parse.rml_parse): - _name = 'report.account.general.ledger_landscape' - - - def set_context(self, objects, data, ids, report_type = None): - ## - self.borne_date = self.get_min_date(data['form']) - ## - new_ids = [] - if (data['model'] == 'account.account'): - new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] - else: - new_ids.append(data['form']['Account_list']) - objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - super(general_ledger_landscape, self).set_context(objects, data, new_ids,report_type) - - def __init__(self, cr, uid, name, context): - super(general_ledger_landscape, self).__init__(cr, uid, name, context=context) - self.date_borne = {} - self.query = "" - self.child_ids = "" - self.tot_currency = 0.0 - self.period_sql = "" - self.sold_accounts = {} - self.localcontext.update( { - 'time': time, - 'lines': self.lines, - 'sum_debit_account': self._sum_debit_account, - 'sum_credit_account': self._sum_credit_account, - 'sum_solde_account': self._sum_solde_account, - 'sum_debit': self._sum_debit, - 'sum_credit': self._sum_credit, - 'sum_solde': self._sum_solde, - 'get_children_accounts': self.get_children_accounts, - 'sum_currency_amount_account': self._sum_currency_amount_account - }) - self.context = context - def _calc_contrepartie(self,cr,uid,ids, context={}): - result = {} - #for id in ids: - # result.setdefault(id, False) - - for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): - # For avoid long text in the field we will limit it to 5 lines - # - # - # - result[account_line.id] = ' ' - num_id_move = account_line.move_id.id - num_id_line = account_line.id - account_id = account_line.account_id.id - # search the basic account - # We have the account ID we will search all account move line from now until this time - # We are in the case of we are on the top of the account move Line - cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' , (num_id_move,account_id,)) - res_mv = cr.dictfetchall() - # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line - if (len(res_mv) >=1): - concat = '' - rup_id = 0 - for move_rest in res_mv: - concat = concat + move_rest['code_rest'] + '|' - result[account_line.id] = concat - if rup_id >5: - # we need to stop the computing and to escape but before we will add "..." - result[account_line.id] = concat + '...' - break - rup_id+=1 - return result - - def get_min_date(self,form): - - ## Get max born from account_fiscal year - # - sql = """ select min(fy.date_start) as start_date,max(fy.date_stop) as stop_date from account_fiscalyear - As fy where fy.state <> 'close' - """ - self.cr.execute(sql) - res = self.cr.dictfetchall() - borne_min = res[0]['start_date'] - borne_max = res[0]['stop_date'] - if form['state'] == 'byperiod': - ## This function will return the most aged date - periods = form['periods'] - if not periods: - self.cr.execute(""" - 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""" ,(form['fiscalyear'],)) - else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) - - res = self.cr.dictfetchall() - borne_min = res[0]['start_date'] - borne_max = res[0]['stop_date'] - elif form['state'] == 'bydate': - borne_min = form['date_from'] - borne_max = form['date_to'] - elif form['state'] == 'all': - periods = form['periods'] - if not periods: - if form['fiscalyear'] == False: - fiscalyears = self.pool.get('account.fiscalyear').search(self.cr, self.uid, [('state', '=', 'draft')]) - else: - fiscalyears = [form['fiscalyear']] - self.cr.execute("select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id =ANY(%s)" ,(fiscalyears,)) - else: - self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) - res = self.cr.dictfetchall() - period_min = res[0]['start_date'] - period_max = res[0]['stop_date'] - date_min = form['date_from'] - date_max = form['date_to'] - if period_min=',child_account.id)], - context=ctx)) <> 0 : - res.append(child_account) - ## - if not len(res): - - return [account] - else: - ## We will now compute solde initiaux - for move in res: - self.cr.execute("""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""",(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: - sum_debit = 0 - else: - sum_debit = resultat[0]['sum_debit'] - if resultat[0]['sum_credit'] == None: - sum_credit = 0 - else: - sum_credit = resultat[0]['sum_credit'] - - move.init_credit = sum_credit - move.init_debit = sum_debit - - else: - move.init_credit = 0 - move.init_debit = 0 - - - return res - - def lines(self, account, form): - inv_types = { - 'out_invoice': 'CI: ', - 'in_invoice': 'SI: ', - 'out_refund': 'OR: ', - 'in_refund': 'SR: ', - } - - if form['sortbydate'] == 'sort_date': - sorttag = 'l.date' - else: - sorttag = 'j.code' - sql = """ - SELECT l.id, l.date, j.code,c.code AS currency_code,l.amount_currency,l.ref, l.name , COALESCE(l.debit,0) as debit, COALESCE(l.credit,0) as credit, l.period_id - FROM account_move_line as l - LEFT JOIN res_currency c on (l.currency_id=c.id) - JOIN account_journal j on (l.journal_id=j.id) - AND account_id = %%s - AND %s - WHERE l.date<=%%s - AND l.date>=%%s - ORDER by %s""" % (self.query, sorttag) - - self.cr.execute(sql, (account.id, self.date_borne['max_date'], self.date_borne['min_date'],)) - - res = self.cr.dictfetchall() - sum = 0.0 - account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - for l in res: - line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) - l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) - tmpres = self.cr.dictfetchall() - if len(tmpres) > 0 : - inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) - l['ref'] = inv_types[inv.type] + ': '+str(inv.number) - if line.partner_id : - l['partner'] = line.partner_id.name - else : - l['partner'] = '' - sum = l['debit'] - l ['credit'] -# c = time.strptime(l['date'],"%Y-%m-%d") -# l['date'] = time.strftime("%d-%m-%Y",c) - l['progress'] = sum - l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] - # Modification du amount Currency - if (l['credit'] > 0): - if l['amount_currency'] != None: - l['amount_currency'] = abs(l['amount_currency']) * -1 - - # - if l['amount_currency'] != None: - self.tot_currency = self.tot_currency + l['amount_currency'] - return res - - def _sum_debit_account(self, account, form): - - self.cr.execute("SELECT sum(debit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) - ## Add solde init to the result - # - sum_debit = self.cr.fetchone()[0] or 0.0 - if form['soldeinit']: - sum_debit += account.init_debit - # - ## - return sum_debit - - def _sum_credit_account(self, account, form): - - self.cr.execute("SELECT sum(credit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) - ## Add solde init to the result - # - sum_credit = self.cr.fetchone()[0] or 0.0 - if form['soldeinit']: - sum_credit += account.init_credit - # - ## - - return sum_credit - - 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 "+self.query,(account.id,)) - sum_solde = self.cr.fetchone()[0] or 0.0 - if form.get('soldeinit',False): - sum_solde += account.init_debit - account.init_credit - - return sum_solde - - def _sum_debit(self, form): - if not self.ids: - return 0.0 - self.cr.execute("SELECT sum(debit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) - sum_debit = self.cr.fetchone()[0] or 0.0 - return sum_debit - - def _sum_credit(self, form): - if not self.ids: - return 0.0 - self.cr.execute("SELECT sum(credit) "\ - "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) - ## Add solde init to the result - # - sum_credit = self.cr.fetchone()[0] or 0.0 - return sum_credit - - def _sum_solde(self, form): - if not self.ids: - return 0.0 - self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ - "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) - sum_solde = self.cr.fetchone()[0] or 0.0 - return sum_solde - - def _set_get_account_currency_code(self, account_id): - self.cr.execute("SELECT c.code as code "\ - "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) - result = self.cr.fetchone() - if result: - self.account_currency = result[0] - else: - self.account_currency = False - - def _sum_currency_amount_account(self, account, form): - self._set_get_account_currency_code(account.id) - self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) - total = self.cr.fetchone() - - if self.account_currency: - return_field = str(total[0]) + self.account_currency - return return_field - else: - currency_total = self.tot_currency = 0.0 - return currency_total - -report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger_landscape, header=False) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/general_ledger_landscape.rml b/addons/account/report/general_ledger_landscape.rml index 9e937a72baf..a707a47d0bd 100644 --- a/addons/account/report/general_ledger_landscape.rml +++ b/addons/account/report/general_ledger_landscape.rml @@ -104,7 +104,7 @@ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] @@ -165,7 +165,7 @@ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] diff --git a/addons/account/report/overdue.rml b/addons/account/report/overdue.rml index 2713b665d06..e8e1a7dc84c 100644 --- a/addons/account/report/overdue.rml +++ b/addons/account/report/overdue.rml @@ -84,8 +84,8 @@ + - [[ repeatIn(objects,'o') ]] [[ setLang(o.lang) ]] @@ -177,16 +177,16 @@ [[ line['ref'] ]] - [[ line['date_maturity'] ]] + [[ line['date_maturity'] and formatLang(line['date_maturity'],date=True) or '' ]] - [[ formatLang(line['debit']) and formatLang(line['debit'] * (line['account_id']['type'] == 'payable' and -1 or 1)) ]] + [[ (line['account_id']['type'] == 'receivable' and formatLang(line['debit']) or 0) or (line['account_id']['type'] == 'payable' and formatLang(line['credit'] * -1) or ' ') ]] - [[ formatLang(line['credit']) and formatLang(line['credit'] * (line['account_id']['type'] == 'payable' and -1 or 1)) ]] + [[ (line['account_id']['type'] == 'receivable' and formatLang(line['credit']) or 0) or (line['account_id']['type'] == 'payable' and formatLang(line['debit'] * -1) or 0) ]] - [[ formatLang((line['date_maturity'] < time.strftime('%Y-%m-%d')) and ((line['debit'] - line['credit']) * (line['account_id']['type'] == 'payable' and -1 or 1))) ]] + [[ formatLang((line['date_maturity'] < time.strftime('%Y-%m-%d'))) and (line['debit'] - line['credit']) ]] [[ line['blocked'] and 'X' or '' ]] @@ -205,13 +205,13 @@ Sub-Total : - [[ formatLang((reduce(lambda x, y: x + (y['debit'] * (y['account_id']['type'] == 'payable' and -1 or 1)), getLines(o), 0))) ]] + [[ formatLang((reduce(lambda x, y: x + ((y['account_id']['type'] == 'receivable' and y['debit'] or 0) or (y['account_id']['type'] == 'payable' and y['credit'] * -1 or 0)), getLines(o), 0))) ]] - [[ formatLang((reduce(lambda x ,y: x + (y['credit'] * (y['account_id']['type'] == 'payable' and -1 or 1)), getLines(o), 0))) ]] + [[ formatLang((reduce(lambda x, y: x + ((y['account_id']['type'] == 'receivable' and y['credit'] or 0) or (y['account_id']['type'] == 'payable' and y['debit'] * -1 or 0)), getLines(o), 0))) ]] - [[ formatLang((reduce(lambda x, y: x + ((y['debit'] - y['credit']) * (y['account_id']['type'] == 'payable' and -1 or 1)), filter(lambda x: x['date_maturity'] < time.strftime('%Y-%m-%d'), getLines(o)), 0))) ]] + [[ formatLang((reduce(lambda x, y: x + (y['debit'] - y['credit']), filter(lambda x: x['date_maturity'] < time.strftime('%Y-%m-%d'), getLines(o)), 0))) ]] @@ -229,7 +229,7 @@ Balance : - [[ formatLang((reduce(lambda x, y: x +((y['debit'] - y['credit']) * (y['account_id']['type'] == 'payable' and -1 or 1)), getLines(o), 0))) ]] + [[ formatLang((reduce(lambda x, y: x +(y['debit'] - y['credit']), getLines(o), 0))) ]] @@ -248,9 +248,9 @@ - Total amount due: [[ formatLang((reduce(lambda x, y: x + ((y['debit'] - y['credit']) * (y['account_id']['type'] == 'payable' and -1 or 1)), getLines(o), 0))) ]] [[ company.currency_id.name ]]. + Total amount due: [[ formatLang((reduce(lambda x, y: x + (y['debit'] - y['credit']), getLines(o), 0))) ]] [[ company.currency_id.name ]]. - + \ No newline at end of file diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index 1dca4dfb64a..c10fcb33313 100644 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -167,9 +167,9 @@ class third_party_ledger(rml_parse.rml_parse): # #new_ids = [id for (id,) in self.cr.fetchall()] if data['form']['result_selection'] == 'supplier': - self.ACCOUNT_TYPE = ['receivable'] - elif data['form']['result_selection'] == 'customer': self.ACCOUNT_TYPE = ['payable'] + elif data['form']['result_selection'] == 'customer': + self.ACCOUNT_TYPE = ['receivable'] elif data['form']['result_selection'] == 'all': self.ACCOUNT_TYPE = ['payable','receivable'] diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv index e1aa3b6510a..7458594d240 100644 --- a/addons/account/security/ir.model.access.csv +++ b/addons/account/security/ir.model.access.csv @@ -15,8 +15,8 @@ "access_account_move","account.move","model_account_move","account.group_account_user",1,1,1,1 "access_account_move_line","account.move.line","model_account_move_line","account.group_account_user",1,1,1,1 "access_account_move_reconcile","account.move.reconcile","model_account_move_reconcile","account.group_account_user",1,1,1,1 -"access_account_tax_code","account.tax.code","model_account_tax_code",,1,0,0,0 -"access_account_tax","account.tax","model_account_tax",,1,0,0,0 +"access_account_tax_code","account.tax.code","model_account_tax_code","account.group_account_invoice",1,0,0,0 +"access_account_tax","account.tax","model_account_tax","account.group_account_invoice",1,0,0,0 "access_account_model","account.model","model_account_model","account.group_account_user",1,1,1,1 "access_account_model_line","account.model.line","model_account_model_line","account.group_account_user",1,1,1,1 "access_account_subscription","account.subscription","model_account_subscription","account.group_account_user",1,1,1,1 @@ -93,3 +93,13 @@ "access_report_account_type_sales","report.account_type.sales","model_report_account_type_sales","account.group_account_manager",1,0,0,0 "access_report_account_sales","report.account.sales","model_report_account_sales","account.group_account_manager",1,0,0,0 "access_account_invoice_report","account.invoice.report","model_account_invoice_report","account.group_account_manager",1,0,0,0 +"access_project_account_analytic_line","project.account.analytic.line","model_project_account_analytic_line","account.group_account_manager",1,1,1,1 +"access_account_move_line_reconcile_select","account.move.line.reconcile.select","model_account_move_line_reconcile_select","account.group_account_manager",1,1,1,1 +"access_account_move_line_unreconcile_select","account.move.line.unreconcile.select","model_account_move_line_unreconcile_select","account.group_account_manager",1,1,1,1 +"access_account_invoice_refund","account.invoice.refund","model_account_invoice_refund","account.group_account_manager",1,1,1,1 +"access_account_move_journal","account.move.journal","model_account_move_journal","account.group_account_manager",1,1,1,1 +"access_account_move_bank_reconcile","account.move.bank.reconcile","model_account_move_bank_reconcile","account.group_account_manager",1,1,1,1 +"access_account_subscription_generate","account.subscription.generate","model_account_subscription_generate","account.group_account_manager",1,1,1,1 +"access_account_period_close","account.period.close","model_account_period_close","account.group_account_manager",1,1,1,1 +"access_account_fiscalyear_close_state","account.fiscalyear.close.state","model_account_fiscalyear_close_state","account.group_account_manager",1,1,1,1 +"access_account_chart","account.chart","model_account_chart","account.group_account_manager",1,1,1,1 diff --git a/addons/account/sequence.py b/addons/account/sequence.py index d48f23eb1cf..e23ec1e3def 100644 --- a/addons/account/sequence.py +++ b/addons/account/sequence.py @@ -42,7 +42,7 @@ class ir_sequence(osv.osv): _columns = { 'fiscal_ids' : fields.one2many('account.sequence.fiscalyear', 'sequence_main_id', 'Sequences') } - def get_id(self, cr, uid, sequence_id, test='id', context={}): + def get_id(self, cr, uid, sequence_id, test='id', context={}): cr.execute('select id from ir_sequence where '+test+'=%s and active=%s', (sequence_id, True,)) res = cr.dictfetchone() if res: diff --git a/addons/account/wizard/account_aged_trial_balance_view.xml b/addons/account/wizard/account_aged_trial_balance_view.xml index 7984f69e86e..769d7ee268f 100644 --- a/addons/account/wizard/account_aged_trial_balance_view.xml +++ b/addons/account/wizard/account_aged_trial_balance_view.xml @@ -8,7 +8,7 @@ form
- + diff --git a/addons/account/wizard/account_balance_report_view.xml b/addons/account/wizard/account_balance_report_view.xml index dd1b7147f13..f50cce039cc 100644 --- a/addons/account/wizard/account_balance_report_view.xml +++ b/addons/account/wizard/account_balance_report_view.xml @@ -8,7 +8,7 @@ form - + diff --git a/addons/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py index 1e23b793d27..eee754435cd 100644 --- a/addons/account/wizard/account_change_currency.py +++ b/addons/account/wizard/account_change_currency.py @@ -42,6 +42,7 @@ class account_change_currency(osv.osv_memory): obj_inv = self.pool.get('account.invoice') obj_inv_line = self.pool.get('account.invoice.line') obj_currency = self.pool.get('res.currency') + invoice_ids = [] if context is None: context = {} data = self.read(cr, uid, ids)[0] @@ -66,7 +67,8 @@ class account_change_currency(osv.osv_memory): new_price = (line.price_unit / old_rate ) * rate obj_inv_line.write(cr, uid, [line.id], {'price_unit' : new_price}) - obj_inv.write(cr, uid, [invoice.id], {'currency_id' : new_currency}) + invoice_ids.append(invoice.id) + obj_inv.write(cr, uid, invoice_ids, {'currency_id' : new_currency}, context=context) return {} account_change_currency() diff --git a/addons/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py index ba94bbfb37c..af3f0c26511 100644 --- a/addons/account/wizard/account_chart.py +++ b/addons/account/wizard/account_chart.py @@ -24,7 +24,7 @@ from tools.translate import _ class account_chart(osv.osv_memory): """ For Chart of Accounrs - """ + """ _name = "account.chart" _description = "chart" _columns = { diff --git a/addons/account/wizard/account_general_ledger_report_view.xml b/addons/account/wizard/account_general_ledger_report_view.xml index 0790a1654b9..a2ff3accf5f 100644 --- a/addons/account/wizard/account_general_ledger_report_view.xml +++ b/addons/account/wizard/account_general_ledger_report_view.xml @@ -8,7 +8,7 @@ form - +