Skip to content

Commit

Permalink
fix: avoid accidental duplicate invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
rubencabrera committed Apr 26, 2023
1 parent e47d242 commit 1c0f181
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion partner_portal_extra_details/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging

from datetime import date
from odoo import api, fields, models, _
from odoo.exceptions import UserError

Expand Down Expand Up @@ -133,8 +134,13 @@ def _send_mail_to_new_validate_user(self):
account_invoice = invoices = self.env['account.invoice']
dom = [
('partner_id', '=', partner.id),
('state', '=', 'draft')
(
'date_invoice',
'>=',
date(date.today().year, 1, 1).strftime("%Y-%m-%d")
)
]
_logger.debug("Domain: %s", dom)
invoices |= account_invoice.search(
dom, order='date_invoice asc', limit=1
)
Expand Down

0 comments on commit 1c0f181

Please sign in to comment.