diff --git a/addons/account/account.py b/addons/account/account.py index c9dd1950347..cfba30856a9 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -541,10 +541,18 @@ class account_account(osv.osv): return False return True + def _check_company_account(self, cr, uid, ids, context=None): + for account in self.browse(cr, uid, ids, context=context): + if account.parent_id: + if account.company_id != account.parent_id.company_id: + return False + return True + _constraints = [ (_check_recursion, 'Error!\nYou cannot create recursive accounts.', ['parent_id']), (_check_type, 'Configuration Error!\nYou cannot define children to an account with internal type different of "View".', ['type']), (_check_account_type, 'Configuration Error!\nYou cannot select an account type with a deferral method different of "Unreconciled" for accounts with internal type "Payable/Receivable".', ['user_type','type']), + (_check_company_account, 'Error!\nYou cannot create an account which has parent account of different company.', ['parent_id']), ] _sql_constraints = [ ('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !') diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 48082451f35..8e79376aa87 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -61,7 +61,7 @@ class account_bank_statement(osv.osv): return res def _get_period(self, cr, uid, context=None): - periods = self.pool.get('account.period').find(cr, uid) + periods = self.pool.get('account.period').find(cr, uid,context=context) if periods: return periods[0] return False diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 17fa05d5f24..c1f30824461 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -78,7 +78,7 @@ class account_cash_statement(osv.osv): """ res = {} for statement in self.browse(cr, uid, ids, context=context): - if statement.journal_id.type not in ('cash',): + if (statement.journal_id.type not in ('cash',)) or (not statement.journal_id.cash_control): continue start = end = 0 for line in statement.details_ids: @@ -289,13 +289,13 @@ class account_cash_statement(osv.osv): super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context) absl_proxy = self.pool.get('account.bank.statement.line') - TABLES = (('Profit', 'profit_account_id'), ('Loss', 'loss_account_id'),) + TABLES = ((_('Profit'), 'profit_account_id'), (_('Loss'), 'loss_account_id'),) for obj in self.browse(cr, uid, ids, context=context): if obj.difference == 0.0: continue - for item_label, item_account in TALBES: + for item_label, item_account in TABLES: if getattr(obj.journal_id, item_account): raise osv.except_osv(_('Error!'), _('There is no %s Account on the journal %s.') % (item_label, obj.journal_id.name,)) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 2f722d07aeb..4feb97c2f5f 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -168,10 +168,8 @@ context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}" domain="[('supplier', '=', True)]"/> - - - - + +