Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX] l10n_do_accounting: wizard fix to create a credit note #1123

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading