How to use the trytond.model.fields.Selection 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 / ui / view.py View on Github external
logger = logging.getLogger(__name__)


class XMLError(ValidationError):
    pass


class View(ModelSQL, ModelView):
    "View"
    __name__ = 'ir.ui.view'
    _rec_name = 'model'
    model = fields.Char('Model', select=True, states={
            'required': Eval('type') != 'board',
            })
    priority = fields.Integer('Priority', required=True, select=True)
    type = fields.Selection([
            (None, ''),
            ('tree', 'Tree'),
            ('form', 'Form'),
            ('graph', 'Graph'),
            ('calendar', 'Calendar'),
            ('board', 'Board'),
            ('list-form', "List Form"),
            ], 'View Type', select=True,
        domain=[
            If(Bool(Eval('inherit')),
                ('type', '=', None),
                ('type', '!=', None)),
            ],
        depends=['inherit'])
    type_string = type.translated('type')
    data = fields.Text('Data')
github tryton-ar / account_invoice_ar / journal.py View on Github external
STATES={'required': Bool(Eval('pyafipws_electronic_invoice_service'))}

class Journal(ModelSQL, ModelView):
    'Journal'
    __name__ = 'account.journal'

    pyafipws_electronic_invoice_service = fields.Selection([
            ('' , ''),
            ('wsfe',   u'Mercado interno -sin detalle- RG2485 (WSFEv1)'),
#            ('wsmtxca',u'Mercado interno -con detalle- RG2904 (WSMTXCA)'),
            ('wsbfe',  u'Bono Fiscal -con detalle- RG2557 (WSMTXCA)'),
            ('wsfex',  u'Exportación -con detalle- RG2758 (WSFEXv1)'),
        ], u'AFIP Web Service',
        help= u"Habilita la facturación electrónica por webservices AFIP")

    pyafipws_invoice_type = fields.Selection([
            ('' , ''),
            ( '1',u'01-Factura A'),
            ( '2',u'02-Nota de Débito A'),
            ( '3',u'03-Nota de Crédito A'),
            ( '4',u'04-Recibos A'),
            ( '5',u'05-Nota de Venta al Contado A'),
            ( '6',u'06-Factura B'),
            ( '7',u'07-Nota de Débito B'),
            ( '8',u'08-Nota de Crédito B'),
            ( '9',u'09-Recibos B'),
            ('10',u'10-Notas de Venta al Contado B'),
            ('11',u'11-Factura C'),
            ('12',u'12-Nota de Débito C'),
            ('13',u'13-Nota de Crédito C'),
            ('15',u'Recibo C'),
            ('19',u'19-Factura E'),
github tryton-ar / account_invoice_ar / company.py View on Github external
from trytond.exceptions import UserError
from trytond.i18n import gettext

logger = logging.getLogger(__name__)

__all__ = ['Company']


class Company(metaclass=PoolMeta):
    __name__ = 'company.company'

    pyafipws_certificate = fields.Text('Certificado AFIP WS',
        help='Certificado (.crt) de la empresa para webservices AFIP')
    pyafipws_private_key = fields.Text('Clave Privada AFIP WS',
        help='Clave Privada (.key) de la empresa para webservices AFIP')
    pyafipws_mode_cert = fields.Selection([
        ('', 'n/a'),
        ('homologacion', 'Homologación'),
        ('produccion', 'Producción'),
        ], 'Modo de certificacion',
        help=('El objetivo de Homologación (testing), es facilitar las '
            'pruebas. Los certificados de Homologación y Producción son '
            'distintos.'))

    @staticmethod
    def default_pyafipws_mode_cert():
        return ''

    @classmethod
    def validate(cls, companies):
        super(Company, cls).validate(companies)
        for company in companies:
github tryton / trytond / trytond / res / request.py View on Github external
_READONLY = If(Eval('state').in_(['waiting', 'closed']),
    True,
    If(Eval('state') == 'chatting',
        Eval('act_from') != Eval('_user'),
        False))
_DEPENDS = ['state', 'act_from']


class Request(ModelSQL, ModelView):
    "Request"
    __name__ = 'res.request'
    name = fields.Char('Subject', states={
            'readonly': _READONLY,
            }, required=True, depends=_DEPENDS)
    active = fields.Boolean('Active')
    priority = fields.Selection(_PRIORITIES, 'Priority', states={
            'readonly': _READONLY,
            }, required=True, order_field='priority', depends=_DEPENDS)
    act_from = fields.Many2One('res.user', 'From', required=True,
       readonly=True)
    act_to = fields.Many2One('res.user', 'To', required=True,
            domain=[('active', '=', True)],
            states={
                '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)
github tryton-ar / account_invoice_ar / pos.py View on Github external
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([
        ('', ''),
        ('wsfe', 'Mercado interno -sin detalle- RG2485 (WSFEv1)'),
        #('wsmtxca', 'Mercado interno -con detalle- RG2904 (WSMTXCA)'),
        ('wsbfe', 'Bono Fiscal -con detalle- RG2557 (WSMTXCA)'),
        ('wsfex', 'Exportación -con detalle- RG2758 (WSFEXv1)'),
        ], 'AFIP Web Service', depends=['pos_type', 'active'], states={
            'invisible': Eval('pos_type') != 'electronic',
            'required': Eval('pos_type') == 'electronic',
            'readonly': ~Eval('active', True),
            },
        help='Habilita la facturación electrónica por webservices AFIP')
    active = fields.Boolean('Active', select=True)

    @classmethod
    def __register__(cls, module_name):
        cursor = Transaction().connection.cursor()
github openlabs / nereid-project / project.py View on Github external
class ProjectHistory(ModelSQL, ModelView):
    'Project Work History'
    __name__ = 'project.work.history'

    date = fields.DateTime('Change Date')  # date is python built
    create_uid = fields.Many2One('res.user', 'Create User')

    #: The reverse many to one for history field to work
    project = fields.Many2One('project.work', 'Project Work')

    # Nereid user who made this update
    updated_by = fields.Many2One('nereid.user', 'Updated By')
    # States
    previous_state = fields.Selection([
        ('opened', 'Opened'),
        ('done', 'Done'),
    ], 'Prev. State', select=True
    )
    new_state = fields.Selection([
        ('opened', 'Opened'),
        ('done', 'Done'),
    ], 'New State', select=True
    )
    previous_progress_state = fields.Selection(
        PROGRESS_STATES, 'Prev. Progress State', select=True
    )
    new_progress_state = fields.Selection(
        PROGRESS_STATES, 'New Progress State', select=True
    )
github openlabs / nereid-project / project.py View on Github external
project = fields.Many2One('project.work', 'Project Work')

    # Nereid user who made this update
    updated_by = fields.Many2One('nereid.user', 'Updated By')
    # States
    previous_state = fields.Selection([
        ('opened', 'Opened'),
        ('done', 'Done'),
    ], 'Prev. State', select=True
    )
    new_state = fields.Selection([
        ('opened', 'Opened'),
        ('done', 'Done'),
    ], 'New State', select=True
    )
    previous_progress_state = fields.Selection(
        PROGRESS_STATES, 'Prev. Progress State', select=True
    )
    new_progress_state = fields.Selection(
        PROGRESS_STATES, 'New Progress State', select=True
    )

    # Comment
    comment = fields.Text('Comment')

    # Name
    previous_name = fields.Char('Prev. Name')
    new_name = fields.Char('New Name')

    # Assigned to
    previous_assigned_to = fields.Many2One('nereid.user', 'Prev. Assignee')
    new_assigned_to = fields.Many2One('nereid.user', 'New Assignee')
github tryton-ar / account_invoice_ar / pos.py View on Github external
def get_rec_name(self, name):
        if self.pos_type and self.number:
            return '[%s] %s' % (str(self.number), self.pos_type_string)

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


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

    pos = fields.Many2One('account.pos', 'Point of Sale',
        ondelete='CASCADE', select=True, required=True)
    invoice_type = fields.Selection(INVOICE_TYPE_POS,
        'Tipo Comprobante AFIP', select=True, required=True,
        help='Tipo de Comprobante AFIP')
    invoice_type_string = invoice_type.translated('invoice_type')
    invoice_sequence = fields.Many2One('ir.sequence',
        'Sequence',
        domain=[
            ('code', '=', 'account.invoice'),
            ['OR',
                ('company', '=', Eval('context', {}).get('company', -1)),
                ('company', '=', None),
                ],
            ])

    @classmethod
    def __register__(cls, module_name):
        cursor = Transaction().connection.cursor()
github tryton / trytond / trytond / ir / action.py View on Github external
report_content_html = fields.Function(fields.Binary(
            "Content HTML",
            states={
                'invisible': ~Eval('template_extension').in_(
                    ['html', 'xhtml']),
                },
            depends=['template_extension']),
        'get_report_content_html', setter='set_report_content_html')
    action = fields.Many2One('ir.action', 'Action', required=True,
            ondelete='CASCADE')
    direct_print = fields.Boolean('Direct Print')
    single = fields.Boolean("Single",
        help="Check if the template works only for one record.")
    translatable = fields.Boolean("Translatable",
        help="Uncheck to disable translations for this report.")
    template_extension = fields.Selection([
            ('odt', 'OpenDocument Text'),
            ('odp', 'OpenDocument Presentation'),
            ('ods', 'OpenDocument Spreadsheet'),
            ('odg', 'OpenDocument Graphics'),
            ('txt', 'Plain Text'),
            ('xml', 'XML'),
            ('html', 'HTML'),
            ('xhtml', 'XHTML'),
            ], string='Template Extension', required=True,
        translate=False)
    extension = fields.Selection([
            ('', ''),
            ('bib', 'BibTex'),
            ('bmp', 'Windows Bitmap'),
            ('csv', 'Text CSV'),
            ('dbf', 'dBase'),