File: configuration.py

package info (click to toggle)
tryton-modules-sale-invoice-grouping 7.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 380 kB
  • sloc: python: 310; xml: 35; makefile: 11; sh: 3
file content (38 lines) | stat: -rw-r--r-- 1,378 bytes parent folder | download | duplicates (2)
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
# 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 fields
from trytond.pool import Pool, PoolMeta

sale_invoice_grouping_method = fields.Selection(
    'get_sale_invoice_grouping_methods', "Sale Invoice Grouping Method",
    help="The default invoice grouping method for new customers.")


@classmethod
def get_sale_invoice_grouping_methods(cls):
    pool = Pool()
    Party = pool.get('party.party')
    field_name = 'sale_invoice_grouping_method'
    return Party.fields_get([field_name])[field_name]['selection']


class Configuration(metaclass=PoolMeta):
    __name__ = 'sale.configuration'

    sale_invoice_grouping_method = fields.MultiValue(
        sale_invoice_grouping_method)
    get_sale_invoice_grouping_methods = get_sale_invoice_grouping_methods

    @classmethod
    def multivalue_model(cls, field):
        pool = Pool()
        if field == 'sale_invoice_grouping_method':
            return pool.get('sale.configuration.sale_method')
        return super(Configuration, cls).multivalue_model(field)


class ConfigurationSaleMethod(metaclass=PoolMeta):
    __name__ = 'sale.configuration.sale_method'

    sale_invoice_grouping_method = sale_invoice_grouping_method
    get_sale_invoice_grouping_methods = get_sale_invoice_grouping_methods