Skip to content

Commit

Permalink
[FIX] custom_account: Sólo se hace la comprobación de cronología en l…
Browse files Browse the repository at this point in the history
…as facturas wmitidas.
  • Loading branch information
omar7r committed Dec 1, 2020
1 parent 6e88cd6 commit fb5dd33
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions project-addons/custom_account/models/invoice.py
Expand Up @@ -11,17 +11,19 @@ class AccountInvoice(models.Model):
@api.constrains("invoice_number")
def check_last_invoice_number(self):
for inv in self:
if inv.invoice_number:
if inv.invoice_number and inv.type \
in ("out_refund", "out_invoice"):
sequence = inv.journal_id.invoice_sequence_id
if (
inv.type in {"out_refund", "in_refund"}
inv.type == "out_refund"
and inv.journal_id.refund_inv_sequence_id
):
sequence = inv.journal_id.refund_inv_sequence_id
if sequence.implementation == "no_gap":
prefix, suffix = sequence.with_context(
ir_sequence_date=inv.date_invoice.strftime("%Y-%m-%d"),
ir_sequence_date_range=inv.date_invoice.strftime("%Y-%m-%d"),
ir_sequence_date_range=inv.
date_invoice.strftime("%Y-%m-%d"),
)._get_prefix_suffix()
num_char = inv.invoice_number.replace(prefix, "").replace(
suffix, ""
Expand Down Expand Up @@ -51,7 +53,8 @@ def check_last_invoice_number(self):

@api.model
def _prepare_refund(
self, invoice, date_invoice=None, date=None, description=None, journal_id=None
self, invoice, date_invoice=None, date=None, description=None,
journal_id=None
):
vals = super(AccountInvoice, self)._prepare_refund(
invoice, date_invoice, date, description, journal_id
Expand Down

0 comments on commit fb5dd33

Please sign in to comment.