-
Notifications
You must be signed in to change notification settings - Fork 0
/
o.sh
139 lines (135 loc) · 4 KB
/
o.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
DB=`pwd | xargs basename`
DBFILTER="^${DB}$"
DBTEST=`pwd | xargs basename`-tests
DBFILTERTEST="^${DBTEST}$"
function _k {
pkill -9 odoo
}
function _setup {
pip install --upgrade pip
pip install -r requirements.txt -e .
pip install pudb ipython
}
function _doc {
V=`python -c "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)";` # python -V does not really work in 2
F=~/src/doc_$DB
pigeoo -m $2 -p ~/src/$DB/odoo/addons,~/.virtualenvs/$DB/lib/python$V/site-packages/odoo/addons -o $F
python3 -m webbrowser -t $F/index_module.html 2>&1
}
function _prod2test {
click-odoo-dropdb $DBTEST
click-odoo-copydb $DB $DBTEST
_clean 0 $DBTEST
}
function _clean {
DB=${2:-$DB}
B=`odoo --version | awk '{print $3;}' | sed 's/\..*//'`
if (($B<12)) ; then
psql -d $DB -c "update res_users set login='admin' where id=1;"
else
psql -d $DB -c "update res_users set login='admin' where id=2;"
fi
psql -d $DB -c "UPDATE res_users SET password=login;"
psql -d $DB -c "DELETE FROM ir_attachment WHERE name like '%assets_%';"
psql -d $DB -c "UPDATE ir_cron SET active='f';"
psql -d $DB -c "UPDATE ir_mail_server SET active=false;"
psql -d $DB -c "UPDATE ir_config_parameter SET value = '2042-01-01 00:00:00' WHERE key = 'database.expiration_date';"
psql -d $DB -c "UPDATE ir_config_parameter SET value = '"+new_uuid+"' WHERE key = 'database.uuid';"
psql -d $DB -c "INSERT INTO ir_mail_server(active,name,smtp_host,smtp_port,smtp_encryption) VALUES (true,'mailcatcher','localhost',1025,false);"
}
function _pu {
pip-df sync --update $2
}
function _ga {
gitaggregate -c gitaggregate.yaml -d src/$2 -p
}
function _release {
echo "git push && acsoo tag"
git push && acsoo tag
}
function _bumpp {
bumpversion patch --commit && _release
}
function _bumpm {
bumpversion minor --commit && _release
}
function _bumpM {
bumpversion major --commit && _release
}
function _ddb {
psql -l | awk '{print $1;}' | grep -E $2 | xargs -t -I % click-odoo-dropdb %
}
function _dropdbs {
PATTERN=`pwd | xargs basename`_
_ddb 0 $PATTERN
}
# Main database
function _up {
click-odoo-update -c .odoorc -d $DB
}
function _i {
odoo -d `pwd | xargs basename` -c ./.odoorc --db-filter=$DBFILTER -i $2 --stop-after-init
}
function _u {
odoo -d `pwd | xargs basename` -c ./.odoorc --db-filter=$DBFILTER -u $2 --stop-after-init
}
function _r {
odoo -d $DB -c ./.odoorc --db-filter=$DBFILTER
}
function _rt {
odoo -d $DBTEST -c ./.odoorc --db-filter=$DBFILTERTEST
}
function _rs {
odoo shell -d $DB -c ./.odoorc -p 9069
}
function _rst {
odoo shell -d $DBTEST -c ./.odoorc -p 9069
}
# Test DB
function _upt {
click-odoo-update -c .odoorc -d $DBTEST
}
function _it {
odoo -d $DBTEST -c ./.odoorc --db-filter=$DBFILTERTEST -i $2 --stop-after-init
}
function _t {
odoo -d $DBTEST -c ./.odoorc --db-filter=$DBFILTERTEST -u $2 --test-enable --stop-after-init --workers 0
}
# Module-specific databases
function _rtt {
DB=`pwd | xargs basename`_$2-tests
DBFILTER="^${DB}$"
odoo -d $DB -c ./.odoorc --db-filter=$DBFILTER
}
function _itt {
DB=`pwd | xargs basename`_$2-tests
DBFILTER="^${DB}$"
echo $DB
if psql $DB -c '' 2>&1; then
dropdb $DB
fi
odoo -d $DB -c ./.odoorc --db-filter=$DBFILTER -i $2 --stop-after-init
}
function _itti {
DB=`pwd | xargs basename`_$2-tests
DBFILTER="^${DB}$"
odoo -d $DB -c ./.odoorc --db-filter=$DBFILTER -i $3 --stop-after-init
}
function _tt {
DB=`pwd | xargs basename`_$2-tests
DBFILTER="^${DB}$"
if ! psql $DB -c '' 2>&1 ; then
echo "Installing first..."
odoo -d $DB -c ./.odoorc --db-filter=$DBFILTER -i $2 --stop-after-init
fi
odoo -d $DB -c ./.odoorc --db-filter=$DBFILTER -u $2 --test-enable --stop-after-init --workers 0
}
# profiling
function _xprof {
# if on python2, install gprof2dot in the venv
XPROF="$2.xdot"
gprof2dot -f pstats -o $XPROF $2
xdot $XPROF
}
_$1 "$@"