Check pending purchase to erase party

issue7169
review41161003
This commit is contained in:
Cédric Krier committed 2018-03-24 00:07:53 +01:00
1 parent 66c054f90f
commit 4cd3449dbc
3 files changed
+36 -4

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Check pending purchase to erase party
* Add wizard to modify purchase header after filling lines
* Make description on purchase line optional
* Add product supplier on purchase line
+3 -2
View File
@@ -7,7 +7,7 @@ from .product import *
from .stock import *
from .configuration import *
from .invoice import *
from .party import PartyReplace
from . import party
def register():
@@ -42,6 +42,7 @@ def register():
OpenSupplier,
HandleShipmentException,
HandleInvoiceException,
PartyReplace,
party.PartyReplace,
party.PartyErase,
ModifyHeader,
module='purchase', type_='wizard')
+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:
@@ -15,3 +15,33 @@ class PartyReplace:
('purchase.product_supplier', 'party'),
('purchase.purchase', 'party'),
]
class PartyErase:
__metaclass__ = PoolMeta
__name__ = 'party.erase'
@classmethod
def __setup__(cls):
super(PartyErase, cls).__setup__()
cls._error_messages.update({
'pending_purchase': (
'The party "%(party)s" can not be erased '
'because he has pending purchases '
'for the company "%(company)s".'),
})
def check_erase_company(self, party, company):
pool = Pool()
Purchase = pool.get('purchase.purchase')
super(PartyErase, self).check_erase_company(party, company)
purchases = Purchase.search([
('party', '=', party.id),
('state', 'not in', ['done', 'cancel']),
])
if purchases:
self.raise_user_error('pending_purchase', {
'party': party.rec_name,
'company': company.rec_name,
})