Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'),
}),
'get_last_user')
last_modification = fields.Function(fields.DateTime('Last Modification',
states={
'invisible': ~Eval('last_modification'),
}),
'get_last_modification')
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': {
'invisible': ~Eval('state').in_(['draft', 'chatting']),
'readonly': Eval('act_from') != Eval('_user'),
},
'reply': {
'invisible': Eval('state') != 'waiting',
'readonly': Eval('act_to') != Eval('_user'),
},
'close': {
'invisible': ~Eval('state').in_(['waiting', 'draft',
'chatting']),
},
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={
'invisible': Eval('on_time', False),
}, depends=['on_time'])
condition = fields.Char('Condition', required=True,
help='A PYSON statement evaluated with record represented by '
'"self"\nIt triggers the action if true.')
limit_number = fields.Integer('Limit Number', required=True,
help='Limit the number of call to "Action Function" by records.\n'
'0 for no limit.')
#! -*- coding: utf8 -*-
from trytond.model import ModelView, ModelSQL, fields
from trytond.pyson import Bool, Eval
__all__ = ['Journal']
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([
('' , ''),
('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()
pool = Pool()
pos_table = cls.__table__()
company_table = pool.get('company.company').__table__()
TableHandler = backend.get('TableHandler')
table = TableHandler(cls, module_name)
exist = table.column_exist('company')
'nereid.user', 'Assigned to', depends=['all_participants'],
domain=[('id', 'in', Eval('all_participants'))],
states={
'invisible': Eval('type') != 'task',
'readonly': Eval('type') != 'task',
}
)
progress_state = fields.Selection(
PROGRESS_STATES, 'Progress State',
depends=['state', 'type'], select=True,
states={
'invisible':
(Eval('type') != 'task') | (Eval('state') != 'opened'),
'readonly':
(Eval('type') != 'task') | (Eval('state') != 'opened'),
}
)
owner = fields.Many2One(
'nereid.user', 'Task Owner', depends=['all_participants'],
domain=[('id', 'in', Eval('all_participants'))],
states={
'invisible': Eval('type') != 'task',
}
)
description_markup = fields.Selection([
(None, 'Plain text'),
('rst', 'reStructuredText'),
('markdown', 'Markdown'),
], 'Description Markup Type', states={
@fields.depends('taxes', 'pyafipws_exento')
def on_change_with_pyafipws_exento(self, name=None):
if self.taxes:
return False
return self.pyafipws_exento
class Invoice(metaclass=PoolMeta):
__name__ = 'account.invoice'
pos = fields.Many2One('account.pos', 'Point of Sale',
domain=[('company', '=', Eval('company'))],
states=_POS_STATES, depends=_DEPENDS + ['company'])
invoice_type = fields.Many2One('account.pos.sequence', 'Comprobante',
domain=[('pos', '=', Eval('pos')),
('invoice_type', 'in',
If(Eval('total_amount', -1) >= 0,
['1', '2', '4', '5', '6', '7', '9', '11', '12', '15',
'19', '20', '201', '202', '206', '207', '211', '212'],
['3', '8', '13', '21', '203', '208', '213']),
)],
states=_POS_STATES, depends=_DEPENDS + ['pos', 'invoice_type',
'total_amount'])
invoice_type_tree = fields.Function(fields.Selection(INVOICE_TYPE_POS,
'Tipo comprobante'), 'get_comprobante',
searcher='search_comprobante')
pyafipws_concept = fields.Selection([
('1', '1-Productos'),
('2', '2-Servicios'),
('3', '3-Productos y Servicios'),
('4', '4-Otros (exportación)'),
class Export(metaclass=PoolMeta):
__name__ = 'ir.export'
groups = fields.Many2Many(
'ir.export-res.group', 'export', 'group', "Groups",
help="The user groups that can use the export.")
write_groups = fields.Many2Many(
'ir.export-write-res.group', 'export', 'group',
"Modification Groups",
domain=[
('id', 'in', Eval('groups', [])),
],
states={
'invisible': ~Eval('groups'),
},
depends=['groups'],
help="The user groups that can modify the export.")
class Export_Group(ModelSQL):
"Export Group"
__name__ = 'ir.export-res.group'
export = fields.Many2One(
'ir.export', "Export", required=True, select=True, ondelete='CASCADE')
group = fields.Many2One(
'res.group', "Group", required=True, ondelete='CASCADE')
class Export_Write_Group(Export_Group):
def __setup__(cls):
super(User, cls).__setup__()
cls.__rpc__.update({
'get_preferences': RPC(check_access=False),
'set_preferences': RPC(
readonly=False, check_access=False, fresh_session=True),
'get_preferences_fields_view': RPC(check_access=False),
})
table = cls.__table__()
cls._sql_constraints += [
('login_key', Unique(table, table.login),
'You can not have two users with the same login!')
]
cls._buttons.update({
'reset_password': {
'invisible': ~Eval('email', True) | (not _has_password),
},
})
cls._preferences_fields = [
'name',
'password',
'email',
'signature',
'menu',
'pyson_menu',
'actions',
'status_bar',
'warnings',
'applications',
]
cls._context_fields = [
'language',
help='Número de factura informado a la AFIP')
transactions = fields.One2Many('account_invoice_ar.afip_transaction',
'invoice', 'Transacciones', readonly=True)
tipo_comprobante = fields.Selection(TIPO_COMPROBANTE, 'Comprobante',
select=True, depends=['state', 'type'], states={
'invisible': Eval('type') == 'out',
'readonly': Eval('state') != 'draft',
})
tipo_comprobante_string = tipo_comprobante.translated('tipo_comprobante')
pyafipws_incoterms = fields.Selection(INCOTERMS, 'Incoterms')
pyafipws_licenses = fields.One2Many('account.invoice.export.license',
'invoice', 'Export Licenses')
ref_pos_number = fields.Function(fields.Char('POS Number', size=5, states={
'required': And(Eval('type') == 'in', Eval('state') != 'draft'),
'invisible': Eval('type') == 'out',
'readonly': Eval('state') != 'draft',
}), 'get_ref_subfield', setter='set_ref_subfield')
ref_voucher_number = fields.Function(fields.Char('Voucher Number', size=8,
states={
'required': And(Eval('type') == 'in', Eval('state') != 'draft'),
'invisible': Eval('type') == 'out',
'readonly': Eval('state') != 'draft',
}), 'get_ref_subfield', setter='set_ref_subfield')
pos_pos_daily_report = fields.Function(
fields.Boolean("POS Daily Report"),
'on_change_with_pos_pos_daily_report')
ref_number_from = fields.Char('From number', size=13,
states=_REF_NUMBERS_STATES,
depends=['pos_pos_daily_report', 'state'])
ref_number_to = fields.Char('To number', size=13,
states=_REF_NUMBERS_STATES,
depends=['pos_pos_daily_report', 'state'])