Commit 7832ca19 authored by Luca Cristaldi's avatar Luca Cristaldi
Browse files

first implementation draft

parent 39cdaf59
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
from trytond.pool import Pool
from . import subscription

__all__ = ['register']


def register():
    Pool.register(
        subscription.Subscription,
        module='subscription_include', type_='model')
    Pool.register(
        module='subscription_include', type_='wizard')

subscription.py

0 → 100644
+18 −0
Original line number Diff line number Diff line
from trytond.model import ModelView, fields
from trytond.pool import PoolMeta
from trytond.pyson import Eval

__all__ = ['Subscription']

class Subscription(metaclass=PoolMeta):
    "Subscription"
    __name__ = 'sale.subscription'

    include = fields.Boolean("Include", states={'readonly': Eval('state') != 'draft'})

    def compute_next_invoice_date(self):
        date = super(Subscription, self).compute_next_invoice_date()
        if(self.include and not self.next_invoice_date):
            return self.invoice_start_date or self.start_date
        else:
            return date
 No newline at end of file

subscription.xml

0 → 100644
+10 −0
Original line number Diff line number Diff line
<?xml version="1.0"?>
<tryton>
    <data>
        <record model="ir.ui.view" id="subscription_view_form">
            <field name="model">sale.subscription</field>
            <field name="inherit" ref="sale_subscription.subscription_view_form"/>
            <field name="name">subscription_form</field>
        </record>
    </data>
</tryton>
 No newline at end of file
+10 −1
Original line number Diff line number Diff line
[tryton]
version=4.8
version=4.8.0
depends:
    account
    account_invoice
    company
    currency
    ir
    product
    res
    sale
    sale_subscription
xml:
    subscription.xml
+7 −0
Original line number Diff line number Diff line
<?xml version="1.0"?>
<data>
    <xpath expr="/form/notebook/page[@id='subscription']/field[@name='start_date']" position="after">
        <label name="include"/>
        <field name="include" xexpand="0" width="25"/>
    </xpath>
</data>
 No newline at end of file