diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index ebbd5459cea..c538614fd0f 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -159,6 +159,5 @@ for a particular financial year and for preparation of vouchers there is a modul ], 'installable': True, 'auto_install': False, - 'certificate': '0080331923549', } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/account.py b/addons/account/account.py index d145f0308b0..a2f84506b11 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -31,7 +31,7 @@ import decimal_precision as dp from tools.translate import _ from tools.float_utils import float_round from openerp import SUPERUSER_ID - +import tools _logger = logging.getLogger(__name__) @@ -227,7 +227,7 @@ class account_account(osv.osv): while pos < len(args): if args[pos][0] == 'code' and args[pos][1] in ('like', 'ilike') and args[pos][2]: - args[pos] = ('code', '=like', str(args[pos][2].replace('%', ''))+'%') + args[pos] = ('code', '=like', tools.ustr(args[pos][2].replace('%', ''))+'%') if args[pos][0] == 'journal_id': if not args[pos][2]: del args[pos] @@ -601,7 +601,7 @@ class account_account(osv.osv): if not default: default = {} default = default.copy() - default['code'] = (account['code'] or '') + '(copy)' + default.update(code=_("%s (copy)") % (account['code'] or '')) if not local: done_list = [] if account.id in done_list: @@ -682,7 +682,7 @@ class account_journal_view(osv.osv): _name = "account.journal.view" _description = "Journal View" _columns = { - 'name': fields.char('Journal View', size=64, required=True), + 'name': fields.char('Journal View', size=64, required=True, translate=True), 'columns_id': fields.one2many('account.journal.column', 'view_id', 'Columns') } _order = "name" @@ -782,9 +782,10 @@ class account_journal(osv.osv): if not default: default = {} default = default.copy() - default['code'] = (journal['code'] or '') + '(copy)' - default['name'] = (journal['name'] or '') + '(copy)' - default['sequence_id'] = False + default.update( + code=_("%s (copy)") % (journal['code'] or ''), + name=_("%s (copy)") % (journal['name'] or ''), + sequence_id=False) return super(account_journal, self).copy(cr, uid, id, default, context=context) def write(self, cr, uid, ids, vals, context=None): @@ -1907,7 +1908,7 @@ class account_tax(osv.osv): 'ref_tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1."), 'include_base_amount': fields.boolean('Included in base amount', help="Indicates if the amount of tax must be included in the base amount for the computation of the next taxes"), 'company_id': fields.many2one('res.company', 'Company', required=True), - 'description': fields.char('Tax Code',size=32), + 'description': fields.char('Tax Code'), 'price_include': fields.boolean('Tax Included in Price', help="Check this if the price you use on the product and invoices includes this tax."), 'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Application', required=True) @@ -2827,7 +2828,7 @@ class account_tax_template(osv.osv): 'ref_base_sign': fields.float('Base Code Sign', help="Usually 1 or -1."), 'ref_tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1."), 'include_base_amount': fields.boolean('Include in Base Amount', help="Set if the amount of tax must be included in the base amount before computing the next taxes."), - 'description': fields.char('Internal Name', size=32), + 'description': fields.char('Internal Name'), 'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Use In', required=True,), 'price_include': fields.boolean('Tax Included in Price', help="Check this if the price you use on the product and invoices includes this tax."), } diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 2dc7f96768f..9889eadf387 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -447,11 +447,13 @@ class account_bank_statement(osv.osv): return self.write(cr, uid, done, {'state':'draft'}, context=context) def _compute_balance_end_real(self, cr, uid, journal_id, context=None): - cr.execute('SELECT balance_end_real \ - FROM account_bank_statement \ - WHERE journal_id = %s AND NOT state = %s \ - ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft')) - res = cr.fetchone() + res = False + if journal_id: + cr.execute('SELECT balance_end_real \ + FROM account_bank_statement \ + WHERE journal_id = %s AND NOT state = %s \ + ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft')) + res = cr.fetchone() return res and res[0] or 0.0 def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None): diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 8966e3caa78..e492417eca9 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -508,8 +508,10 @@ class account_invoice(osv.osv): if journal_id: journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context) currency_id = journal.currency and journal.currency.id or journal.company_id.currency_id.id + company_id = journal.company_id.id result = {'value': { 'currency_id': currency_id, + 'company_id': company_id, } } return result @@ -1373,7 +1375,10 @@ class account_invoice_line(osv.osv): 'partner_id': fields.related('invoice_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True) } - def _default_account_id(self, cr, uid, ids, context=None): + def _default_account_id(self, cr, uid, context=None): + # XXX this gets the default account for the user's company, + # it should get the default account for the invoice's company + # however, the invoice's company does not reach this point prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context) return prop and prop.id or False @@ -1403,7 +1408,7 @@ class account_invoice_line(osv.osv): context = {} company_id = company_id if company_id != None else context.get('company_id',False) context = dict(context) - context.update({'company_id': company_id}) + context.update({'company_id': company_id, 'force_company': company_id}) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: @@ -1558,12 +1563,14 @@ class account_invoice_line(osv.osv): def onchange_account_id(self, cr, uid, ids, product_id, partner_id, inv_type, fposition_id, account_id): if not account_id: return {} - taxes = self.pool.get('account.account').browse(cr, uid, account_id).tax_ids + account = self.pool.get('account.account').browse(cr, uid, account_id) + taxes = account.tax_ids fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False tax_ids = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) product_change_result = self.product_id_change(cr, uid, ids, product_id, False, type=inv_type, - partner_id=partner_id, fposition_id=fposition_id) + partner_id=partner_id, fposition_id=fposition_id, + company_id=account.company_id.id) unique_tax_ids = set(tax_ids) if product_change_result and 'value' in product_change_result and 'invoice_line_tax_id' in product_change_result['value']: unique_tax_ids |= set(product_change_result['value']['invoice_line_tax_id']) @@ -1652,14 +1659,13 @@ class account_invoice_tax(osv.osv): for line in inv.invoice_line: for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, (line.price_unit* (1-(line.discount or 0.0)/100.0)), line.quantity, line.product_id, inv.partner_id)['taxes']: - tax['price_unit'] = cur_obj.round(cr, uid, cur, tax['price_unit']) val={} val['invoice_id'] = inv.id val['name'] = tax['name'] val['amount'] = tax['amount'] val['manual'] = False val['sequence'] = tax['sequence'] - val['base'] = tax['price_unit'] * line['quantity'] + val['base'] = cur_obj.round(cr, uid, cur, tax['price_unit'] * line['quantity']) if inv.type in ('out_invoice','in_invoice'): val['base_code_id'] = tax['base_code_id'] diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 2aed5b02107..bb1ace992ca 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -562,6 +562,7 @@ class account_move_line(osv.osv): 'journal_id': lambda self, cr, uid, c: c.get('journal_id', False), 'credit': 0.0, 'debit': 0.0, + 'amount_currency': 0.0, 'account_id': lambda self, cr, uid, c: c.get('account_id', False), 'period_id': lambda self, cr, uid, c: c.get('period_id', False), 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c) @@ -736,7 +737,7 @@ class account_move_line(osv.osv): WHERE debit > 0 AND credit > 0 ORDER BY last_reconciliation_date""") ids = cr.fetchall() - ids = len(ids) and list(ids[0]) or [] + ids = len(ids) and [x[0] for x in ids] or [] return self.pool.get('res.partner').name_get(cr, uid, ids, context=context) def reconcile_partial(self, cr, uid, ids, type='auto', context=None, writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False): @@ -1193,12 +1194,12 @@ class account_move_line(osv.osv): jour_period_obj = self.pool.get('account.journal.period') cr.execute('SELECT state FROM account_journal_period WHERE journal_id = %s AND period_id = %s', (journal_id, period_id)) result = cr.fetchall() + journal = journal_obj.browse(cr, uid, journal_id, context=context) + period = period_obj.browse(cr, uid, period_id, context=context) for (state,) in result: if state == 'done': - raise osv.except_osv(_('Error!'), _('You cannot add/modify entries in a closed journal.')) + raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed period %s of journal %s.' % (period.name,journal.name))) if not result: - journal = journal_obj.browse(cr, uid, journal_id, context=context) - period = period_obj.browse(cr, uid, period_id, context=context) jour_period_obj.create(cr, uid, { 'name': (journal.code or journal.name)+':'+(period.name or ''), 'journal_id': journal.id, diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 2c204fdf707..f8811432a2b 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1305,16 +1305,6 @@ Account.Entry Edition --> - - account.move.graph - account.move - - - - - - - account.move.tree account.move @@ -1338,8 +1328,8 @@
-
@@ -1488,7 +1478,7 @@ Journal Entries account.move form - tree,form,graph + tree,form @@ -2037,7 +2027,7 @@ src_model="account.journal"/> other + + X11007 + USD Bank Account - (test) + + liquidity + + + Liabilities - (test) @@ -360,8 +368,8 @@ bank - - + + @@ -384,7 +392,12 @@ - + + @@ -412,6 +425,16 @@ + + + USD Bank Journal - (test) + TUBK + bank + + + + + diff --git a/addons/account/partner.py b/addons/account/partner.py index f2b9f79bb8a..a9b2b99588d 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -44,17 +44,17 @@ class account_fiscal_position(osv.osv): return [] if not fposition_id: return map(lambda x: x.id, taxes) - result = [] + result = set() for t in taxes: ok = False for tax in fposition_id.tax_ids: if tax.tax_src_id.id == t.id: if tax.tax_dest_id: - result.append(tax.tax_dest_id.id) + result.add(tax.tax_dest_id.id) ok=True if not ok: - result.append(t.id) - return result + result.add(t.id) + return list(result) def map_account(self, cr, uid, fposition_id, account_id, context=None): if not fposition_id: @@ -77,6 +77,12 @@ class account_fiscal_position_tax(osv.osv): 'tax_dest_id': fields.many2one('account.tax', 'Replacement Tax') } + _sql_constraints = [ + ('tax_src_dest_uniq', + 'unique (position_id,tax_src_id,tax_dest_id)', + 'A tax fiscal position could be defined only once time on same taxes.') + ] + account_fiscal_position_tax() class account_fiscal_position_account(osv.osv): @@ -89,6 +95,12 @@ class account_fiscal_position_account(osv.osv): 'account_dest_id': fields.many2one('account.account', 'Account Destination', domain=[('type','<>','view')], required=True) } + _sql_constraints = [ + ('account_src_dest_uniq', + 'unique (position_id,account_src_id,account_dest_id)', + 'An account fiscal position could be defined only once time on same accounts.') + ] + account_fiscal_position_account() class res_partner(osv.osv): diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index 7ac1efd4f9f..4bee2002ffd 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -92,34 +92,7 @@ - - - - - - - - - - - - - - - - - - + @@ -141,7 +114,7 @@ context="{'search_default_partner_id':[active_id], 'default_partner_id': active_id}" src_model="res.partner" view_type="form" - view_mode="tree,form,graph,calendar"/> + view_mode="tree,form,calendar"/> diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index da1a11b9cb6..70db95425b1 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -73,7 +73,7 @@ ir.actions.act_window account.analytic.account form - tree,graph,form + tree,form
@@ -114,9 +114,6 @@ - account.analytic.line.form @@ -351,15 +348,6 @@ # Reporting # - - Print Analytic Journals - account.analytic.journal - tree - To print an analytics (or costs) journal for a given period. The report give code, move name, account number, general amount and analytic amount. - - account.journal.form.1 @@ -372,16 +360,5 @@ - - analytic.accounts.graph - account.analytic.account - - - - - - - - diff --git a/addons/account/project/wizard/account_analytic_journal_report.py b/addons/account/project/wizard/account_analytic_journal_report.py index 9a2eee020b1..8148a016927 100644 --- a/addons/account/project/wizard/account_analytic_journal_report.py +++ b/addons/account/project/wizard/account_analytic_journal_report.py @@ -29,6 +29,7 @@ class account_analytic_journal_report(osv.osv_memory): _columns = { 'date1': fields.date('Start of period', required=True), 'date2': fields.date('End of period', required=True), + 'analytic_account_journal_id': fields.many2many('account.analytic.journal', 'account_analytic_journal_name', 'journal_line_id', 'journal_print_id', 'Analytic Journals', required=True), } _defaults = { @@ -40,8 +41,15 @@ class account_analytic_journal_report(osv.osv_memory): if context is None: context = {} data = self.read(cr, uid, ids)[0] + ids_list = [] + if context.get('active_id',False): + ids_list.append(context.get('active_id',False)) + else: + record = self.browse(cr,uid,ids[0],context=context) + for analytic_record in record.analytic_account_journal_id: + ids_list.append(analytic_record.id) datas = { - 'ids': context.get('active_ids',[]), + 'ids': ids_list, 'model': 'account.analytic.journal', 'form': data } @@ -50,6 +58,14 @@ class account_analytic_journal_report(osv.osv_memory): 'report_name': 'account.analytic.journal', 'datas': datas, } + + def default_get(self, cr, uid, fields, context=None): + if context is None: + context = {} + res = super(account_analytic_journal_report, self).default_get(cr, uid, fields, context=context) + if 'analytic_account_journal_id' in fields: + res.update({'analytic_account_journal_id': context.get('active_ids',[])}) + return res account_analytic_journal_report() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/account_analytic_journal_report_view.xml b/addons/account/project/wizard/account_analytic_journal_report_view.xml index e4c4cd314db..b0cb0293270 100644 --- a/addons/account/project/wizard/account_analytic_journal_report_view.xml +++ b/addons/account/project/wizard/account_analytic_journal_report_view.xml @@ -7,15 +7,16 @@ account.analytic.journal.report
-
-
+ +
+
@@ -38,6 +39,13 @@ action account.analytic.journal + + + diff --git a/addons/account/res_config.py b/addons/account/res_config.py index ea903654a4e..17df4377548 100644 --- a/addons/account/res_config.py +++ b/addons/account/res_config.py @@ -117,6 +117,9 @@ class account_config_settings(osv.osv_memory): 'group_multi_currency': fields.boolean('Allow multi currencies', implied_group='base.group_multi_currency', help="Allows you multi currency environment"), + 'group_analytic_accounting': fields.boolean('Analytic accounting', + implied_group='analytic.group_analytic_accounting', + help="Allows you to use the analytic accounting."), } def _default_company(self, cr, uid, context=None): diff --git a/addons/account/res_config_view.xml b/addons/account/res_config_view.xml index d7618fbff5a..0e4b1fa64c4 100644 --- a/addons/account/res_config_view.xml +++ b/addons/account/res_config_view.xml @@ -129,6 +129,10 @@