Skip to content

Commit

Permalink
Merge commit 'refs/pull/792/head' of https://github.com/OCA/bank-payment
Browse files Browse the repository at this point in the history
 into kcv/14.0.2.0.11
  • Loading branch information
dnplkndll committed Apr 23, 2021
2 parents 00e723d + 462cfa3 commit 2dd0c1c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 38 deletions.
2 changes: 1 addition & 1 deletion account_payment_order/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _prepare_payment_line_vals(self, payment_order):
aplo = self.env["account.payment.line"]
# default values for communication_type and communication
communication_type = "normal"
communication = self.ref or self.name
communication = self.ref or self.name or (self.move_id and self.move_id.name)
# change these default values if move line is linked to an invoice
if self.move_id.is_invoice():
if self.move_id.reference_type != "none":
Expand Down
2 changes: 1 addition & 1 deletion account_payment_order/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def _prepare_move_line_offsetting_account(
vals.update({"date_maturity": bank_lines[0].date})

if self.payment_mode_id.offsetting_account == "bank_account":
account_id = self.journal_id.default_account_id.id
account_id = self.journal_id.payment_debit_account_id.id
elif self.payment_mode_id.offsetting_account == "transfer_account":
account_id = self.payment_mode_id.transfer_account_id.id
partner_id = False
Expand Down
46 changes: 10 additions & 36 deletions account_payment_order/models/bank_payment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,42 +150,16 @@ def reconcile(self):
self.ensure_one()
amlo = self.env["account.move.line"]
transit_mlines = amlo.search([("bank_payment_line_id", "=", self.id)])
assert len(transit_mlines) == 1, "We should have only 1 move"
transit_mline = transit_mlines[0]
assert not transit_mline.reconciled, "Transit move should not be reconciled"
lines_to_rec = transit_mline
for payment_line in self.payment_line_ids:

if not payment_line.move_line_id:
raise UserError(
_(
"Can not reconcile: no move line for "
"payment line %s of partner '%s'."
)
% (payment_line.name, payment_line.partner_id.name)
)
if payment_line.move_line_id.reconciled:
raise UserError(
_("Move line '%s' of partner '%s' has already " "been reconciled")
% (payment_line.move_line_id.name, payment_line.partner_id.name)
)
if payment_line.move_line_id.account_id != transit_mline.account_id:
raise UserError(
_(
"For partner '%s', the account of the account "
"move line to pay (%s) is different from the "
"account of of the transit move line (%s)."
)
% (
payment_line.move_line_id.partner_id.name,
payment_line.move_line_id.account_id.code,
transit_mline.account_id.code,
)
)

lines_to_rec += payment_line.move_line_id

lines_to_rec.reconcile()
for line in transit_mlines:
lines_to_rec = line
for payment_line in self.payment_line_ids.filtered(
lambda x: x.move_line_id
and not x.move_line_id.reconciled
and x.move_line_id.account_id == line.account_id
and x.move_line_id.credit == line.debit
):
lines_to_rec += payment_line.move_line_id
lines_to_rec.reconcile()

def unlink(self):
for line in self:
Expand Down
6 changes: 6 additions & 0 deletions account_payment_order/views/account_payment_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
states="cancel"
string="Back to Draft"
/>
<button
name="action_done"
type="object"
states="uploaded"
string="Done Payments"
/>
<button
name="action_cancel"
type="object"
Expand Down

0 comments on commit 2dd0c1c

Please sign in to comment.