How to use the trytond.model.fields.Boolean 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 tryton / trytond / trytond / ir / model.py View on Github external
__name__ = 'ir.model.data'
    fs_id = fields.Char('Identifier on File System', required=True,
        help="The id of the record as known on the file system.",
        select=True)
    model = fields.Char('Model', required=True, select=True)
    module = fields.Char('Module', required=True, select=True)
    db_id = fields.Integer(
        "Resource ID", select=True,
        states={
            'required': ~Eval('noupdate', False),
            },
        help="The id of the record in the database.")
    values = fields.Text('Values')
    fs_values = fields.Text('Values on File System')
    noupdate = fields.Boolean('No Update')
    out_of_sync = fields.Function(fields.Boolean('Out of Sync'),
        'get_out_of_sync', searcher='search_out_of_sync')
    _get_id_cache = Cache('ir_model_data.get_id', context=False)
    _has_model_cache = Cache('ir_model_data.has_model', context=False)

    @classmethod
    def __setup__(cls):
        super(ModelData, cls).__setup__()
        table = cls.__table__()
        cls._sql_constraints = [
            ('fs_id_module_model_uniq',
                Unique(table, table.fs_id, table.module, table.model),
                'The triple (fs_id, module, model) must be unique!'),
        ]
        cls._buttons.update({
                'sync': {
                    'invisible': ~Eval('out_of_sync'),
github tryton / trytond / trytond / ir / resource.py View on Github external
__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'),
                }),
        'get_last_user')
    last_modification = fields.Function(fields.DateTime('Last Modification',
            states={
                'invisible': ~Eval('last_modification'),
                }),
        'get_last_modification')

    @classmethod
    def __setup__(cls):
        super(ResourceMixin, cls).__setup__()
        cls._order.insert(0, ('last_modification', 'DESC'))
github tryton / trytond / trytond / model / modelsql.py View on Github external
if field_name in cls._defaults:
                def default():
                    default_ = cls._clean_defaults({
                            field_name: cls._defaults[field_name](),
                            })[field_name]
                    return field.sql_format(default_)

            table.add_column(field_name, field._sql_type, default=default)
            if cls._history:
                history_table.add_column(field_name, field._sql_type)

            if isinstance(field, (fields.Integer, fields.Float)):
                # migration from tryton 2.2
                table.db_default(field_name, None)

            if isinstance(field, (fields.Boolean)):
                table.db_default(field_name, False)

            if isinstance(field, fields.Many2One):
                if field.model_name in ('res.user', 'res.group'):
                    # XXX need to merge ir and res
                    ref = field.model_name.replace('.', '_')
                else:
                    ref_model = pool.get(field.model_name)
                    if (issubclass(ref_model, ModelSQL)
                            and not callable(ref_model.table_query)):
                        ref = ref_model._table
                        # Create foreign key table if missing
                        if not backend.TableHandler.table_exist(ref):
                            backend.TableHandler(ref_model)
                    else:
                        ref = None
github tryton / trytond / trytond / workflow / workflow.py View on Github external
], 'Split Mode', required=True)
    join_mode = fields.Selection([
       ('XOR', 'Xor'),
       ('AND', 'And'),
       ], 'Join Mode', required=True)
    kind = fields.Selection([
       ('dummy', 'Dummy'),
       ('function', 'Function'),
       ('subflow', 'Subflow'),
       ('stopall', 'Stop All'),
       ], 'Kind', required=True)
    action = fields.Text('Action', states={
        'readonly': "kind == 'dummy'",
        'required': "kind == 'function'",
        })
    flow_start = fields.Boolean('Flow Start')
    flow_stop = fields.Boolean('Flow Stop')
    subflow =  fields.Many2One('workflow', 'Subflow', states={
        'readonly': "kind != 'subflow'",
        'required': "kind == 'subflow'",
        })
    signal_send = fields.Char('Signal (subflow.*)')
    out_transitions = fields.One2Many('workflow.transition', 'act_from',
       'Outgoing transitions')
    in_transitions = fields.One2Many('workflow.transition', 'act_to',
       'Incoming transitions')

    #TODO add a _constraint on subflow without action
    #to have the same model than the workflow

    def default_kind(self, cursor, user, context=None):
        return 'dummy'
github tryton-ar / account_invoice_ar / bank.py View on Github external
# 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.pyson import Eval, If, In
from trytond.pool import PoolMeta

__all__ = ['BankAccount']


class BankAccount(metaclass=PoolMeta):
    __name__ = 'bank.account'
    pyafipws_cbu = fields.Boolean('CBU del Emisor',
        states={
            'required': If(In(Eval('party_company'), Eval('owners', [])),
                True, False),
            },
        depends=['owners', 'party_company'])
github tryton / trytond / trytond / ir / model.py View on Github external
"Model data"
    __name__ = 'ir.model.data'
    fs_id = fields.Char('Identifier on File System', required=True,
        help="The id of the record as known on the file system.",
        select=True)
    model = fields.Char('Model', required=True, select=True)
    module = fields.Char('Module', required=True, select=True)
    db_id = fields.Integer(
        "Resource ID", select=True,
        states={
            'required': ~Eval('noupdate', False),
            },
        help="The id of the record in the database.")
    values = fields.Text('Values')
    fs_values = fields.Text('Values on File System')
    noupdate = fields.Boolean('No Update')
    out_of_sync = fields.Function(fields.Boolean('Out of Sync'),
        'get_out_of_sync', searcher='search_out_of_sync')
    _get_id_cache = Cache('ir_model_data.get_id', context=False)
    _has_model_cache = Cache('ir_model_data.has_model', context=False)

    @classmethod
    def __setup__(cls):
        super(ModelData, cls).__setup__()
        table = cls.__table__()
        cls._sql_constraints = [
            ('fs_id_module_model_uniq',
                Unique(table, table.fs_id, table.module, table.model),
                'The triple (fs_id, module, model) must be unique!'),
        ]
        cls._buttons.update({
                'sync': {
github tryton-ar / account_invoice_ar / party.py View on Github external
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from decimal import Decimal

from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, Or
from trytond.transaction import Transaction

__all__ = ['Party']


class Party(metaclass=PoolMeta):
    __name__ = 'party.party'

    pyafipws_fce = fields.Boolean('MiPyme FCE', states={
            'readonly': ~Eval('active', True),
            }, depends=['active'])
    pyafipws_fce_amount = fields.Numeric('MiPyme FCE Amount',
        digits=(16, Eval('pyafipws_fce_amount_digits', 2)),
        states={
            'readonly': Or(
                ~Eval('pyafipws_fce', False),
                ~Eval('active', True)),
            },
        depends=['active', 'pyafipws_fce_amount_digits', 'pyafipws_fce'])
    pyafipws_fce_amount_digits = fields.Function(fields.Integer(
            'Currency Digits'), 'get_pyafipws_fce_amount_digits')

    @staticmethod
    def default_pyafipws_fce_amount():
        return Decimal('0')
github tryton / trytond / trytond / ir / model.py View on Github external
for rec in res:
                for field in to_delete:
                    del rec[field]
        return res


class ModelAccess(DeactivableMixin, ModelSQL, ModelView):
    "Model access"
    __name__ = 'ir.model.access'
    model = fields.Many2One('ir.model', 'Model', required=True,
            ondelete="CASCADE")
    group = fields.Many2One('res.group', 'Group',
            ondelete="CASCADE")
    perm_read = fields.Boolean('Read Access')
    perm_write = fields.Boolean('Write Access')
    perm_create = fields.Boolean('Create Access')
    perm_delete = fields.Boolean('Delete Access')
    description = fields.Text('Description')
    _get_access_cache = Cache('ir_model_access.get_access', context=False)

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

    @staticmethod
    def check_xml_record(accesses, values):
        return True

    @staticmethod
github tryton / trytond / trytond / ir / translation.py View on Github external
key=lambda x: (x.msgctxt, x.msgid))


class Translation(ModelSQL, ModelView):
    "Translation"
    __name__ = "ir.translation"

    name = fields.Char('Field Name', required=True)
    res_id = fields.Integer('Resource ID', select=True, required=True)
    lang = fields.Selection('get_language', string='Language')
    type = fields.Selection(TRANSLATION_TYPE, string='Type',
       required=True)
    src = fields.Text('Source')
    value = fields.Text('Translation Value')
    module = fields.Char('Module', readonly=True)
    fuzzy = fields.Boolean('Fuzzy')
    model = fields.Function(fields.Char('Model'), 'get_model',
            searcher='search_model')
    overriding_module = fields.Char('Overriding Module', readonly=True)
    _translation_cache = Cache('ir.translation', size_limit=10240,
        context=False)
    _get_language_cache = Cache('ir.translation.get_language')

    @classmethod
    def __register__(cls, module_name):
        transaction = Transaction()
        cursor = transaction.connection.cursor()
        ir_translation = cls.__table__()
        table = cls.__table_handler__(module_name)

        # Migration from 5.0: remove src_md5
        if table.column_exist('src_md5'):
github tryton / trytond / trytond / ir / model.py View on Github external
for field in to_delete:
                    del rec[field]
        return res


class ModelAccess(DeactivableMixin, ModelSQL, ModelView):
    "Model access"
    __name__ = 'ir.model.access'
    model = fields.Many2One('ir.model', 'Model', required=True,
            ondelete="CASCADE")
    group = fields.Many2One('res.group', 'Group',
            ondelete="CASCADE")
    perm_read = fields.Boolean('Read Access')
    perm_write = fields.Boolean('Write Access')
    perm_create = fields.Boolean('Create Access')
    perm_delete = fields.Boolean('Delete Access')
    description = fields.Text('Description')
    _get_access_cache = Cache('ir_model_access.get_access', context=False)

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

    @staticmethod
    def check_xml_record(accesses, values):
        return True

    @staticmethod
    def default_perm_read():