Add group lines wizard
issue8213 review275091002
This commit is contained in:
1 parent
b3705cc7f1
commit
942baf03be
4 files changed
+52
-1
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Add warning to group lines
|
||||
* Add date to Pay Lines wizard
|
||||
|
||||
Version 5.0.0 - 2018-10-01
|
||||
|
||||
+44
-1
@@ -18,7 +18,7 @@ from trytond.transaction import Transaction
|
||||
from trytond.tools.multivalue import migrate_property
|
||||
from trytond.modules.company.model import CompanyValueMixin
|
||||
|
||||
from .exceptions import BlockedWarning
|
||||
from .exceptions import BlockedWarning, GroupWarning
|
||||
from .payment import KINDS
|
||||
|
||||
__all__ = ['MoveLine', 'PayLine', 'PayLineAskJournal',
|
||||
@@ -229,6 +229,49 @@ class PayLine(Wizard):
|
||||
])
|
||||
pay = StateAction('account_payment.act_payment_form')
|
||||
|
||||
def default_start(self, fields):
|
||||
pool = Pool()
|
||||
Line = pool.get('account.move.line')
|
||||
Warning = pool.get('res.user.warning')
|
||||
|
||||
reverse = {'receivable': 'payable', 'payable': 'receivable'}
|
||||
types = {
|
||||
kind: {
|
||||
'parties': set(),
|
||||
'lines': list(),
|
||||
}
|
||||
for kind in reverse.keys()}
|
||||
lines = Line.browse(Transaction().context['active_ids'])
|
||||
for line in lines:
|
||||
for kind in types:
|
||||
if getattr(line.account.type, kind):
|
||||
types[kind]['parties'].add(line.party)
|
||||
types[kind]['lines'].append(line)
|
||||
|
||||
for kind in types:
|
||||
parties = types[kind]['parties']
|
||||
others = Line.search([
|
||||
('account.type.' + kind, '=', reverse[kind]),
|
||||
('party', 'in', [p.id for p in parties]),
|
||||
('reconciliation', '=', None),
|
||||
('payment_amount', '!=', 0),
|
||||
('move_state', '=', 'posted'),
|
||||
])
|
||||
for line in others:
|
||||
warning_name = '%s:%s' % (reverse[kind], line.party)
|
||||
if Warning.check(warning_name):
|
||||
lines = [l for l in types[kind]['lines']
|
||||
if l.party == line.party]
|
||||
names = ', '.join(l.rec_name for l in lines[:5])
|
||||
if len(lines) > 5:
|
||||
names += '...'
|
||||
raise GroupWarning(warning_name,
|
||||
gettext('account_payment.msg_pay_line_group',
|
||||
names=names,
|
||||
party=line.party.rec_name,
|
||||
line=line.rec_name))
|
||||
return {}
|
||||
|
||||
def _get_journals(self):
|
||||
journals = {}
|
||||
for journal in getattr(self.ask_journal, 'journals', []):
|
||||
|
||||
@@ -19,3 +19,7 @@ class PaymentValidationError(ValidationError):
|
||||
|
||||
class BlockedWarning(UserWarning):
|
||||
pass
|
||||
|
||||
|
||||
class GroupWarning(UserWarning):
|
||||
pass
|
||||
@@ -15,5 +15,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.message" id="msg_pay_line_blocked">
|
||||
<field name="text">Line "%(line)s" is blocked for payment.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_pay_line_group">
|
||||
<field name="text">The lines "%(names)s" for %(party)s could be grouped with the line "%(line)s".</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
Reference in new issue
Block a user