Skip to content

Commit

Permalink
[WIP] l10n_do_accounting: v17 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
jose-pcg committed May 16, 2024
1 parent 6b33048 commit 1bbfef6
Showing 1 changed file with 10 additions and 34 deletions.
44 changes: 10 additions & 34 deletions l10n_do_accounting/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ def _auto_init(self):
"account_move_unique_l10n_do_fiscal_number_purchase_internal",
self._table,
)

if not column_exists(self.env.cr, "account_move", "l10n_do_fiscal_number"):
create_column(
self.env.cr, "account_move", "l10n_do_fiscal_number", "varchar"
)
if not column_exists(self.env.cr, "account_move", "l10n_latam_manual_document_number"):
create_column(
self.env.cr, "account_move", "l10n_latam_manual_document_number", "varchar"
)

self.env.cr.execute(
"""
CREATE UNIQUE INDEX account_move_unique_l10n_do_fiscal_number_sales
Expand Down Expand Up @@ -380,40 +390,6 @@ def _compute_l10n_do_electronic_stamp(self):

(self - l10n_do_ecf_invoice).l10n_do_electronic_stamp = False

# @api.constrains("name", "journal_id", "state", "l10n_do_fiscal_number")
# def _check_unique_sequence_number(self):
# l10n_do_invoices = self.filtered(
# lambda inv: inv.l10n_latam_use_documents
# and inv.country_code == "DO"
# and inv.is_sale_document()
# and inv.state == "posted"
# )
# if l10n_do_invoices:
# self.flush_model(
# ["name", "journal_id", "move_type", "state", "l10n_do_fiscal_number"]
# )
# self._cr.execute(
# """
# SELECT move2.id, move2.l10n_do_fiscal_number
# FROM account_move move
# INNER JOIN account_move move2 ON
# move2.l10n_do_fiscal_number = move.l10n_do_fiscal_number
# AND move2.journal_id = move.journal_id
# AND move2.move_type = move.move_type
# AND move2.id != move.id
# WHERE move.id IN %s AND move2.state = 'posted'
# """,
# [tuple(l10n_do_invoices.ids)],
# )
# res = self._cr.fetchone()
# if res:
# raise ValidationError(
# _("There is already a sale invoice with fiscal number %s")
# % self.l10n_do_fiscal_number
# )
#
# super(AccountMove, (self - l10n_do_invoices))._check_unique_sequence_number()

@api.constrains(
"l10n_do_fiscal_number", "partner_id", "company_id", "posted_before"
)
Expand Down

0 comments on commit 1bbfef6

Please sign in to comment.