Files
tryton/modules/project/party.py
T

37 lines
1.1 KiB
Python
Raw Normal View History

2016-10-11 18:16:47 +02:00
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
2018-12-29 14:20:29 +01:00
from trytond.i18n import gettext
2018-03-24 00:07:13 +01:00
from trytond.pool import PoolMeta, Pool
2016-10-11 18:16:47 +02:00
2018-12-29 14:20:29 +01:00
from trytond.modules.party.exceptions import EraseError
2016-10-11 18:16:47 +02:00
2020-03-01 12:33:53 +01:00
class Replace(metaclass=PoolMeta):
2016-10-11 18:16:47 +02:00
__name__ = 'party.replace'
@classmethod
def fields_to_replace(cls):
2020-03-01 12:33:53 +01:00
return super().fields_to_replace() + [
2016-10-11 18:16:47 +02:00
('project.work', 'party'),
]
2018-03-24 00:07:13 +01:00
2020-03-01 12:33:53 +01:00
class Erase(metaclass=PoolMeta):
2018-03-24 00:07:13 +01:00
__name__ = 'party.erase'
def check_erase_company(self, party, company):
pool = Pool()
Work = pool.get('project.work')
2020-03-01 12:33:53 +01:00
super().check_erase_company(party, company)
2018-03-24 00:07:13 +01:00
works = Work.search([
('party', '=', party.id),
2019-12-14 10:47:54 +01:00
('company', '=', company.id),
('progress', '!=', 1),
2018-03-24 00:07:13 +01:00
])
if works:
2018-12-29 14:20:29 +01:00
raise EraseError(
gettext('project.msg_erase_party_opened_project',
party=party.rec_name,
company=company.rec_name))