How to use the trytond.model.fields.Function 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 / View on Github external
def __setup__(cls):
        super(ActionMixin, cls).__setup__()
        for name in dir(Action):
            field = getattr(Action, name)
            if (isinstance(field, fields.Field)
                    and not getattr(cls, name, None)):
                setattr(cls, name, fields.Function(field, 'get_action',
                        setter='set_action', searcher='search_action'))
                default_func = 'default_' + name
                if getattr(Action, default_func, None):
                    setattr(cls, default_func,
                        partial(ActionMixin._default_action, name))
github tryton / trytond / trytond / ir / View on Github external
('txt', 'Plain Text'),
            ('wmf', 'Windows Metafile'),
            ('xhtml', 'XHTML Document'),
            ('xls', 'Microsoft Excel 97/2000/XP'),
            ('xls5', 'Microsoft Excel 5.0'),
            ('xls95', 'Microsoft Excel 95'),
            ('xlsx', 'Microsoft Excel 2007/2010 XML'),
            ('xpm', 'X PixMap'),
            ], translate=False,
        string='Extension', help='Leave empty for the same as template, '
        'see LibreOffice documentation for compatible format.')
    module = fields.Char('Module', readonly=True, select=True)
    email = fields.Char('Email',
        help='Python dictonary where keys define "to" "cc" "subject"\n'
        "Example: {'to': '', 'cc': ''}")
    pyson_email = fields.Function(fields.Char('PySON Email'), 'get_pyson')

    def __register__(cls, module_name):
        super(ActionReport, cls).__register__(module_name)

        transaction = Transaction()
        cursor = transaction.connection.cursor()
        table = cls.__table_handler__(module_name)
        action_report = cls.__table__()

        # Migration from 3.4 remove report_name_module_uniq constraint

        # Migration from 4.4 replace plain extension by txt
github openlabs / trytond-amazon-mws / View on Github external
__metaclass__ = PoolMeta

class Template:
    "Product Template"
    __name__ = 'product.template'

    export_to_amazon = fields.Boolean('Amazon Exportable')

class Product:
    __name__ = "product.product"

    asin = fields.Function(fields.Many2One(
        'product.product.code', 'ASIN'
    ), 'get_codes')
    ean = fields.Function(fields.Many2One(
        'product.product.code', 'EAN'
    ), 'get_codes')
    upc = fields.Function(fields.Many2One(
        'product.product.code', 'UPC'
    ), 'get_codes')
    isbn = fields.Function(fields.Many2One(
        'product.product.code', 'ISBN'
    ), 'get_codes')
    gtin = fields.Function(fields.Many2One(
        'product.product.code', 'GTIN'
    ), 'get_codes')

github tryton / trytond / trytond / ir / ui / View on Github external
class UIMenu(DeactivableMixin, sequence_ordered(), tree(separator=' / '),
        ModelSQL, ModelView):
    "UI menu"
    __name__ = ''

    name = fields.Char('Menu', required=True, translate=True)
    childs = fields.One2Many('', 'parent', 'Children')
    parent = fields.Many2One('', 'Parent Menu', select=True,
    groups = fields.Many2Many('',
       'menu', 'group', 'Groups')
    complete_name = fields.Function(fields.Char('Complete Name'),
        'get_rec_name', searcher='search_rec_name')
    icon = fields.Selection('list_icons', 'Icon', translate=False)
    action = fields.Function(fields.Reference('Action',
                ('', ''),
                ('', ''),
                ('ir.action.act_window', 'ir.action.act_window'),
                ('ir.action.wizard', 'ir.action.wizard'),
                ('ir.action.url', 'ir.action.url'),
                ], translate=False), 'get_action', setter='set_action')
    action_keywords = fields.One2Many('ir.action.keyword', 'model',
        'Action Keywords')
    favorite = fields.Function(fields.Boolean('Favorite'), 'get_favorite')

    def order_complete_name(cls, tables):
        return'name', tables, cls)

github tryton / trytond / trytond / ir / View on Github external
type = fields.Selection([
        ('data', 'Data'),
        ('link', 'Link'),
        ], 'Type', required=True)
    description = fields.Text('Description')
    summary = fields.Function(fields.Char('Summary'), 'on_change_with_summary')
    link = fields.Char('Link', states={
            'invisible': Eval('type') != 'link',
            }, depends=['type'])
    data = fields.Binary('Data', filename='name',
        file_id=file_id, store_prefix=store_prefix,
            'invisible': Eval('type') != 'data',
            }, depends=['type'])
    file_id = fields.Char('File ID', readonly=True)
    data_size = fields.Function(fields.Integer('Data size', states={
                'invisible': Eval('type') != 'data',
                }, depends=['type']), 'get_size')

    def __setup__(cls):
        cls._order = [
            ('create_date', 'DESC'),
            ('id', 'DESC'),

    def __register__(cls, module_name):
        cursor = Transaction().connection.cursor()

        super(Attachment, cls).__register__(module_name)
github tryton-ar / account_invoice_ar / View on Github external
            ('owners', '=', Eval('company_party')),
            ('numbers.type', '=', 'cbu'),
            'owners': Eval('company_party'),
            'numbers.type': 'cbu',
        depends=_DEPENDS + ['company_party'])
    pyafipws_anulacion = fields.Boolean('FCE MiPyme anulación', states=_STATES,
    currency_rate = fields.Numeric('Currency rate', digits=(12, 6),
        states={'readonly': Eval('state') != 'draft'}, depends=['state'])
    pyafipws_imp_neto = fields.Function(fields.Numeric('Gravado',
            digits=(12, 2)), 'on_change_with_pyafipws_imp_neto')
    pyafipws_imp_tot_conc = fields.Function(fields.Numeric('No Gravado',
            digits=(12, 2)), 'on_change_with_pyafipws_imp_tot_conc')
    pyafipws_imp_op_ex = fields.Function(fields.Numeric('Exento',
            digits=(12, 2)), 'on_change_with_pyafipws_imp_op_ex')
    pyafipws_imp_iva = fields.Function(fields.Numeric('Imp. IVA',
            digits=(12, 2)), 'on_change_with_pyafipws_imp_iva')
    pyafipws_imp_trib = fields.Function(fields.Numeric('Imp. Tributo',
            digits=(12, 2)), 'on_change_with_pyafipws_imp_trib')
    pyafipws_cmp_asoc = fields.Many2Many('account.invoice-cmp.asoc',
        'invoice', 'cmp_asoc', 'Cmp Asoc', states=_STATES,
            ('company', '=', Eval('company', -1)),
            ('type', '=', 'out'),
                ('state', 'in', ['posted', 'paid']),
                ('id', 'in', Eval('pyafipws_cmp_asoc')),
github tryton / trytond / trytond / ir / View on Github external
"Action act window"
    __name__ = 'ir.action.act_window'
    domain = fields.Char('Domain Value')
    context = fields.Char('Context Value')
    order = fields.Char('Order Value')
    res_model = fields.Char('Model')
    context_model = fields.Char('Context Model')
    context_domain = fields.Char(
        "Context Domain",
        help="Part of the domain that will be evaluated on each refresh.")
    act_window_views = fields.One2Many('ir.action.act_window.view',
            'act_window', 'Views')
    views = fields.Function(fields.Binary('Views'), 'get_views')
    act_window_domains = fields.One2Many('ir.action.act_window.domain',
        'act_window', 'Domains')
    domains = fields.Function(fields.Binary('Domains'), 'get_domains')
    limit = fields.Integer('Limit', help='Default limit for the list view.')
    action = fields.Many2One('ir.action', 'Action', required=True,
    search_value = fields.Char('Search Criteria',
            help='Default search criteria for the list view.')
    pyson_domain = fields.Function(fields.Char('PySON Domain'), 'get_pyson')
    pyson_context = fields.Function(fields.Char('PySON Context'),
    pyson_order = fields.Function(fields.Char('PySON Order'), 'get_pyson')
    pyson_search_value = fields.Function(fields.Char(
        'PySON Search Criteria'), 'get_pyson')

    def __setup__(cls):
        super(ActionActWindow, cls).__setup__()