File: service.py

package info (click to toggle)
tryton-modules-sale-subscription 7.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 916 kB
  • sloc: python: 1,502; xml: 752; makefile: 11; sh: 3
file content (28 lines) | stat: -rw-r--r-- 1,014 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
# 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 DeactivableMixin, ModelSQL, ModelView, fields
from trytond.pyson import Eval


class Service(DeactivableMixin, ModelSQL, ModelView):
    "Subscription Service"
    __name__ = 'sale.subscription.service'

    product = fields.Many2One(
        'product.product', "Product", required=True, ondelete='CASCADE',
        domain=[
            ('type', '=', 'service'),
            ])
    consumption_recurrence = fields.Many2One(
        'sale.subscription.recurrence.rule.set', "Consumption Recurrence")
    consumption_delay = fields.TimeDelta("Consumption Delay",
        states={
            'invisible': ~Eval('consumption_recurrence'),
            })

    def get_rec_name(self, name):
        return self.product.rec_name

    @classmethod
    def search_rec_name(cls, name, clause):
        return [('product.rec_name',) + tuple(clause[1:])]