Skip to content

Commit

Permalink
[FIX] send to_auto_reconcile when config state draft only
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 committed Jan 3, 2025
1 parent cae839c commit 56f0c2a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions account_payment_register_draft/wizard/account_payment_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@

from odoo import models

MAPPING_TYPE = {
"inbound": "register_customer_payment_state",
"outbound": "register_vendor_payment_state",
}


class AccountPaymentRegister(models.TransientModel):
_inherit = "account.payment.register"

def _check_payment_draft(self):
return bool(self.env.company[MAPPING_TYPE.get(self.payment_type)] == "draft")

def _create_payment_vals_from_wizard(self):
payment_vals = super()._create_payment_vals_from_wizard()
payment_vals["to_auto_reconcile"] = self._get_batches()[0]["lines"]
if self._check_payment_draft():
payment_vals["to_auto_reconcile"] = self._get_batches()[0]["lines"]

Check warning on line 21 in account_payment_register_draft/wizard/account_payment_register.py

View check run for this annotation

Codecov / codecov/patch

account_payment_register_draft/wizard/account_payment_register.py#L21

Added line #L21 was not covered by tests
return payment_vals

def _create_payment_vals_from_batch(self, batch_result):
payment_vals = super()._create_payment_vals_from_batch(batch_result)
payment_vals["to_auto_reconcile"] = batch_result["lines"]
if self._check_payment_draft():
payment_vals["to_auto_reconcile"] = batch_result["lines"]

Check warning on line 27 in account_payment_register_draft/wizard/account_payment_register.py

View check run for this annotation

Codecov / codecov/patch

account_payment_register_draft/wizard/account_payment_register.py#L27

Added line #L27 was not covered by tests
return payment_vals

def _create_payments(self):
self = self.with_context(skip_clear_auto_reconcile=1)
payments = super()._create_payments()
mapping_function = {
"inbound": "register_customer_payment_state",
"outbound": "register_vendor_payment_state",
}
if (
mapping_function.get(self.payment_type, False)
and self.env.company[mapping_function[self.payment_type]] == "draft"
):
if self._check_payment_draft():
payments.with_context(skip_clear_auto_reconcile=1).action_draft()

Check warning on line 34 in account_payment_register_draft/wizard/account_payment_register.py

View check run for this annotation

Codecov / codecov/patch

account_payment_register_draft/wizard/account_payment_register.py#L34

Added line #L34 was not covered by tests
return payments

0 comments on commit 56f0c2a

Please sign in to comment.