File: party.py

package info (click to toggle)
tryton-modules-account-dunning 7.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 564 kB
  • sloc: python: 592; xml: 427; makefile: 11; sh: 3
file content (31 lines) | stat: -rw-r--r-- 1,176 bytes parent folder | download
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
# 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.model import ModelSQL, ValueMixin, fields
from trytond.pool import Pool, PoolMeta

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