Add check_erase_company to PartyErase

This allows to check party's properties depending on the company for each
company.

issue7169
review41141002
This commit is contained in:
Cédric Krier committed 2018-03-24 00:03:18 +01:00
1 parent 4fde95b441
commit 03e460297a
2 files changed
+32 -8

No files matched your search

+7 -6
View File
@@ -4,7 +4,7 @@
from trytond.pool import Pool
from .company import *
from .cron import *
from .party import *
from . import party
def register():
@@ -19,15 +19,16 @@ def register():
CompanyConfigStart,
Cron,
CronCompany,
Configuration,
PartyConfigurationLang,
Party,
PartyLang,
party.Configuration,
party.PartyConfigurationLang,
party.Party,
party.PartyLang,
Rule,
module='company', type_='model')
Pool.register(
CompanyConfig,
PartyReplace,
party.PartyReplace,
party.PartyErase,
module='company', type_='wizard')
Pool.register(
LetterReport,
+25 -2
View File
@@ -1,13 +1,14 @@
# 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 import backend
from trytond.pool import PoolMeta
from trytond.pool import PoolMeta, Pool
from trytond.tools.multivalue import migrate_property
from trytond.transaction import Transaction
from .model import CompanyMultiValueMixin, CompanyValueMixin
__all__ = ['Configuration', 'PartyConfigurationLang', 'Party', 'PartyLang',
'PartyReplace']
'PartyReplace', 'PartyErase']
class Configuration(CompanyMultiValueMixin):
@@ -76,3 +77,25 @@ class PartyReplace:
('company.company', 'party'),
('company.employee', 'party'),
]
class PartyErase:
__metaclass__ = PoolMeta
__name__ = 'party.erase'
def check_erase(self, party):
pool = Pool()
Party = pool.get('party.party')
Company = pool.get('company.company')
super(PartyErase, self).check_erase(party)
with Transaction().set_user(0):
companies = Company.search([])
for company in companies:
with Transaction().set_context(company=company.id):
party = Party(party.id)
self.check_erase_company(party, company)
def check_erase_company(self, party, company):
pass