summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqdp-odoo <qdp@odoo.com>2017-10-25 12:04:38 +0200
committerqdp-odoo <qdp@odoo.com>2017-10-25 12:04:38 +0200
commite69fb3f82d386b14ffbdc6fda4bb38df533d29b0 (patch)
tree26260e9f73896125abcfaf030a4ee4b8ecff58d3
parentea9b574ac6fbe26551bcb1881bf1e036dce82800 (diff)
[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
-rw-r--r--addons/account_voucher/models/account_voucher.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/addons/account_voucher/models/account_voucher.py b/addons/account_voucher/models/account_voucher.py
index 467ed1c4533..c288aa53def 100644
--- a/addons/account_voucher/models/account_voucher.py
+++ b/addons/account_voucher/models/account_voucher.py
@@ -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
@@ -222,6 +223,24 @@ class AccountVoucher(models.Model):
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):
'''
Create one account move line, on the given account move, per voucher line where amount is not 0.0.
@@ -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