This repository was archived by the owner on Jan 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparty.py
More file actions
50 lines (40 loc) · 1.78 KB
/
party.py
File metadata and controls
50 lines (40 loc) · 1.78 KB
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
41
42
43
44
45
46
47
48
49
50
# 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.model import ModelSQL, ValueMixin, fields
from trytond.pool import Pool, PoolMeta
from trytond.tools.multivalue import migrate_property
dunning_procedure = fields.Many2One(
'account.dunning.procedure', "Dunning Procedure")
class Party(metaclass=PoolMeta):
__name__ = 'party.party'
dunning_procedure = fields.MultiValue(dunning_procedure)
dunning_procedures = fields.One2Many(
'party.party.dunning_procedure', 'party', "Dunning Procedures")
@classmethod
def default_dunning_procedure(cls, **pattern):
pool = Pool()
Configuration = pool.get('account.configuration')
config = Configuration(1)
dunning_procedure = config.get_multivalue(
'default_dunning_procedure', **pattern)
return dunning_procedure.id if dunning_procedure else None
class PartyDunningProcedure(ModelSQL, ValueMixin):
"Party Dunning Procedure"
__name__ = 'party.party.dunning_procedure'
party = fields.Many2One(
'party.party', "Party", ondelete='CASCADE')
dunning_procedure = dunning_procedure
@classmethod
def __register__(cls, module_name):
exist = backend.TableHandler.table_exist(cls._table)
super(PartyDunningProcedure, cls).__register__(module_name)
if not exist:
cls._migrate_property([], [], [])
@classmethod
def _migrate_property(cls, field_names, value_names, fields):
field_names.append('dunning_procedure')
value_names.append('dunning_procedure')
migrate_property(
'party.party', field_names, cls, value_names,
parent='party', fields=fields)