Check pending subscription to erase party

issue7169
review44701002
This commit is contained in:
Cédric Krier committed 2018-03-24 00:09:09 +01:00
1 parent a2a0f387e5
commit 82b329e599
3 files changed
+36 -3

No files matched your search

+3 -1
View File
@@ -1,5 +1,7 @@
* Check pending subscription to erase party
Version 4.6.0 - 2017-10-30
* Bug fixes (see mercurial logs for details)
Version 4.4.0 - 2017-05-01
* Initial release
* Initial release
+1
View File
@@ -28,6 +28,7 @@ def register():
subscription.CreateLineConsumption,
subscription.CreateSubscriptionInvoice,
party.PartyReplace,
party.PartyErase,
module='sale_subscription', type_='wizard')
Pool.register(
module='sale_subscription', type_='report')
+32 -2
View File
@@ -1,8 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.pool import PoolMeta
from trytond.pool import PoolMeta, Pool
__all__ = ['PartyReplace']
__all__ = ['PartyReplace', 'PartyErase']
class PartyReplace:
@@ -14,3 +14,33 @@ class PartyReplace:
return super(PartyReplace, cls).fields_to_replace() + [
('sale.subscription', 'party'),
]
class PartyErase:
__metaclass__ = PoolMeta
__name__ = 'party.erase'
@classmethod
def __setup__(cls):
super(PartyErase, cls).__setup__()
cls._error_messages.update({
'pending_subscription': (
'The party "%(party)s" can not be erased '
'because he has pending subscriptions '
'for the company "%(company)s".'),
})
def check_erase_company(self, party, company):
pool = Pool()
Subscription = pool.get('sale.subscription')
super(PartyErase, self).check_erase_company(party, company)
subscriptions = Subscription.search([
('party', '=', party.id),
('state', 'not in', ['closed', 'canceled']),
])
if subscriptions:
self.raise_user_error('pending_subscription', {
'party': party.rec_name,
'company': company.rec_name,
})