Initial commit

This commit is contained in:
2023-01-20 15:25:20 +01:00
commit e308314fbb
52 changed files with 620 additions and 0 deletions

15
py_class.sublime-snippet Normal file
View File

@@ -0,0 +1,15 @@
<snippet>
<content><![CDATA[
from trytond.model import ModelSQL, ModelView, fields
class ${1:ClassName}(ModelSQL, ModelView):
"""${2:Model Title}"""
__name__ = '${3:model.name}'
${4}
]]></content>
<tabTrigger>tryton_class</tabTrigger>
<scope>source.python</scope>
<description>Tryton: New model</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
context = Transaction().context
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_context</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python</scope>
<description>Tryton: context</description>
</snippet>

View File

@@ -0,0 +1,14 @@
<snippet>
<content><![CDATA[
@classmethod
def copy(cls, ${1:records}, default=None):
if default is None:
default = {}
default = default.copy()
default.setdefault('${3}', None)
return super().copy($1, default=default)
]]></content>
<tabTrigger>tryton_copy</tabTrigger>
<scope>source.python</scope>
<description>Tryton: copy() reimplementation</description>
</snippet>

View File

@@ -0,0 +1,12 @@
<snippet>
<content><![CDATA[
@classmethod
def create(cls, vlist):
${3:for vals in vlist:
}
${2:return} super().create(vlist)
]]></content>
<tabTrigger>tryton_create</tabTrigger>
<scope>source.python </scope>
<description>Tryton: create() reimplementation</description>
</snippet>

View File

@@ -0,0 +1,9 @@
<snippet>
<content><![CDATA[
Date = Pool().get('ir.date')
today = Date.today()
]]></content>
<tabTrigger>tryton_today</tabTrigger>
<scope>source.python</scope>
<description>Tryton: Today</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
@staticmethod
def default_${1:field_name}():
return ${2:True}
]]></content>
<tabTrigger>tryton_default.static</tabTrigger>
<scope>source.python</scope>
<description>Tryton: default_fieldname() function</description>
</snippet>

View File

@@ -0,0 +1,11 @@
<snippet>
<content><![CDATA[
@classmethod
def delete(cls, ${1:records}):
${3}
super().delete($1)
]]></content>
<tabTrigger>tryton_delete</tabTrigger>
<scope>source.python</scope>
<description>Tryton: delete() reimplementation</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
@fields.depends(${1:fields})
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_depends</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python </scope>
<description>Tryton: decorator for on_change/_with functions to specify which fields supply to the function in self object</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.BigInteger('${2:Field Title}'${3:, required=True}${4:, readonly=True}${7}${5:, help='${6}'})
]]></content>
<tabTrigger>tryton_fields.BigInteger</tabTrigger>
<scope>source.python </scope>
<description>Tryton: fields.BigInteger()</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.Binary('${2:Field Title}'${3:, filename='${4:$1_name}'}${5:, required=True}${6:, readonly=True}${9}${7:, help='${8}'})
]]></content>
<tabTrigger>tryton_fields.Binary</tabTrigger>
<scope>source.python</scope>
<description>Tryton: fields.Binary()</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.Boolean('${2:Field Title}'${3:, readonly=True}${6}${4:, help='${5}'})
]]></content>
<tabTrigger>tryton_fields.Boolean</tabTrigger>
<scope>source.python</scope>
<description>Tryton: fields.Boolean()</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.Date('${2:Field Title}'${3:, required=True}${4:, readonly=True}${7}${5:, help='${6}'})
]]></content>
<tabTrigger>tryton_fields.Date</tabTrigger>
<scope>source.python </scope>
<description>Tryton: fields.Date()</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.DateTime('${2:Field Title}'${3:, format=${4:'%H:M:%S'}}${5:, required=True}${6:, readonly=True}${9}${7:, help='${8}'})
]]></content>
<tabTrigger>tryton_fields.DateTime</tabTrigger>
<scope>source.python </scope>
<description>Tryton: fields.DateTime()</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.Integer("${2:Field name}")
]]></content>
<tabTrigger>tryton_fields.Integer</tabTrigger>
<scope>source.python </scope>
<description>Tryton: fields.Integer()</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.Numeric('${2:Field Title}', digits=(16, ${3:4})${4:, required=True}${5:, readonly=True}${8}${6:, help='${7}'})
]]></content>
<tabTrigger>tryton_fields.Numeric</tabTrigger>
<scope>source.python </scope>
<description>Tryton: fields.Numeric()</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.Text('${2:Field Title}'${3:, translate=True}${4:, size=${5}}${6:, required=True}${7:, readonly=True}${10}${8:, help='${9}'})
]]></content>
<tabTrigger>tryton_fields.Text</tabTrigger>
<scope>source.python </scope>
<description>Tryton: fields.Text()</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.Time("${2:Field name}"${3:, ${4:format='%H:%M'}})
]]></content>
<tabTrigger>tryton_fields.Time</tabTrigger>
<scope>source.python </scope>
<description>Tryton: fields.Time()</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
${1:fieldname} = fields.Timestamp('${2:Field Title}'${3:, required=True}${4:, readonly=True}${7}${5:, help='${6}'})
]]></content>
<tabTrigger>tryton_fields.Timestamp</tabTrigger>
<scope>source.python </scope>
<description>Tryton: fields.Timestamp()</description>
</snippet>

View File

@@ -0,0 +1,9 @@
<snippet>
<content><![CDATA[
def get_rec_name(self, name):
return ${1}
]]></content>
<tabTrigger>tryton_get_rec_name</tabTrigger>
<scope>source.python</scope>
<description>Tryton: getter for rec_name</description>
</snippet>

View File

@@ -0,0 +1,9 @@
<snippet>
<content><![CDATA[
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
]]></content>
<tabTrigger>tryton_header</tabTrigger>
<scope>source.python</scope>
<description>Tryton: modules file header</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
from trytond.config import config as config_
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_import_config</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python</scope>
<description>Tryton: config import</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
from trytond.model import Model, ModelSQL, ModelView, Workflow, fields
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_import_model</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python</scope>
<description>Tryton: model classes import</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
from trytond.pyson import Bool, If, In, Equal, Eval, Get, Not
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_import_pyson</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python</scope>
<description>Tryton: Pyson classes import</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
from trytond.transaction import Transaction
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_import_transaction</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python</scope>
<description>Tryton: Transaction classes import</description>
</snippet>

View File

@@ -0,0 +1,11 @@
<snippet>
<content><![CDATA[
from trytond.wizard import (Wizard, Button, StateAction, StateTransition,
StateView)
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_import_wizard</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python</scope>
<description>Tryton: wizard classes import</description>
</snippet>

View File

@@ -0,0 +1,13 @@
<snippet>
<content><![CDATA[
from trytond.model import ModelSQL, ModelView, fields
from trytond.pyson import Eval
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_imports</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python</scope>
<description>Tryton: common imports</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
Date = Pool().get('ir.date')
today = Date.today()
{1}
]]></content>
<tabTrigger>tryton_today</tabTrigger>
<scope>source.python</scope>
<description>Tryton: Today</description>
</snippet>

View File

@@ -0,0 +1,12 @@
<snippet>
<content><![CDATA[
@fields.depends(${2:used fields})
def on_change_${1:fieldname}(self):${7}
return ${3:{
${4:'${5:res_fieldname}': ${6},}
}}
]]></content>
<tabTrigger>tryton_on_change</tabTrigger>
<scope>source.python</scope>
<description>Tryton: function to compute values of fields when field change value</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
@fields.depends(${2:trigger/used fields})
def on_change_with_${1:fieldname}(self, name=None):${4}
return ${3}
]]></content>
<tabTrigger>tryton_on_change_with</tabTrigger>
<scope>source.python</scope>
<description>Tryton: function to compute functional field and value of field when others change value</description>
</snippet>

11
py_setup.sublime-snippet Normal file
View File

@@ -0,0 +1,11 @@
<snippet>
<content><![CDATA[
@classmethod
def __setup__(cls):
super().__setup__()
${1}
]]></content>
<tabTrigger>tryton_setup</tabTrigger>
<scope>source.python</scope>
<description>Tryton: setup() reimplementation</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
# -*- coding: utf-8 -*-
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>utf8-header</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.python</scope>
<description>UTF8 Header</description>
</snippet>

View File

@@ -0,0 +1,15 @@
<snippet>
<content><![CDATA[
@classmethod
def validate(cls, ${1:records}):
super(${2:ClassName}, cls).validate($1)
cls.check_${4:validation}($1)
@classmethod
def check_$4(cls, $1):
${5}
]]></content>
<tabTrigger>tryton_validate.class</tabTrigger>
<scope>source.python</scope>
<description>Tryton: validate() classmethod validation</description>
</snippet>

View File

@@ -0,0 +1,15 @@
<snippet>
<content><![CDATA[
@classmethod
def validate(cls, ${1:records}):
super(${2:ClassName}, cls).validate($1)
for ${3:record} in $1:
$3.check_${4:validation}()
def check_$4(self):
${5}
]]></content>
<tabTrigger>tryton_validate.instance</tabTrigger>
<scope>source.python</scope>
<description>Tryton: validate() instance method validation</description>
</snippet>

View File

@@ -0,0 +1,15 @@
<snippet>
<content><![CDATA[
@classmethod
def write(cls, *args):
actions = iter(args)
args = []
for records, values in zip(actions, actions):
${2:values['example'] = True # add/del/modify items from values}
args.extend((records, values))
super().write(*args)
]]></content>
<tabTrigger>tryton_write</tabTrigger>
<scope>source.python </scope>
<description>Tryton: write() reimplementation</description>
</snippet>

View File

@@ -0,0 +1,14 @@
<snippet>
<content><![CDATA[
<record model="ir.action.act_window.view" id="act_${1:model_id}_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="$1_list_view"/>
<field name="act_window" ref="act_$1"/>
</record>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_act_formview</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
<description>Tryton: Action Window List View record</description>
</snippet>

View File

@@ -0,0 +1,36 @@
<snippet>
<content><![CDATA[
<record model="ir.ui.view" id="${1:model_id}_view_form">
<field name="model">${2:model_name}</field>
<field name="type">form</field>
<field name="name">$1_form</field>
</record>
<record model="ir.ui.view" id="$1_view_list">
<field name="model">$2</field>
<field name="type">tree</field>
<field name="name">$1_list</field>
</record>
<record model="ir.action.act_window" id="act_$1">
<field name="name">${3:plural_title}</field>
<field name="res_model">$2</field>
<field name="search_value"></field>
<field name="domain"></field>
<field name="context"></field>
</record>
<record model="ir.action.act_window.view" id="act_$1_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="$1_view_list"/>
<field name="act_window" ref="act_$1"/>
</record>
<record model="ir.action.act_window.view" id="act_$1_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="$1_view_form"/>
<field name="act_window" ref="act_$1"/>
</record>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_complete_view</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
<description>Tryton: Complete view</description>
</snippet>

View File

@@ -0,0 +1,18 @@
<snippet>
<content><![CDATA[
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tryton>
<data>
${1}
</data>
</tryton>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_header</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
</snippet>

44
xml_help.sublime-snippet Normal file
View File

@@ -0,0 +1,44 @@
<snippet>
<content><![CDATA[
<!--
Sublime Tryton Snippets - XML help
1. General
tryton_header -
tryton_help - This help snippet.
2. View records
tryton_record_form -
tryton_record_inform -
tryton_record_list -
tryton_record_inlist -
tryton_record_tree -
3. Action records
tryton_act_window -
tryton_act_formview -
4. Complete view records with actions
tryton_complete_view -
5. Data
tryton_record_data -
6. Views general
tryton_view_header -
7. Tree/List views
tryton_view_field -
tryton_view_button -
8. Form views
tryton_view_form -
tryton_view_form_field -
tryton_view_label -
tryton_view_field -
tryton_view_button -
-->
]]></content>
<tabTrigger>tryton_help</tabTrigger>
<scope>text.xml</scope>
<description>Tryton XML help</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
<menuitem id="menu_${1:name}"${2: action="act_$1"}${3: parent="${4}.menu_${5}}"${6: icon="${7}"} sequence="${8}"/>
]]></content>
<tabTrigger>tryton_menuitem</tabTrigger>
<scope>text.xml</scope>
<description>Tryton: Menu item</description>
</snippet>

View File

@@ -0,0 +1,12 @@
<snippet>
<content><![CDATA[
<record model="${1:model.name}" id="${2:model_name_record_id}">
${3:fields}
</record>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_record_data</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
<description>Tryton: Record for data</description>
</snippet>

View File

@@ -0,0 +1,14 @@
<snippet>
<content><![CDATA[
<record model="ir.ui.view" id="${1:model_id}_view_form">
<field name="model">${2:model.name}</field>
<field name="type">form</field>
<field name="name">$1_form</field>
</record>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_record_form</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
<description>Tryton: Record for Form View</description>
</snippet>

View File

@@ -0,0 +1,14 @@
<snippet>
<content><![CDATA[
<record model="ir.ui.view" id="${1:model_id}_view_form">
<field name="model">${2:model.name}</field>
<field name="inherit" ref="${3:inherit_model}.${4:$1_view_form}"/>
<field name="name">$1_form</field>
</record>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_record_inform</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
<description>Tryton: Record for Inherited Form View</description>
</snippet>

View File

@@ -0,0 +1,14 @@
<snippet>
<content><![CDATA[
<record model="ir.ui.view" id="${1:model_id}_view_list">
<field name="model">${2:model.name}</field>
<field name="inherit" ref="${3:inherit_model}.${4:$1_view_${5:tree}}"/>
<field name="name">$1_list</field>
</record>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_record_inlist</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
<description>Tryton: Record for Inherited List View</description>
</snippet>

View File

@@ -0,0 +1,14 @@
<snippet>
<content><![CDATA[
<record model="ir.ui.view" id="${1:model_id}_view_list">
<field name="model">${2:model.name}</field>
<field name="type">tree</field>
<field name="name">$1_list</field>
</record>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_record_list</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
<description>Tryton: Record for List View</description>
</snippet>

View File

@@ -0,0 +1,15 @@
<snippet>
<content><![CDATA[
<record model="ir.ui.view" id="${1:model_id}_view_tree">
<field name="model">${2:model.name}</field>
<field name="type">tree</field>
<field name="field_childs">${3:childs}</field>
<field name="name">$1_tree</field>
</record>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_record_tree</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
<description>Tryton: Record for Tree View</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
<button name="${1:name}"${2: string="${3:label}"}${4: icon="${5:tryton-executable}"}${6: confirm="${7:Are you sure?}"}${8: colspan="${9:2}"}${10: states="${11}"}${12: help="${13}"}/>
]]></content>
<tabTrigger>tryton_view_button</tabTrigger>
<scope>text.xml</scope>
<description>Tryton: View button</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
<field name="${1:fieldname}"/>
]]></content>
<tabTrigger>tryton_view_field</tabTrigger>
<scope>text.xml</scope>
<description>Tryton: View field</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
<form ${1: col="${2}"}>
${3}
</form>
]]></content>
<tabTrigger>tryton_view_form</tabTrigger>
<scope>text.xml</scope>
<description>Tryton: Form view</description>
</snippet>

View File

@@ -0,0 +1,9 @@
<snippet>
<content><![CDATA[
<label name="${1:fieldname}"/>
<field name="${1}"/>
]]></content>
<tabTrigger>tryton_view_form_field</tabTrigger>
<scope>text.xml</scope>
<description>Tryton: View label and field</description>
</snippet>

View File

@@ -0,0 +1,13 @@
<snippet>
<content><![CDATA[
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
${1}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tryton_view_header</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
<description>Tryton: view file header</description>
</snippet>

View File

@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[
<label name="${1:fieldname}"/>
]]></content>
<tabTrigger>tryton_view_label</tabTrigger>
<scope>text.xml</scope>
<description>Tryton: View label</description>
</snippet>

View File

@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
<tree>
${1}
</tree>
]]></content>
<tabTrigger>tryton_view_tree</tabTrigger>
<scope>text.xml</scope>
<description>Tryton: Tree view</description>
</snippet>