Skip to content

Commit

Permalink
Merge pull request #182 from coopiteasy/12.0-4273-identical-invoices
Browse files Browse the repository at this point in the history
[12.0][FIX] ai_check_identical_invoice: check on invoice type
  • Loading branch information
vvrossem authored Jul 22, 2021
2 parents 213ebab + d3e1b7d commit 827be16
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions account_invoice_check_identical_invoice/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,23 @@ class AccountInvoice(models.Model):
copy=False,
help="You need to check this box to validate the invoice if"
" invoices with the same partner,"
" invoice date and totam alount already exist.",
" invoice date and total amount already exist.",
)
identical_invoice_detected = fields.Boolean(
"identical_invoice_detected", compute="_compute_identical_invoice"
)

@api.onchange("partner_id", "date_invoice")
@api.multi
def _onchange_compute_identical_invoice(self):
self._compute_identical_invoice()

@api.multi
@api.depends("partner_id", "date_invoice", "amount_total")
def _compute_identical_invoice(self):
Invoice = self.env["account.invoice"]
for invoice in self:
duplicate_domain = [
("state", "not in", ["draft", "cancel"]),
("partner_id.supplier", "=", True),
("partner_id", "=", invoice.partner_id.id),
]
partner_invoices = Invoice.search(duplicate_domain)
partner_invoices = self.env["account.invoice"].search(
[
("state", "not in", ["draft", "cancel"]),
("type", "=", "in_invoice"),
("partner_id", "=", invoice.partner_id.id),
]
)

def equal_amount(i):
return round(i.amount_total, 2) == round(
Expand All @@ -61,7 +57,6 @@ def invoiced_today(i):

@api.multi
def invoice_validate(self):
self._compute_identical_invoice()
for invoice in self:
if (
invoice.identical_invoice_detected
Expand Down

0 comments on commit 827be16

Please sign in to comment.