Skip to content

Commit

Permalink
[UPD] comentando _sql_constraints de NCF duplicados.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcape14 committed Nov 14, 2024
1 parent 5944720 commit 5d17ddd
Showing 1 changed file with 64 additions and 64 deletions.
128 changes: 64 additions & 64 deletions l10n_do_accounting/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,70 +124,70 @@ def _get_l10n_do_income_type(self):
"manually because a new expiration date was set on journal",
)

_sql_constraints = [
(
"unique_l10n_do_fiscal_number_sales",
"",
"Another document with the same fiscal number already exists.",
),
(
"unique_l10n_do_fiscal_number_purchase_manual",
"",
"Another document for the same partner with the same fiscal number already exists.",
),
(
"unique_l10n_do_fiscal_number_purchase_internal",
"",
"Another document for the same partner with the same fiscal number already exists.",
),
]

def _auto_init(self):
if not index_exists(
self.env.cr, "account_move_unique_l10n_do_fiscal_number_sales"
):
drop_index(
self.env.cr,
"account_move_unique_l10n_do_fiscal_number_purchase_manual",
self._table,
)
drop_index(
self.env.cr,
"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
ON account_move(l10n_do_fiscal_number, company_id)
WHERE (l10n_latam_document_type_id IS NOT NULL
AND move_type NOT IN ('in_invoice', 'in_refund'))
AND l10n_do_fiscal_number <> '';
CREATE UNIQUE INDEX account_move_unique_l10n_do_fiscal_number_purchase_manual
ON account_move(l10n_do_fiscal_number, commercial_partner_id, company_id)
WHERE (l10n_latam_document_type_id IS NOT NULL AND move_type IN ('in_invoice', 'in_refund')
AND l10n_latam_manual_document_number = 't')
AND l10n_do_fiscal_number <> '';
CREATE UNIQUE INDEX account_move_unique_l10n_do_fiscal_number_purchase_internal
ON account_move(l10n_do_fiscal_number, company_id)
WHERE (l10n_latam_document_type_id IS NOT NULL AND move_type IN ('in_invoice', 'in_refund', 'in_receipt')
AND l10n_latam_manual_document_number = 'f')
AND l10n_do_fiscal_number <> '';
"""
)
return super()._auto_init()
# _sql_constraints = [
# (
# "unique_l10n_do_fiscal_number_sales",
# "",
# "Another document with the same fiscal number already exists.",
# ),
# (
# "unique_l10n_do_fiscal_number_purchase_manual",
# "",
# "Another document for the same partner with the same fiscal number already exists.",
# ),
# (
# "unique_l10n_do_fiscal_number_purchase_internal",
# "",
# "Another document for the same partner with the same fiscal number already exists.",
# ),
# ]
#
# def _auto_init(self):
# if not index_exists(
# self.env.cr, "account_move_unique_l10n_do_fiscal_number_sales"
# ):
# drop_index(
# self.env.cr,
# "account_move_unique_l10n_do_fiscal_number_purchase_manual",
# self._table,
# )
# drop_index(
# self.env.cr,
# "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
# ON account_move(l10n_do_fiscal_number, company_id)
# WHERE (l10n_latam_document_type_id IS NOT NULL
# AND move_type NOT IN ('in_invoice', 'in_refund'))
# AND l10n_do_fiscal_number <> '';
#
# CREATE UNIQUE INDEX account_move_unique_l10n_do_fiscal_number_purchase_manual
# ON account_move(l10n_do_fiscal_number, commercial_partner_id, company_id)
# WHERE (l10n_latam_document_type_id IS NOT NULL AND move_type IN ('in_invoice', 'in_refund')
# AND l10n_latam_manual_document_number = 't')
# AND l10n_do_fiscal_number <> '';
#
# CREATE UNIQUE INDEX account_move_unique_l10n_do_fiscal_number_purchase_internal
# ON account_move(l10n_do_fiscal_number, company_id)
# WHERE (l10n_latam_document_type_id IS NOT NULL AND move_type IN ('in_invoice', 'in_refund', 'in_receipt')

Check failure on line 185 in l10n_do_accounting/models/account_move.py

View workflow job for this annotation

GitHub Actions / flake8

line too long (123 > 120 characters)
# AND l10n_latam_manual_document_number = 'f')
# AND l10n_do_fiscal_number <> '';
# """
# )
# return super()._auto_init()

@api.model
def _name_search(
Expand Down

0 comments on commit 5d17ddd

Please sign in to comment.