diff --git a/osi_quote_downpayment/models/account_move.py b/osi_quote_downpayment/models/account_move.py
index 4c2e40ea..bd6a8754 100644
--- a/osi_quote_downpayment/models/account_move.py
+++ b/osi_quote_downpayment/models/account_move.py
@@ -10,13 +10,13 @@ class AccountMove(models.Model):
#Prevents price of downpayment from being reset on draft sale orders
def action_post(self):
downpayment_lines = {}
- for rec in records:
+ for rec in self:
downpayment_lines[rec.id] = {}
for line in rec.invoice_line_ids:
if "Down payment" in line.name:
downpayment_lines[rec.id][line.id] = line.price_unit
res = super().action_post()
- for rec in records:
+ for rec in self:
for line in rec.invoice_line_ids:
if "Down payment" in line.name:
downpayment_lines[rec.id][line.id] = line.price_unit
diff --git a/osi_quote_downpayment/views/sale_order_views.xml b/osi_quote_downpayment/views/sale_order_views.xml
index 32137e07..17acb8d6 100644
--- a/osi_quote_downpayment/views/sale_order_views.xml
+++ b/osi_quote_downpayment/views/sale_order_views.xml
@@ -7,7 +7,7 @@
- invoice_status != 'to invoice' or state in ['draft', 'sent']
+ invoice_status != 'to invoice' and state not in ['draft', 'sent']
diff --git a/osi_quote_downpayment/wizards/sale_make_invoice_advance_views.xml b/osi_quote_downpayment/wizards/sale_make_invoice_advance_views.xml
index da9dc9df..d5c3ebd7 100644
--- a/osi_quote_downpayment/wizards/sale_make_invoice_advance_views.xml
+++ b/osi_quote_downpayment/wizards/sale_make_invoice_advance_views.xml
@@ -8,7 +8,7 @@
-
+