Browse Source

[FIX] change state account.interest

adrielso 6 years ago
parent
commit
e9c8d5fb73
1 changed files with 15 additions and 0 deletions
  1. 15 0
      models/eiru_account_interest.py

+ 15 - 0
models/eiru_account_interest.py

@@ -281,6 +281,21 @@ class EiruAccountInterest(models.Model):
                     'amount_dicount': round(line['discount'],decimal_precision)
                 })
 
+        ''' Verify State interest '''
+        state = []
+        linesState = map(lambda x: x.state, accountInterest.lines_ids)
+
+        if (('discount'in linesState) or ('paid' in linesState)):
+            state ={ 'state': 'lines_paid'}
+
+            if (accountInterest.invoice_id.state == 'paid'):
+                state ={ 'state': 'paid'}
+
+        if (('invoiced' in  linesState) or ('invoice_cancel' in linesState) or ('invoice_draft' in linesState) or ('open' in linesState)):
+            state ={'state': 'lines_open'}
+
+        if (state):
+            accountInterest.write(state)
 
         return {
             'state': True,