Skip to content

Commit 65248ed

Browse files
odooNextevBorruso
authored andcommitted
[FIX] l10n_it_edi_extension: fix migration script for fc, rea and rd
1 parent 6c7ffd9 commit 65248ed

File tree

1 file changed

+12
-72
lines changed

1 file changed

+12
-72
lines changed

l10n_it_edi_extension/__init__.py

Lines changed: 12 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -653,77 +653,6 @@ def _l10n_it_fatturapa_post_migration_payment_data(env):
653653
move.sudo().message_post(body=message)
654654

655655

656-
def _l10n_it_fatturapa_post_migration_related_document_type(env):
657-
env.cr.execute("""
658-
SELECT invoice_id, invoice_line_id, type, name, date, code, cig, cup
659-
FROM fatturapa_related_document_type
660-
WHERE invoice_id IS NOT NULL OR invoice_line_id IS NOT NULL
661-
""")
662-
rows = env.cr.fetchall()
663-
invoice_map = {}
664-
for row in rows:
665-
invoice_id, invoice_line_id, document_type, name, date, code, cig, cup = row
666-
move_id = (
667-
invoice_id or env["account.move.line"].browse(invoice_line_id).move_id.id
668-
)
669-
if move_id:
670-
invoice_map.setdefault(move_id, []).append(
671-
(document_type, name, date, code, cig, cup)
672-
)
673-
674-
moves = env["account.move"].browse(invoice_map.keys())
675-
out_moves = moves.filtered(lambda m: m.is_sale_document())
676-
for move in out_moves:
677-
for index, (document_type, name, date, code, cig, cup) in enumerate(
678-
invoice_map[move.id], start=1
679-
):
680-
if index == 1:
681-
if document_type == "order":
682-
document_type = "purchase_order"
683-
elif document_type not in ["contract", "agreement"]:
684-
document_type = ""
685-
move.l10n_it_origin_document_type = document_type
686-
move.l10n_it_origin_document_name = name
687-
move.l10n_it_origin_document_date = date
688-
move.l10n_it_cig = cig
689-
move.l10n_it_cup = cup
690-
else:
691-
document_type_tags = Markup('<ul class="mb-0">{}</ul>').format(
692-
Markup().join(
693-
nl2br_enclose(" ".join(tag.split()), "li")
694-
for tag in [
695-
f"IdDocumento: {name}",
696-
f'Data: {date or "N/A"}',
697-
f'CodiceCommessaConvenzione: {code or "N/A"}',
698-
f'CodiceCIG: {cig or "N/A"}',
699-
f'CodiceCUP: {cup or "N/A"}',
700-
]
701-
)
702-
)
703-
message = Markup("{} {}<br/>{}").format(
704-
document_type, env._("from XML file:"), document_type_tags
705-
)
706-
move.sudo().message_post(body=message)
707-
for move in moves - out_moves:
708-
for document_type, name, date, code, cig, cup in invoice_map[move.id]:
709-
document_type_tags = Markup('<ul class="mb-0">{}</ul>').format(
710-
Markup().join(
711-
nl2br_enclose(" ".join(tag.split()), "li")
712-
for tag in [
713-
f"IdDocumento: {name}",
714-
f'Data: {date or "N/A"}',
715-
f'CodiceCommessaConvenzione: {code or "N/A"}',
716-
f'CodiceCIG: {cig or "N/A"}',
717-
f'CodiceCUP: {cup or "N/A"}',
718-
]
719-
)
720-
)
721-
message = Markup("{} {}<br/>{}").format(
722-
document_type, env._("from XML file:"), document_type_tags
723-
)
724-
move.sudo().message_post(body=message)
725-
726-
727656
def _l10n_it_fatturapa_post_migration(env):
728657
table = "res_partner"
729658
rename_fields(
@@ -802,7 +731,6 @@ def _l10n_it_fatturapa_post_migration(env):
802731
_l10n_it_fatturapa_post_migration_delivery_data(env)
803732
_l10n_it_fatturapa_post_migration_vehicle_data(env)
804733
_l10n_it_fatturapa_post_migration_payment_data(env)
805-
_l10n_it_fatturapa_post_migration_related_document_type(env)
806734

807735

808736
def _l10n_it_fatturapa_in_pre_migration(env):
@@ -1014,6 +942,10 @@ def _l10n_it_fiscalcode_post_migration(env):
1014942
rename_fields(
1015943
env, table, {"l10n_it_codice_fiscale": "fiscalcode"}, condition=condition
1016944
)
945+
table = "res_company"
946+
rename_fields(
947+
env, table, {"l10n_it_codice_fiscale": "fiscalcode"}, condition=condition
948+
)
1017949

1018950

1019951
def _l10n_it_ipa_post_migration(env):
@@ -1045,6 +977,14 @@ def _l10n_it_rea_post_migration(env):
1045977
},
1046978
condition,
1047979
)
980+
openupgrade.logged_query(
981+
env.cr,
982+
"""
983+
UPDATE res_company
984+
SET l10n_it_has_eco_index = 't'
985+
WHERE l10n_it_eco_index_number IS NOT NULL
986+
""",
987+
)
1048988

1049989

1050990
def _l10n_it_vat_payability_pre_migration(env):

0 commit comments

Comments
 (0)