From b33ce231c8b2c8f736895f2c8bf52ad726d848a0 Mon Sep 17 00:00:00 2001 From: Mathias Behrle Date: Thu, 14 Apr 2011 14:56:27 +0200 Subject: [PATCH] Reverting surplus changes to company introduced by c32d5ba495f8 for issue1941. --- statement.py | 54 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/statement.py b/statement.py index 9498e7304f..e40d82a1d4 100644 --- a/statement.py +++ b/statement.py @@ -28,7 +28,7 @@ class Statement(ModelWorkflow, ModelSQL, ModelView): Bool(Eval('lines'))), }, on_change=['journal'], select=1) currency_digits = fields.Function(fields.Integer('Currency Digits', - on_change_with=['company']), 'get_currency_digits') + on_change_with=['journal']), 'get_currency_digits') date = fields.Date('Date', required=True, states=_STATES, select=1) start_balance = fields.Numeric('Start Balance', digits=(16, Eval('currency_digits', 2)), @@ -39,8 +39,8 @@ class Statement(ModelWorkflow, ModelSQL, ModelView): lines = fields.One2Many('account.statement.line', 'statement', 'Transactions', states={ 'readonly': Or(Not(Equal(Eval('state'), 'draft')), - Not(Bool(Eval('company')))), - }, on_change=['lines', 'company']) + Not(Bool(Eval('journal')))), + }, on_change=['lines', 'journal']) state = fields.Selection([ ('draft', 'Draft'), ('validated', 'Validated'), @@ -119,16 +119,16 @@ class Statement(ModelWorkflow, ModelSQL, ModelView): return res def on_change_with_currency_digits(self, vals): - company_obj = self.pool.get('company.company') - if vals.get('company'): - company = company_obj.browse(vals['company']) - return company.currency.digits + journal_obj = self.pool.get('account.statement.journal') + if vals.get('journal'): + journal = journal_obj.browse(vals['journal']) + return journal.currency.digits return 2 def get_currency_digits(self, ids, name): res = {} for statement in self.browse(ids): - res[statement.id] = statement.company.currency.digits + res[statement.id] = statement.journal.currency.digits return res def get_rec_name(self, ids, name): @@ -149,10 +149,10 @@ class Statement(ModelWorkflow, ModelSQL, ModelView): for statement in self.browse(ids): res[statement.id] = statement.journal.name + ' ' + \ lang.currency(lang, statement.start_balance, - statement.company.currency, symbol=False, + statement.journal.currency, symbol=False, grouping=True) + \ lang.currency(lang, statement.end_balance, - statement.company.currency, symbol=False, + statement.journal.currency, symbol=False, grouping=True) return res @@ -190,13 +190,13 @@ class Statement(ModelWorkflow, ModelSQL, ModelView): def on_change_lines(self, values): invoice_obj = self.pool.get('account.invoice') - company_obj = self.pool.get('company.company') + journal_obj = self.pool.get('account.statement.journal') currency_obj = self.pool.get('currency.currency') res = { 'lines': {}, } - if values.get('company') and values.get('lines'): - company = company_obj.browse(values['company']) + if values.get('journal') and values.get('lines'): + journal = journal_obj.browse(values['journal']) invoice_ids = set() for line in values['lines']: if line['invoice']: @@ -205,14 +205,14 @@ class Statement(ModelWorkflow, ModelSQL, ModelView): for invoice in invoice_obj.browse(invoice_ids): invoice_id2amount_to_pay[invoice.id] = currency_obj.compute( invoice.currency, invoice.amount_to_pay, - company.currency) + journal.currency) for line in values['lines']: if line['invoice'] and line['id']: amount_to_pay = invoice_id2amount_to_pay[line['invoice']] if abs(line['amount']) > amount_to_pay: res['lines'].setdefault('update', []) - if currency_obj.is_zero(company.currency, + if currency_obj.is_zero(journal.currency, amount_to_pay): res['lines']['update'].append({ 'id': line['id'], @@ -254,7 +254,7 @@ class Statement(ModelWorkflow, ModelSQL, ModelView): lang = lang_obj.browse(lang_ids[0]) amount = lang_obj.format(lang, - '%.' + str(statement.company.currency.digits) + 'f', + '%.' + str(statement.journal.currency.digits) + 'f', computed_end_balance, True) self.raise_user_error('wrong_end_balance', error_args=(amount,)) for line in statement.lines: @@ -303,7 +303,7 @@ class Line(ModelSQL, ModelView): digits=(16, Get(Eval('_parent_statement', {}), 'currency_digits', 2)), on_change=['amount', 'party', 'account', 'invoice', - '_parent_statement.company']) + '_parent_statement.journal']) party = fields.Many2One('party.party', 'Party', on_change=['amount', 'party', 'invoice']) account = fields.Many2One('account.account', 'Account', required=True, @@ -362,7 +362,7 @@ class Line(ModelSQL, ModelView): def on_change_amount(self, value): party_obj = self.pool.get('party.party') invoice_obj = self.pool.get('account.invoice') - company_obj = self.pool.get('company.company') + journal_obj = self.pool.get('account.statement.journal') currency_obj = self.pool.get('currency.currency') res = {} @@ -380,11 +380,11 @@ class Line(ModelSQL, ModelView): res['account'] = account.id res['account.rec_name'] = account.rec_name if value.get('invoice'): - if value.get('amount') and value.get('_parent_statement.company'): + if value.get('amount') and value.get('_parent_statement.journal'): invoice = invoice_obj.browse(value['invoice']) - company = company_obj.browse(value['_parent_statement.company']) + journal = journal_obj.browse(value['_parent_statement.journal']) amount_to_pay = currency_obj.compute(invoice.currency, - invoice.amount_to_pay, company.currency) + invoice.amount_to_pay, journal.currency) if abs(value['amount']) > amount_to_pay: res['invoice'] = False else: @@ -437,7 +437,7 @@ class Line(ModelSQL, ModelView): if line.invoice: amount_to_pay = currency_obj.compute(line.invoice.currency, - line.invoice.amount_to_pay, line.statement.company.currency) + line.invoice.amount_to_pay, line.statement.journal.currency) if amount_to_pay < abs(line.amount): for code in [Transaction().language, 'en_US']: lang_ids = lang_obj.search([ @@ -448,12 +448,12 @@ class Line(ModelSQL, ModelView): lang = lang_obj.browse(lang_ids[0]) amount = lang_obj.format(lang, - '%.' + str(line.statement.company.currency.digits) + 'f', + '%.' + str(line.statement.journal.currency.digits) + 'f', line.amount, True) self.raise_user_error('amount_greater_invoice_amount_to_pay', error_args=(amount,)) - amount = currency_obj.compute(line.statement.company.currency, + amount = currency_obj.compute(line.statement.journal.currency, line.amount, line.statement.company.currency) reconcile_lines = invoice_obj.get_reconcile_lines_for_amount( @@ -491,11 +491,11 @@ class Line(ModelSQL, ModelView): currency_obj = self.pool.get('currency.currency') zero = Decimal("0.0") amount = currency_obj.compute( - statement_line.statement.company.currency, statement_line.amount, + statement_line.statement.journal.currency, statement_line.amount, statement_line.statement.company.currency) - if statement_line.statement.company.currency.id != \ + if statement_line.statement.journal.currency.id != \ statement_line.statement.company.currency.id: - second_currency = statement_line.statement.company.currency.id + second_currency = statement_line.statement.journal.currency.id amount_second_currency = abs(statement_line.amount) else: amount_second_currency = False