[FIX] account_voucher: fix missing payment_id in "Pay Directly" voucher
Create an accout.voucher with "Pay Directly" as payment.
You get something like:
D | C
--------------------
Expenses: x |
Cash: | x
However, the expense line doesn't appear in the reconciliation widget
because the payment_id is missing in the account.move.line and then, doesn't match
the search domain for the reconciliation.
To solve it, a payment_id is created for this line in case of "Pay Directly" payment.
-opw: 775167
This commit is contained in:
@@ -183,6 +183,7 @@ class AccountVoucher(models.Model):
|
||||
if company_currency != current_currency else 0.0),
|
||||
'date': self.account_date,
|
||||
'date_maturity': self.date_due
|
||||
'payment_id': self._context.get('payment_id'),
|
||||
}
|
||||
return move_line
|
||||
|
||||
@@ -221,6 +222,24 @@ class AccountVoucher(models.Model):
|
||||
for voucher in self:
|
||||
return voucher.currency_id.compute(amount, voucher.company_id.currency_id)
|
||||
|
||||
@api.multi
|
||||
def voucher_pay_now_payment_create(self):
|
||||
payment_methods = self.journal_id.outbound_payment_method_ids
|
||||
return {
|
||||
'payment_type': 'outbound',
|
||||
'payment_method_id': payment_methods and payment_methods[0].id or False,
|
||||
'partner_type': 'supplier',
|
||||
'partner_id': self.partner_id.id,
|
||||
'amount': self.amount,
|
||||
'currency_id': self.currency_id.id,
|
||||
'payment_date': self.date,
|
||||
'journal_id': self.journal_id.id,
|
||||
'company_id': self.company_id.id,
|
||||
'communication': self.name,
|
||||
'name': self.name,
|
||||
'state': 'reconciled',
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def voucher_move_line_create(self, line_total, move_id, company_currency, current_currency):
|
||||
'''
|
||||
@@ -258,8 +277,8 @@ class AccountVoucher(models.Model):
|
||||
'tax_ids': [(4,t.id) for t in line.tax_ids],
|
||||
'amount_currency': line.price_subtotal if current_currency != company_currency else 0.0,
|
||||
'currency_id': company_currency != current_currency and current_currency or False,
|
||||
'payment_id': self._context.get('payment_id'),
|
||||
}
|
||||
|
||||
self.env['account.move.line'].with_context(apply_taxes=True).create(move_line)
|
||||
return line_total
|
||||
|
||||
@@ -279,6 +298,9 @@ class AccountVoucher(models.Model):
|
||||
ctx = local_context.copy()
|
||||
ctx['date'] = voucher.account_date
|
||||
ctx['check_move_validity'] = False
|
||||
# Create a payment to allow the reconciliation when pay_now = 'pay_now'.
|
||||
if self.pay_now == 'pay_now' and self.amount > 0:
|
||||
ctx['payment_id'] = self.env['account.payment'].create(self.voucher_pay_now_payment_create()).id
|
||||
# Create the account move record.
|
||||
move = self.env['account.move'].create(voucher.account_move_get())
|
||||
# Get the name of the account_move just created
|
||||
|
||||
Reference in New Issue
Block a user