Set default journal when paying line

Only when there is only one available journal.

issue6077
review33641002
This commit is contained in:
Cédric Krier
2016-12-13 18:34:22 +01:00
parent 432b27e844
commit f90825590d
4 changed files with 13 additions and 5 deletions
+2
View File
@@ -1,3 +1,5 @@
* Set default journal when paying line
Version 4.2.0 - 2016-11-28
* Bug fixes (see mercurial logs for details)
* Allow to block payment of line
+9
View File
@@ -229,8 +229,17 @@ class PayLine(Wizard):
return 'pay'
def default_ask_journal(self, fields):
pool = Pool()
Journal = pool.get('account.payment.journal')
values = {}
company, currency = self._missing_journal()[:2]
journals = Journal.search([
('company', '=', company),
('currency', '=', currency),
])
if len(journals) == 1:
journal, = journals
values['journal'] = journal.id
values['company'] = company.id
values['currency'] = currency.id
values['journals'] = [j.id for j in self._get_journals().itervalues()]
+2 -4
View File
@@ -65,7 +65,8 @@ Partially pay line::
>>> Payment = Model.get('account.payment')
>>> line, = [l for l in move.lines if l.account == payable]
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.form.journal = payment_journal
>>> pay_line.form.journal == payment_journal
True
>>> pay_line.execute('start')
>>> payment, = Payment.find()
>>> payment.party == supplier
@@ -88,7 +89,6 @@ Partially pay line::
Partially fail to pay the remaining::
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.form.journal = payment_journal
>>> pay_line.execute('start')
>>> payment, = Payment.find([('state', '=', 'draft')])
>>> payment.amount
@@ -113,7 +113,6 @@ Pay line and block it after::
>>> move.click('post')
>>> line, = [l for l in move.lines if l.account == payable]
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.form.journal = payment_journal
>>> pay_line.execute('start')
>>> len(line.payments)
1
@@ -125,7 +124,6 @@ Pay line and block it after::
Try to pay blocked line::
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.form.journal = payment_journal
>>> pay_line.execute('start') # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
@@ -74,7 +74,6 @@ Partially pay line::
>>> Payment = Model.get('account.payment')
>>> pay_line = Wizard('account.move.line.pay', [line_to_pay])
>>> pay_line.form.journal = payment_journal
>>> pay_line.execute('start')
>>> payment, = Payment.find()
>>> payment.amount = Decimal('20')