forked from tryton/sale_supply_drop_shipment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
party.py
40 lines (32 loc) · 1.31 KB
/
party.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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, Pool
__all__ = ['PartyReplace', 'PartyErase']
class PartyReplace(metaclass=PoolMeta):
__name__ = 'party.replace'
@classmethod
def fields_to_replace(cls):
return super(PartyReplace, cls).fields_to_replace() + [
('purchase.request', 'customer'),
('purchase.purchase', 'customer'),
('stock.shipment.drop', 'supplier'),
('stock.shipment.drop', 'customer'),
]
class PartyErase(metaclass=PoolMeta):
__name__ = 'party.erase'
def check_erase_company(self, party, company):
pool = Pool()
ShipmentDrop = pool.get('stock.shipment.drop')
super(PartyErase, self).check_erase_company(party, company)
shipments = ShipmentDrop.search([
['OR',
('supplier', '=', party.id),
('customer', '=', party.id),
],
('state', 'not in', ['done', 'cancel']),
])
if shipments:
self.raise_user_error('pending_shipment', {
'party': party.rec_name,
'company': company.rec_name,
})