How to use the trytond.model.fields.Integer function in trytond

To help you get started, we’ve selected a few trytond examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openlabs / nereid-project / iteration.py View on Github external
],
        add_remove=[
            ('type', '!=', 'project'),
            ('state', '=', 'opened'),
            ('company', '=', Eval('company')),
        ],
        states=READONLY_IF_CLOSED, depends=['company', 'state'],
    )
    backlog_tasks = fields.One2Many(
        'project.iteration.backlog', 'iteration', 'Backlog Tasks',
        readonly=True
    )
    url = fields.Function(fields.Char('URL'), 'get_url')

    # Function fields to return status
    count_tasks = fields.Function(fields.Integer("Total Tasks"), 'get_count')
    count_backlog = fields.Function(
        fields.Integer("Tasks in Backlog"), 'get_count'
    )
    count_planning = fields.Function(
        fields.Integer("Tasks in Planning"), 'get_count'
    )
    count_in_progress = fields.Function(
        fields.Integer("Tasks in Progress"), 'get_count'
    )
    count_review = fields.Function(
        fields.Integer("Tasks in Review"), 'get_count'
    )
    count_done = fields.Function(
        fields.Integer("Done Tasks"), 'get_count'
    )
github tryton / trytond / trytond / model / order.py View on Github external
def sequence_ordered(
        field_name='sequence',
        field_label=lazy_gettext('ir.msg_sequence'),
        order='ASC NULLS FIRST'):
    "Returns a mixin to order the model by order fields"

    class SequenceOrderedMixin(object):
        "Mixin to order model by a sequence field"
        __slots__ = ()

        @classmethod
        def __setup__(cls):
            super(SequenceOrderedMixin, cls).__setup__()
            cls._order = [(field_name, order)] + cls._order

    setattr(SequenceOrderedMixin, field_name, fields.Integer(field_label))
    return SequenceOrderedMixin
github tryton / trytond / trytond / ir / cron.py View on Github external
from trytond import backend
from trytond.config import config
from trytond.model import (
    ModelView, ModelSQL, DeactivableMixin, fields, dualmethod)
from trytond.pool import Pool
from trytond.pyson import Eval
from trytond.transaction import Transaction
from trytond.worker import run_task

logger = logging.getLogger(__name__)


class Cron(DeactivableMixin, ModelSQL, ModelView):
    "Cron"
    __name__ = "ir.cron"
    interval_number = fields.Integer('Interval Number', required=True)
    interval_type = fields.Selection([
            ('minutes', 'Minutes'),
            ('hours', 'Hours'),
            ('days', 'Days'),
            ('weeks', 'Weeks'),
            ('months', 'Months'),
            ], "Interval Type", sort=False, required=True)
    minute = fields.Integer("Minute",
        states={
            'invisible': Eval('interval_type').in_(['minutes']),
            },
        depends=['interval_type'])
    hour = fields.Integer("Hour",
        states={
            'invisible': Eval('interval_type').in_(['minutes', 'hours']),
            },
github tryton / trytond / trytond / model / model.py View on Github external
    @property
    def __queue__(self):
        pool = Pool()
        Queue = pool.get('ir.queue')
        return Queue.caller(self)


@total_ordering
class Model(URLMixin, PoolBase, metaclass=ModelMeta):
    """
    Define a model in Tryton.
    """
    __slots__ = ('_id', '_values', '_init_values', '_removed', '_deleted')
    _rec_name = 'name'

    id = fields.Integer(lazy_gettext('ir.msg_ID'), readonly=True)

    @classmethod
    def __setup__(cls):
        super(Model, cls).__setup__()
        cls.__rpc__ = {
            'default_get': RPC(cache=dict(seconds=5 * 60)),
            'fields_get': RPC(cache=dict(days=1)),
            'pre_validate': RPC(instantiate=0),
            }

        # Copy fields and update depends
        for attr in dir(cls):
            if attr.startswith('_'):
                continue
            if not isinstance(getattr(cls, attr), fields.Field):
                continue
github tryton-ar / account_invoice_ar / pos.py View on Github external
('206', '206-Factura de Crédito Electrónica MiPyMEs B'),
    ('207', '207-Nota de Débito Electrónica MiPyMEs B'),
    ('208', '208-Nota de Crédito Electrónica MiPyMEs B'),
    ('211', '211-Factura de Crédito Electrónica MiPyMEs C'),
    ('212', '212-Nota de Débito Electrónica MiPyMEs C'),
    ('213', '213-Nota de Crédito Electrónica MiPyMEs C'),
    ]


class Pos(ModelSQL, ModelView):
    'Point of Sale'
    __name__ = 'account.pos'

    company = fields.Many2One('company.company', 'Company', required=True,
        states=STATES, depends=DEPENDS)
    number = fields.Integer('Punto de Venta AFIP', required=True,
        states=STATES, depends=DEPENDS,
        help='Prefijo de emisión habilitado en AFIP')
    pos_sequences = fields.One2Many('account.pos.sequence', 'pos',
        'Point of Sale', context={'company': Eval('company', -1)},
        depends=['company', 'active'], states=STATES)
    pos_type = fields.Selection([
        ('manual', 'Manual'),
        ('electronic', 'Electronic'),
        ('fiscal_printer', 'Fiscal Printer'),
        ], 'Pos Type', required=True, states=STATES, depends=DEPENDS)
    pos_type_string = pos_type.translated('pos_type')
    pos_daily_report = fields.Boolean('Cierre diario (ZETA)', states={
            'invisible': Eval('pos_type') != 'fiscal_printer'
            },
        depends=['pos_type'])
    pyafipws_electronic_invoice_service = fields.Selection([
github openlabs / nereid-project / iteration.py View on Github external
('type', '!=', 'project'),
            ('state', '=', 'opened'),
            ('company', '=', Eval('company')),
        ],
        states=READONLY_IF_CLOSED, depends=['company', 'state'],
    )
    backlog_tasks = fields.One2Many(
        'project.iteration.backlog', 'iteration', 'Backlog Tasks',
        readonly=True
    )
    url = fields.Function(fields.Char('URL'), 'get_url')

    # Function fields to return status
    count_tasks = fields.Function(fields.Integer("Total Tasks"), 'get_count')
    count_backlog = fields.Function(
        fields.Integer("Tasks in Backlog"), 'get_count'
    )
    count_planning = fields.Function(
        fields.Integer("Tasks in Planning"), 'get_count'
    )
    count_in_progress = fields.Function(
        fields.Integer("Tasks in Progress"), 'get_count'
    )
    count_review = fields.Function(
        fields.Integer("Tasks in Review"), 'get_count'
    )
    count_done = fields.Function(
        fields.Integer("Done Tasks"), 'get_count'
    )

    def get_count(self, name):
        """Get task count based on task state.
github tryton / trytond / trytond / res / request.py View on Github external
'readonly': _READONLY,
            }, depends=_DEPENDS)
    body = fields.Text('Body', states={
            'readonly': _READONLY,
            }, depends=_DEPENDS)
    date_sent = fields.DateTime('Date', readonly=True)
    trigger_date = fields.DateTime('Trigger Date', states={
            'readonly': _READONLY,
            }, depends=_DEPENDS)
    references = fields.One2Many('res.request.reference', 'request',
        'References', states={
            'readonly': If(Eval('state') == 'closed',
                True,
                Eval('act_from', 0) != Eval('_user', 0)),
            }, depends=['state', 'act_from'])
    number_references = fields.Function(fields.Integer('Number of References',
        on_change_with=['references']), 'on_change_with_number_references')
    state = fields.Selection(_STATES, 'State', required=True, readonly=True)
    history = fields.One2Many('res.request.history', 'request',
           'History', readonly=True)

    @classmethod
    def __setup__(cls):
        super(Request, cls).__setup__()
        cls.__rpc__.update({
                'request_get': RPC(),
                })
        cls._order.insert(0, ('priority', 'DESC'))
        cls._order.insert(1, ('trigger_date', 'DESC'))
        cls._order.insert(2, ('create_date', 'DESC'))
        cls._buttons.update({
                'send': {
github openlabs / nereid-project / iteration.py View on Github external
# Function fields to return status
    count_tasks = fields.Function(fields.Integer("Total Tasks"), 'get_count')
    count_backlog = fields.Function(
        fields.Integer("Tasks in Backlog"), 'get_count'
    )
    count_planning = fields.Function(
        fields.Integer("Tasks in Planning"), 'get_count'
    )
    count_in_progress = fields.Function(
        fields.Integer("Tasks in Progress"), 'get_count'
    )
    count_review = fields.Function(
        fields.Integer("Tasks in Review"), 'get_count'
    )
    count_done = fields.Function(
        fields.Integer("Done Tasks"), 'get_count'
    )

    def get_count(self, name):
        """Get task count based on task state.
        """
        def _get_count(state):
            return len(
                filter(lambda task: task.progress_state == state, self.tasks)
            )

        if name == 'count_backlog':
            return _get_count('Backlog')
        elif name == 'count_planning':
            return _get_count('Planning')
        elif name == 'count_in_progress':
            return _get_count('In Progress')
github tryton / trytond / trytond / ir / cron.py View on Github external
"Cron"
    __name__ = "ir.cron"
    interval_number = fields.Integer('Interval Number', required=True)
    interval_type = fields.Selection([
            ('minutes', 'Minutes'),
            ('hours', 'Hours'),
            ('days', 'Days'),
            ('weeks', 'Weeks'),
            ('months', 'Months'),
            ], "Interval Type", sort=False, required=True)
    minute = fields.Integer("Minute",
        states={
            'invisible': Eval('interval_type').in_(['minutes']),
            },
        depends=['interval_type'])
    hour = fields.Integer("Hour",
        states={
            'invisible': Eval('interval_type').in_(['minutes', 'hours']),
            },
        depends=['interval_type'])
    weekday = fields.Many2One(
        'ir.calendar.day', "Day of Week",
        states={
            'invisible': Eval('interval_type').in_(
                ['minutes', 'hours', 'days']),
            },
        depends=['interval_type'])
    day = fields.Integer("Day",
        states={
            'invisible': Eval('interval_type').in_(
                ['minutes', 'hours', 'days', 'weeks']),
            },
github openlabs / nereid-project / iteration.py View on Github external
backlog_tasks = fields.One2Many(
        'project.iteration.backlog', 'iteration', 'Backlog Tasks',
        readonly=True
    )
    url = fields.Function(fields.Char('URL'), 'get_url')

    # Function fields to return status
    count_tasks = fields.Function(fields.Integer("Total Tasks"), 'get_count')
    count_backlog = fields.Function(
        fields.Integer("Tasks in Backlog"), 'get_count'
    )
    count_planning = fields.Function(
        fields.Integer("Tasks in Planning"), 'get_count'
    )
    count_in_progress = fields.Function(
        fields.Integer("Tasks in Progress"), 'get_count'
    )
    count_review = fields.Function(
        fields.Integer("Tasks in Review"), 'get_count'
    )
    count_done = fields.Function(
        fields.Integer("Done Tasks"), 'get_count'
    )

    def get_count(self, name):
        """Get task count based on task state.
        """
        def _get_count(state):
            return len(
                filter(lambda task: task.progress_state == state, self.tasks)
            )