Skip to content

Commit

Permalink
[14.0][FIX] l10n_do_accounting: wizard fix to create a credit note (#…
Browse files Browse the repository at this point in the history
…1123)

* [FIX] l10n_do_accounting: wizard fix to create a credit note

* black solution

* black solution
  • Loading branch information
daniel-pcg authored Nov 24, 2023
1 parent c081873 commit b415b90
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
2 changes: 1 addition & 1 deletion l10n_do_accounting/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"category": "Localization",
"license": "LGPL-3",
"website": "https://github.com/odoo-dominicana",
"version": "14.0.2.18.1",
"version": "14.0.2.18.2",
# any module necessary for this one to work correctly
"depends": ["l10n_latam_invoice_document", "l10n_do"],
# always loaded
Expand Down
2 changes: 1 addition & 1 deletion l10n_do_accounting/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def _reverse_move_vals(self, default_values, cancel=True):
return res

if self.country_code == "DO":
res["l10n_do_origin_ncf"] = self.l10n_latam_document_number
res["l10n_do_origin_ncf"] = self.ref
res["l10n_do_ecf_modification_code"] = l10n_do_ecf_modification_code

if refund_type in ("percentage", "fixed_amount"):
Expand Down
63 changes: 63 additions & 0 deletions l10n_do_accounting/wizard/account_move_reversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,66 @@ def reverse_moves(self):
l10n_do_ecf_modification_code=self.l10n_do_ecf_modification_code,
),
).reverse_moves()

@api.depends("move_ids", "journal_id")
def _compute_document_type(self):
self.l10n_latam_available_document_type_ids = False
self.l10n_latam_document_type_id = False
self.l10n_latam_use_documents = False
do_wizard = self.filtered(
lambda w: w.journal_id
and w.journal_id.l10n_latam_use_documents
and w.country_code == "DO"
)
for record in do_wizard:
if len(record.move_ids) > 1:
move_ids_use_document = record.move_ids._origin.filtered(
lambda move: move.l10n_latam_use_documents
)
if move_ids_use_document:
raise UserError(
_(
"You can only reverse documents with legal invoicing documents from Latin America "
"one at a time.\nProblematic documents: %s"
)
% ", ".join(move_ids_use_document.mapped("name"))
)
else:
record.l10n_latam_use_documents = (
record.journal_id.l10n_latam_use_documents
)

if record.l10n_latam_use_documents:
refund = record.env["account.move"].new(
{
"move_type": record._reverse_type_map(
record.move_ids.move_type
),
"journal_id": record.journal_id.id,
"partner_id": record.move_ids.partner_id.id,
"company_id": record.move_ids.company_id.id,
}
)
record.l10n_latam_document_type_id = refund.l10n_latam_document_type_id
record.l10n_latam_available_document_type_ids = (
refund.l10n_latam_available_document_type_ids
)
super(AccountMoveReversal, self - do_wizard)._compute_document_type()

@api.depends("l10n_latam_document_type_id")
def _compute_l10n_latam_manual_document_number(self):
self.l10n_latam_manual_document_number = False
do_wizard = self.filtered(
lambda w: w.journal_id
and w.journal_id.l10n_latam_use_documents
and w.country_code == "DO"
and w.move_ids
)
for rec in do_wizard:
if rec.journal_id and rec.journal_id.l10n_latam_use_documents:
rec.l10n_latam_manual_document_number = self.env[
"account.move"
]._is_manual_document_number(rec.journal_id)
super(
AccountMoveReversal, self - do_wizard
)._compute_l10n_latam_manual_document_number()

0 comments on commit b415b90

Please sign in to comment.