How to use the trytond.model.ModelView 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 / project.py View on Github external
html_template='project/emails/html_content.jinja',
            history=self,
            last_history=last_history
        )

        #message.add_header('reply-to', request.nereid_user.email)

        # Send mail.
        server = get_smtp_server()
        server.sendmail(
            CONFIG['smtp_from'], receivers, message.as_string()
        )
        server.quit()


class ProjectWorkCommit(ModelSQL, ModelView):
    "Repository commits"
    __name__ = 'project.work.commit'
    _rec_name = 'commit_message'

    commit_timestamp = fields.DateTime('Commit Timestamp')
    project = fields.Many2One(
        'project.work', 'Project', required=True, select=True
    )
    nereid_user = fields.Many2One(
        'nereid.user', 'User', required=True, select=True
    )
    repository = fields.Char('Repository Name', required=True, select=True)
    repository_url = fields.Char('Repository URL', required=True)
    commit_message = fields.Char('Commit Message', required=True)
    commit_url = fields.Char('Commit URL', required=True)
    commit_id = fields.Char('Commit Id', required=True)
github tryton / trytond / trytond / ir / resource.py View on Github external
# 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 sql.conditionals import Coalesce

from trytond.i18n import lazy_gettext
from trytond.model import ModelStorage, ModelView, fields
from trytond.pool import Pool
from trytond.pyson import Eval
from trytond.transaction import Transaction

__all__ = ['ResourceMixin', 'resource_copy']


class ResourceMixin(ModelStorage, ModelView):

    resource = fields.Reference('Resource', selection='get_models',
        required=True, select=True)
    copy_to_resources = fields.MultiSelection(
        'get_copy_to_resources', "Copy to Resources",
        states={
            'invisible': ~Eval('copy_to_resources_visible'),
            },
        depends=['copy_to_resources_visible'])
    copy_to_resources_visible = fields.Function(
        fields.Boolean("Copy to Resources Visible"),
        'on_change_with_copy_to_resources_visible')
    last_user = fields.Function(fields.Char('Last User',
            states={
                'invisible': ~Eval('last_user'),
                }),
github tryton / trytond / trytond / webdav / webdav.py View on Github external
def get_login(cls, key, command, path):
        """Validate the key for the command and path
        Return the user id if succeed or None
        """
        shares = cls.search([
                ('key', '=', key),
                ])
        if not shares:
            return None
        for share in shares:
            if cls.match(share, command, path):
                return share.user.id
        return None


class Attachment(ModelSQL, ModelView):
    __name__ = 'ir.attachment'

    path = fields.Function(fields.Char('Path'), 'get_path')
    url = fields.Function(fields.Char('URL'), 'get_url')
    shares = fields.Function(fields.One2Many('webdav.share', None, 'Shares',
            domain=[
                ('path', '=', Eval('path')),
                ],
            depends=['path']), 'get_shares', 'set_shares')

    @classmethod
    def __setup__(cls):
        super(Attachment, cls).__setup__()
        cls._error_messages.update({
                'collection_attachment_name': ('You can not create an '
                    'attachment named "%(attachment)s" in collection '
github tryton / trytond / trytond / ir / export.py View on Github external
def delete(cls, records):
        ModelView._view_toolbar_get_cache.clear()
        super().delete(records)
github tryton / trytond / trytond / ir / trigger.py View on Github external
from trytond.i18n import gettext
from trytond.model import (
    ModelView, ModelSQL, DeactivableMixin, fields, EvalEnvironment, Check)
from trytond.model.exceptions import ValidationError
from trytond.pool import Pool
from trytond.pyson import Eval, PYSONDecoder
from trytond.tools import grouped_slice
from trytond.tools import reduce_ids
from trytond.transaction import Transaction


class ConditionError(ValidationError):
    pass


class Trigger(DeactivableMixin, ModelSQL, ModelView):
    "Trigger"
    __name__ = 'ir.trigger'
    name = fields.Char('Name', required=True, translate=True)
    model = fields.Many2One('ir.model', 'Model', required=True, select=True)
    on_time = fields.Boolean('On Time', select=True, states={
            'invisible': (Eval('on_create', False)
                | Eval('on_write', False)
                | Eval('on_delete', False)),
            }, depends=['on_create', 'on_write', 'on_delete'])
    on_create = fields.Boolean('On Create', select=True, states={
        'invisible': Eval('on_time', False),
        }, depends=['on_time'])
    on_write = fields.Boolean('On Write', select=True, states={
        'invisible': Eval('on_time', False),
        }, depends=['on_time'])
    on_delete = fields.Boolean('On Delete', select=True, states={
github tryton / trytond / trytond / ir / module.py View on Github external
depends = []
        # Restart Browse Cache for deleted dependencies
        module = cls(module.id)
        dependency_names = [x.name for x in module.dependencies]
        to_create = []
        for depend in depends:
            if depend not in dependency_names:
                to_create.append({
                        'module': module.id,
                        'name': depend,
                        })
        if to_create:
            Dependency.create(to_create)


class ModuleDependency(ModelSQL, ModelView):
    "Module dependency"
    __name__ = "ir.module.dependency"
    name = fields.Char('Name')
    module = fields.Many2One('ir.module', 'Module', select=True,
       ondelete='CASCADE', required=True)
    state = fields.Function(fields.Selection([
                ('not activated', 'Not Activated'),
                ('activated', 'Activated'),
                ('to upgrade', 'To be upgraded'),
                ('to remove', 'To be removed'),
                ('to activate', 'To be activated'),
                ('unknown', 'Unknown'),
                ], 'State', readonly=True), 'get_state')

    @classmethod
    def __setup__(cls):
github tryton / trytond / trytond / ir / model.py View on Github external
pool = Pool()
        ModelButton = pool.get('ir.model.button')
        super(ModelButtonRule, cls).write(buttons, values, *args)
        # Restart the cache for get_rules
        ModelButton._rules_cache.clear()

    @classmethod
    def delete(cls, buttons):
        pool = Pool()
        ModelButton = pool.get('ir.model.button')
        super(ModelButtonRule, cls).delete(buttons)
        # Restart the cache for get_rules
        ModelButton._rules_cache.clear()


class ModelButtonClick(DeactivableMixin, ModelSQL, ModelView):
    "Model Button Click"
    __name__ = 'ir.model.button.click'
    button = fields.Many2One(
        'ir.model.button', "Button", required=True, ondelete='CASCADE')
    record_id = fields.Integer("Record ID", required=True)

    @classmethod
    def __setup__(cls):
        super(ModelButtonClick, cls).__setup__()
        cls.__rpc__.update({
                'get_click': RPC(),
                })

    @classmethod
    def register(cls, model, name, records):
        pool = Pool()
github tryton / trytond / trytond / ir / export.py View on Github external
def create(cls, vlist):
        ModelView._view_toolbar_get_cache.clear()
        return super().create(vlist)
github openlabs / nereid-project / project.py View on Github external
class ProjectWorkInvitation(ModelSQL):
    "Project Work Invitation"
    __name__ = 'project.work-project.invitation'

    invitation = fields.Many2One(
        'project.work.invitation', 'Invitation',
        ondelete='CASCADE', select=1, required=True
    )
    project = fields.Many2One(
        'project.work.invitation', 'Project',
        ondelete='CASCADE', select=1, required=True
    )


class TimesheetEmployeeDay(ModelView):
    'Gantt dat view generator'
    __name__ = 'timesheet_by_employee_by_day'

    employee = fields.Many2One('company.employee', 'Employee')
    date = fields.Date('Date')
    hours = fields.Float('Hours', digits=(16, 2))

    @classmethod
    def __register__(cls, module_name):
        """
        Init Method

        :param module_name: Name of the module
        """
        super(TimesheetEmployeeDay, cls).__register__(module_name)
github openlabs / nereid-project / iteration.py View on Github external
start_date = DateField('Start Date', [validators.DataRequired()])
    end_date = DateField('End Date', [validators.DataRequired()])


class IterationAddTaskForm(Form):
    "Iteratino Update Form"
    task_id = IntegerField('Task Id', [validators.DataRequired()])
    action = SelectField(
        'Action to perform', validators=[validators.DataRequired()], choices=[
            ('add', 'Add'),
            ('remove', 'Remove'),
        ]
    )


class Iteration(ModelSQL, ModelView):
    'Iteration'
    __name__ = 'project.iteration'

    name = fields.Char(
        'Name', required=True, states=READONLY_IF_CLOSED,
        depends=['state'],
    )
    company = fields.Many2One(
        'company.company', 'Company', select=True, required=True,
        states=READONLY_IF_CLOSED, depends=['state'],
    )
    start_date = fields.Date(
        'Start Date', required=True, select=True,
        states=READONLY_IF_CLOSED, depends=['state'],
    )
    end_date = fields.Date(