Reviewers: ,


Please review this at http://codereview.tryton.org/721003/

Affected files:
  M invoice.py


Index: invoice.py
===================================================================
--- a/invoice.py
+++ b/invoice.py
@@ -1014,29 +1014,29 @@ class Invoice(Workflow, ModelSQL, ModelV
         for invoice in invoices:
             invoice.check_account()
             invoice.check_same_account()
             invoice.check_cancel_move()

     def check_account(self):
         if self.account.company != self.company:
             self.raise_user_error('check_account', {
-                    'invoice': invoice.rec_name,
-                    'invoice_company': invoice.company.rec_name,
-                    'account': invoice.account.rec_name,
-                    'account_company': invoice.account.company.rec_name,
+                    'invoice': self.rec_name,
+                    'invoice_company': self.company.rec_name,
+                    'account': self.account.rec_name,
+                    'account_company': self.account.company.rec_name,
                     })

     def check_same_account(self):
         for line in self.lines:
             if (line.type == 'line'
                     and line.account == self.account):
                 self.raise_user_error('same_account_on_line', {
-                        'invoice': invoice.rec_name,
-                        'account': invoice.account.rec_name,
+                        'invoice': self.rec_name,
+                        'account': self.account.rec_name,
                         'line': line.rec_name,
                         })

     def check_cancel_move(self):
         if (self.type in ('out_invoice', 'out_credit_note')
                 and self.cancel_move):
             return False
         return True
@@ -1111,17 +1111,17 @@ class Invoice(Workflow, ModelSQL, ModelV
         Period = pool.get('account.period')

         lines = []

         if self.type in ('out_invoice', 'in_credit_note'):
             if self.account == journal.debit_account:
                 self.raise_user_error('same_debit_account', {
                         'journal': journal.rec_name,
-                        'invoice': invoice.rec_name,
+                        'invoice': self.rec_name,
                         })
             if not journal.debit_account:
                 self.raise_user_error('missing_debit_account',
                     (journal.rec_name,))

             lines.append({
                     'description': description,
                     'account': self.account.id,
@@ -1139,17 +1139,17 @@ class Invoice(Workflow, ModelSQL, ModelV
                     'credit': Decimal('0.0'),
                     'amount_second_currency': amount_second_currency,
                     'second_currency': second_currency,
                     })
         else:
             if self.account == journal.credit_account:
                 self.raise_user_error('same_credit_account', {
                         'journal': journal.rec_name,
-                        'invoice': invoice.rec_name,
+                        'invoice': self.rec_name,
                         })
             if not journal.credit_account:
                 self.raise_user_error('missing_credit_account',
                     (journal.rec_name,))

             lines.append({
                     'description': description,
                     'account': self.account.id,
@@ -1317,18 +1317,18 @@ class Invoice(Workflow, ModelSQL, ModelV
         pool = Pool()
         Date = pool.get('ir.date')
         Move = pool.get('account.move')
         Period = pool.get('account.period')

         move = self.move
         default = {}
         if move.period.state == 'close':
-            self.raise_user_warning('%s.get_cancel_move' % self,
-                'period_cancel_move', self.rec_name)
+            self.raise_user_warning('%s.get_cancel_move' % self, (
+                    'period_cancel_move', self.rec_name,))
             date = Date.today()
             period_id = Period.find(self.company.id, date=date)
             default.update({
                     'date': date,
                     'period': period_id,
                     })

         cancel_move, = Move.copy([move], default=default)
@@ -2196,28 +2196,28 @@ class InvoiceTax(ModelSQL, ModelView):
                     'invoice': self.invoice.rec_name,
                     'invoice_company': self.invoice.company.rec_name,
                     'account': self.account.rec_name,
                     'account_company': self.account.company.rec_name,
                     })
         if self.base_code:
             if self.base_code.company != company:
                 self.raise_user_error('invalid_base_code_company', {
-                        'invoice': tax.invoice.rec_name,
-                        'invoice_company': tax.invoice.company.rec_name,
-                        'base_code': tax.base_code.rec_name,
- 'base_code_company': tax.base_code.company.rec_name,
+                        'invoice': self.invoice.rec_name,
+                        'invoice_company': self.invoice.company.rec_name,
+                        'base_code': self.base_code.rec_name,
+ 'base_code_company': self.base_code.company.rec_name,
                         })
         if self.tax_code:
             if self.tax_code.company != company:
                 self.raise_user_error('invalid_tax_code_company', {
-                        'invoice': tax.invoice.rec_name,
-                        'invoice_company': tax.invoice.company.rec_name,
-                        'tax_code': tax.tax_code.rec_name,
-                        'tax_code_company': tax.tax_code.company.rec_name,
+                        'invoice': self.invoice.rec_name,
+                        'invoice_company': self.invoice.company.rec_name,
+                        'tax_code': self.tax_code.rec_name,
+                        'tax_code_company': self.tax_code.company.rec_name,
                         })

     def get_move_line(self):
         '''
         Return a list of move lines values for invoice tax
         '''
         Currency = Pool().get('currency.currency')
         res = {}


Reply via email to