diff --git a/addons/account/account.py b/addons/account/account.py index 57356f7d3ef..d145f0308b0 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -181,7 +181,7 @@ class account_account_type(osv.osv): 'Balance' will generally be used for cash accounts. 'Detail' will copy each existing journal item of the previous year, even the reconciled ones. 'Unreconciled' will copy only the journal items that were unreconciled on the first day of the new fiscal year."""), - 'report_type': fields.function(_get_current_report_type, fnct_inv=_save_report_type, type='selection', string='P&L / BS Category', + 'report_type': fields.function(_get_current_report_type, fnct_inv=_save_report_type, type='selection', string='P&L / BS Category', store=True, selection= [('none','/'), ('income', _('Profit & Loss (Income account)')), ('expense', _('Profit & Loss (Expense account)')), @@ -836,6 +836,10 @@ class account_journal(osv.osv): @return: Returns a list of tupples containing id, name """ + if not ids: + return [] + if isinstance(ids, (int, long)): + ids = [ids] result = self.browse(cr, user, ids, context=context) res = [] for rs in result: @@ -2338,6 +2342,16 @@ class account_model(osv.osv): return move_ids + def onchange_journal_id(self, cr, uid, ids, journal_id, context=None): + company_id = False + + if journal_id: + journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context) + if journal.company_id.id: + company_id = journal.company_id.id + + return {'value': {'company_id': company_id}} + account_model() class account_model_line(osv.osv): @@ -2516,22 +2530,25 @@ class account_account_template(osv.osv): 'nocreate': False, } - def _check_type(self, cr, uid, ids, context=None): - if context is None: - context = {} - accounts = self.browse(cr, uid, ids, context=context) - for account in accounts: - if account.parent_id and account.parent_id.type != 'view': - return False - return True - _check_recursion = check_cycle _constraints = [ (_check_recursion, 'Error!\nYou cannot create recursive account templates.', ['parent_id']), - (_check_type, 'Configuration Error!\nYou cannot define children to an account that has internal type other than "View".', ['type']), - ] + def create(self, cr, uid, vals, context=None): + if 'parent_id' in vals: + parent = self.read(cr, uid, [vals['parent_id']], ['type']) + if parent and parent[0]['type'] != 'view': + raise osv.except_osv(_('Warning!'), _("You may only select a parent account of type 'View'.")) + return super(account_account_template, self).create(cr, uid, vals, context=context) + + def write(self, cr, uid, ids, vals, context=None): + if 'parent_id' in vals: + parent = self.read(cr, uid, [vals['parent_id']], ['type']) + if parent and parent[0]['type'] != 'view': + raise osv.except_osv(_('Warning!'), _("You may only select a parent account of type 'View'.")) + return super(account_account_template, self).write(cr, uid, ids, vals, context=context) + def name_get(self, cr, uid, ids, context=None): if not ids: return [] @@ -3010,9 +3027,9 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'purchase_tax_rate': fields.float('Purchase Tax(%)'), 'complete_tax_set': fields.boolean('Complete Set of Taxes', help='This boolean helps you to choose if you want to propose to the user to encode the sales and purchase rates or use the usual m2o fields. This last choice assumes that the set of tax defined for the chosen template is complete'), } - + def onchange_company_id(self, cr, uid, ids, company_id, context=None): - currency_id = False + currency_id = False if company_id: currency_id = self.pool.get('res.company').browse(cr, uid, company_id, context=context).currency_id.id return {'value': {'currency_id': currency_id}} diff --git a/addons/account/account_bank.py b/addons/account/account_bank.py index ef146128a67..e44d2acd163 100644 --- a/addons/account/account_bank.py +++ b/addons/account/account_bank.py @@ -43,11 +43,15 @@ class bank(osv.osv): "Return the name to use when creating a bank journal" return (bank.bank_name or '') + ' ' + bank.acc_number - def _prepare_name_get(self, cr, uid, bank_type_obj, bank_obj, context=None): - """Add ability to have %(currency_name)s in the format_layout of - res.partner.bank.type""" - bank_obj._data[bank_obj.id]['currency_name'] = bank_obj.currency_id and bank_obj.currency_id.name or '' - return super(bank, self)._prepare_name_get(cr, uid, bank_type_obj, bank_obj, context=context) + def _prepare_name_get(self, cr, uid, bank_dicts, context=None): + """Add ability to have %(currency_name)s in the format_layout of res.partner.bank.type""" + currency_ids = list(set(data['currency_id'][0] for data in bank_dicts if data['currency_id'])) + currencies = self.pool.get('res.currency').browse(cr, uid, currency_ids, context=context) + currency_name = dict((currency.id, currency.name) for currency in currencies) + + for data in bank_dicts: + data['currency_name'] = data['currency_id'] and currency_name[data['currency_id'][0]] or '' + return super(bank, self)._prepare_name_get(cr, uid, bank_dicts, context=context) def post_write(self, cr, uid, ids, context={}): if isinstance(ids, (int, long)): diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 095d461ff3b..2dc7f96768f 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -304,7 +304,7 @@ class account_bank_statement(osv.osv): 'date': st_line.date, 'ref': st_line.ref, 'move_id': move_id, - 'partner_id': partner_id, + 'partner_id': par_id, 'account_id': acc_id, 'credit': credit, 'debit': debit, diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index c92d4eda602..58e824a6250 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -14,8 +14,12 @@ +

+ Select a configuration package to setup automatically your + taxes and chart of accounts. +

- + @@ -32,7 +36,7 @@ - Configure your Chart of Accounts + Configure Accounting Data ir.actions.act_window account.installer diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 42d42e7ec1b..aff38d71cfe 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -395,18 +395,23 @@ class account_invoice(osv.osv): template_id = template and template[1] or False res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form') res_id = res and res[1] or False - ctx = dict(context, active_model='account.invoice', active_id=ids[0]) - ctx.update({'mail.compose.template_id': template_id}) + ctx = dict(context) + ctx.update({ + 'default_model': 'account.invoice', + 'default_res_id': ids[0], + 'default_use_template': True, + 'default_template_id': template_id, + }) return { - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'mail.compose.message', - 'views': [(res_id, 'form')], - 'view_id': res_id, - 'type': 'ir.actions.act_window', - 'target': 'new', - 'context': ctx, - 'nodestroy': True, + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'views': [(res_id, 'form')], + 'view_id': res_id, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': ctx, + 'nodestroy': True, } def confirm_paid(self, cr, uid, ids, context=None): @@ -767,17 +772,20 @@ class account_invoice(osv.osv): if not key in tax_key: raise osv.except_osv(_('Warning!'), _('Taxes are missing!\nClick on compute button.')) - def compute_invoice_totals(self, cr, uid, inv, company_currency, ref, invoice_move_lines): + def compute_invoice_totals(self, cr, uid, inv, company_currency, ref, invoice_move_lines, context=None): + if context is None: + context={} total = 0 total_currency = 0 cur_obj = self.pool.get('res.currency') for i in invoice_move_lines: if inv.currency_id.id != company_currency: + context.update({'date': inv.date_invoice or time.strftime('%Y-%m-%d')}) i['currency_id'] = inv.currency_id.id i['amount_currency'] = i['price'] i['price'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, i['price'], - context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}) + context=context) else: i['amount_currency'] = False i['currency_id'] = False @@ -887,7 +895,7 @@ class account_invoice(osv.osv): # create one move line for the total and possibly adjust the other lines amount total = 0 total_currency = 0 - total, total_currency, iml = self.compute_invoice_totals(cr, uid, inv, company_currency, ref, iml) + total, total_currency, iml = self.compute_invoice_totals(cr, uid, inv, company_currency, ref, iml, context=ctx) acc_id = inv.account_id.id name = inv['name'] or '/' @@ -1095,10 +1103,10 @@ class account_invoice(osv.osv): if not ids: return [] types = { - 'out_invoice': 'CI: ', - 'in_invoice': 'SI: ', - 'out_refund': 'OR: ', - 'in_refund': 'SR: ', + 'out_invoice': 'Invoice ', + 'in_invoice': 'Sup. Invoice ', + 'out_refund': 'Refund ', + 'in_refund': 'Supplier Refund ', } return [(r['id'], (r['number']) or types[r['type']] + (r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')] diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 480d5ec76a6..a2fbf11963b 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -30,7 +30,7 @@ - + diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 18ab1a779a3..69b1bef08e6 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -215,8 +215,10 @@ class account_move_line(osv.osv): def _default_get(self, cr, uid, fields, context=None): if context is None: context = {} - if not context.get('journal_id', False) and context.get('search_default_journal_id', False): + if not context.get('journal_id', False): context['journal_id'] = context.get('search_default_journal_id') + if not context.get('period_id', False): + context['period_id'] = context.get('search_default_period_id') account_obj = self.pool.get('account.account') period_obj = self.pool.get('account.period') journal_obj = self.pool.get('account.journal') @@ -226,6 +228,9 @@ class account_move_line(osv.osv): partner_obj = self.pool.get('res.partner') currency_obj = self.pool.get('res.currency') context = self.convert_to_period(cr, uid, context) + #pass the right context when search_defaul_journal_id + if context.get('search_default_journal_id',False): + context['journal_id'] = context.get('search_default_journal_id') # Compute simple values data = super(account_move_line, self).default_get(cr, uid, fields, context=context) # Starts: Manual entry from account.move form @@ -926,6 +931,8 @@ class account_move_line(osv.osv): return res if (not context.get('journal_id', False)) or (not context.get('period_id', False)): return False + if context.get('search_default_journal_id', False): + context['journal_id'] = context.get('search_default_journal_id') cr.execute('SELECT code FROM account_journal WHERE id = %s', (context['journal_id'], )) j = cr.fetchone()[0] or '' cr.execute('SELECT code FROM account_period WHERE id = %s', (context['period_id'], )) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 8c0de73ef8c..874adb417d3 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -102,6 +102,7 @@
+
@@ -112,7 +113,7 @@ - - account.treasury.graph - account.account - - - - - - - Accounts account.account @@ -1082,7 +1073,7 @@ - + @@ -1349,7 +1340,7 @@ - + @@ -1651,8 +1642,8 @@ - - + + @@ -1728,8 +1719,10 @@ account.payment.term.line - - + + + + @@ -1777,12 +1770,11 @@ account.payment.term - + - - + @@ -2537,7 +2529,7 @@ action = pool.get('res.config').next(cr, uid, [], context)
diff --git a/addons/account/board_account_view.xml b/addons/account/board_account_view.xml index 563c3f5fc6c..abbc81ade2b 100644 --- a/addons/account/board_account_view.xml +++ b/addons/account/board_account_view.xml @@ -12,16 +12,6 @@ [('year','=',time.strftime('%Y'))]
- - Treasury - account.account - form - graph,tree - [('type','=','liquidity')] - {'default_type': 'liquidity'} - - - board.account.form board.board @@ -31,9 +21,6 @@ - - -
diff --git a/addons/account/data/configurable_account_chart.xml b/addons/account/data/configurable_account_chart.xml index 18e22a5e4f2..b8b23344ff3 100644 --- a/addons/account/data/configurable_account_chart.xml +++ b/addons/account/data/configurable_account_chart.xml @@ -45,7 +45,6 @@ 0 Configurable Account Chart - view diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index 94b3d2d4085..53f2b54e0ef 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -19,7 +19,6 @@ X0 Chart For Automated Tests - view diff --git a/addons/account/installer.py b/addons/account/installer.py index 60a34628b1b..6173ea9213e 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -45,12 +45,12 @@ class account_installer(osv.osv_memory): sorted(((m.name, m.shortdesc) for m in modules.browse(cr, uid, ids, context=context)), key=itemgetter(1))) - charts.insert(0, ('configurable', 'Generic Chart Of Accounts')) + charts.insert(0, ('configurable', _('Custom'))) return charts _columns = { # Accounting - 'charts': fields.selection(_get_charts, 'Chart of Accounts', + 'charts': fields.selection(_get_charts, 'Accounting Package', required=True, help="Installs localized accounting charts to match as closely as " "possible the accounting needs of your company based on your " diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index d83571b314e..7ac1efd4f9f 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -12,7 +12,7 @@
- + @@ -23,6 +23,7 @@ + @@ -93,8 +94,10 @@
- - + + + + diff --git a/addons/account/res_config.py b/addons/account/res_config.py index df22008861c..ea903654a4e 100644 --- a/addons/account/res_config.py +++ b/addons/account/res_config.py @@ -51,10 +51,10 @@ class account_config_settings(osv.osv_memory): 'code_digits': fields.integer('# of Digits', help="No. of digits to use for account code"), 'tax_calculation_rounding_method': fields.related('company_id', 'tax_calculation_rounding_method', type='selection', selection=[ - ('round_per_line', 'Round per Line'), - ('round_globally', 'Round Globally'), + ('round_per_line', 'Round per line'), + ('round_globally', 'Round globally'), ], string='Tax calculation rounding method', - help="If you select 'Round per Line' : for each tax, the tax amount will first be computed and rounded for each PO/SO/invoice line and then these rounded amounts will be summed, leading to the total amount for that tax. If you select 'Round Globally': for each tax, the tax amount will be computed for each PO/SO/invoice line, then these amounts will be summed and eventually this total tax amount will be rounded. If you sell with tax included, you should choose 'Round per line' because you certainly want the sum of your tax-included line subtotals to be equal to the total amount with taxes."), + help="If you select 'Round per line' : for each tax, the tax amount will first be computed and rounded for each PO/SO/invoice line and then these rounded amounts will be summed, leading to the total amount for that tax. If you select 'Round globally': for each tax, the tax amount will be computed for each PO/SO/invoice line, then these amounts will be summed and eventually this total tax amount will be rounded. If you sell with tax included, you should choose 'Round per line' because you certainly want the sum of your tax-included line subtotals to be equal to the total amount with taxes."), 'sale_tax': fields.many2one("account.tax.template", "Default sale tax"), 'purchase_tax': fields.many2one("account.tax.template", "Default purchase tax"), 'sale_tax_rate': fields.float('Sales tax (%)'), @@ -72,40 +72,40 @@ class account_config_settings(osv.osv_memory): 'sale_refund_journal_id': fields.many2one('account.journal', 'Sale refund journal'), 'sale_refund_sequence_prefix': fields.related('sale_refund_journal_id', 'sequence_id', 'prefix', type='char', string='Credit note sequence'), 'sale_refund_sequence_next': fields.related('sale_refund_journal_id', 'sequence_id', 'number_next', type='integer', string='Next credit note number'), - 'purchase_journal_id': fields.many2one('account.journal', 'Purchase Journal'), + 'purchase_journal_id': fields.many2one('account.journal', 'Purchase journal'), 'purchase_sequence_prefix': fields.related('purchase_journal_id', 'sequence_id', 'prefix', type='char', string='Supplier invoice sequence'), 'purchase_sequence_next': fields.related('purchase_journal_id', 'sequence_id', 'number_next', type='integer', string='Next supplier invoice number'), 'purchase_refund_journal_id': fields.many2one('account.journal', 'Purchase refund journal'), 'purchase_refund_sequence_prefix': fields.related('purchase_refund_journal_id', 'sequence_id', 'prefix', type='char', string='Supplier credit note sequence'), 'purchase_refund_sequence_next': fields.related('purchase_refund_journal_id', 'sequence_id', 'number_next', type='integer', string='Next supplier credit note number'), - 'module_account_check_writing': fields.boolean('pay your suppliers by check', + 'module_account_check_writing': fields.boolean('Pay your suppliers by check', help="""This allows you to check writing and printing. This installs the module account_check_writing."""), - 'module_account_accountant': fields.boolean('full accounting features: journals, legal statements, chart of accounts, etc.', + 'module_account_accountant': fields.boolean('Full accounting features: journals, legal statements, chart of accounts, etc.', help="""If you do not check this box, you will be able to do invoicing & payments, but not accounting (Journal Items, Chart of Accounts, ...)"""), - 'module_account_asset': fields.boolean('assets management', + 'module_account_asset': fields.boolean('Assets management', help="""This allows you to manage the assets owned by a company or a person. It keeps track of the depreciation occurred on those assets, and creates account move for those depreciation lines. This installs the module account_asset. If you do not check this box, you will be able to do invoicing & payments, but not accounting (Journal Items, Chart of Accounts, ...)"""), - 'module_account_budget': fields.boolean('budget management', + 'module_account_budget': fields.boolean('Budget management', help="""This allows accountants to manage analytic and crossovered budgets. Once the master budgets and the budgets are defined, the project managers can set the planned amount on each analytic account. This installs the module account_budget."""), - 'module_account_payment': fields.boolean('manage payment orders', + 'module_account_payment': fields.boolean('Manage payment orders', help="""This allows you to create and manage your payment orders, with purposes to * serve as base for an easy plug-in of various automated payment mechanisms, and * provide a more efficient way to manage invoice payments. This installs the module account_payment."""), - 'module_account_voucher': fields.boolean('manage customer payments', + 'module_account_voucher': fields.boolean('Manage customer payments', help="""This includes all the basic requirements of voucher entries for bank, cash, sales, purchase, expense, contra, etc. This installs the module account_voucher."""), - 'module_account_followup': fields.boolean('manage customer payment follow-ups', + 'module_account_followup': fields.boolean('Manage customer payment follow-ups', help="""This allows to automate letters for unpaid invoices, with multi-level recalls. This installs the module account_followup."""), - 'group_proforma_invoices': fields.boolean('allow pro-forma invoices', + 'group_proforma_invoices': fields.boolean('Allow pro-forma invoices', implied_group='account.group_proforma_invoices', help="Allows you to put invoices in pro-forma state."), 'default_sale_tax': fields.many2one('account.tax', 'Default sale tax', @@ -114,6 +114,9 @@ class account_config_settings(osv.osv_memory): help="This purchase tax will be assigned by default on new products."), 'decimal_precision': fields.integer('Decimal precision on journal entries', help="""As an example, a decimal precision of 2 will allow journal entries like: 9.99 EUR, whereas a decimal precision of 4 will allow journal entries like: 0.0231 EUR."""), + 'group_multi_currency': fields.boolean('Allow multi currencies', + implied_group='base.group_multi_currency', + help="Allows you multi currency environment"), } def _default_company(self, cr, uid, context=None): @@ -220,6 +223,16 @@ class account_config_settings(osv.osv_memory): return {'value': {'date_stop': end_date.strftime('%Y-%m-%d')}} return {} + def open_company_form(self, cr, uid, ids, context=None): + config = self.browse(cr, uid, ids[0], context) + return { + 'type': 'ir.actions.act_window', + 'name': 'Configure your Company', + 'res_model': 'res.company', + 'res_id': config.company_id.id, + 'view_mode': 'form', + } + def set_default_taxes(self, cr, uid, ids, context=None): """ set default sale and purchase taxes for products """ ir_values = self.pool.get('ir.values') diff --git a/addons/account/res_config_view.xml b/addons/account/res_config_view.xml index 2ea4431d478..d7618fbff5a 100644 --- a/addons/account/res_config_view.xml +++ b/addons/account/res_config_view.xml @@ -121,6 +121,10 @@ - - - - - - - - - - - - - - - - + - + - + @@ -972,7 +874,7 @@ stock.picking.out.tree - stock.picking + stock.picking.out @@ -1002,13 +904,16 @@