diff --git a/share/tryton/tryton.glade b/share/tryton/tryton.glade
index 60ea3567d8..04c353c134 100644
--- a/share/tryton/tryton.glade
+++ b/share/tryton/tryton.glade
@@ -36,128 +36,6 @@
3
3
3
-
-
- True
- 1
- 3
- 3
- User:
-
-
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- 1
- 3
- 3
- Password:
- GTK_JUSTIFY_RIGHT
-
-
- 3
- 4
- GTK_FILL
-
-
-
-
-
- True
- True
- Change
- True
- 0
-
-
-
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- False
- False
- True
- 16
- localhost
-
-
- 1
- 2
-
-
-
-
-
- True
- 1
- 3
- 3
- Database:
-
-
- 1
- 2
- GTK_FILL
-
-
-
-
-
- 117
- True
- 1
- 3
- 3
- Server:
-
-
- GTK_FILL
-
-
-
-
-
- True
- True
- True
- admin
-
-
- 1
- 3
- 2
- 3
-
-
-
-
-
- True
- True
- True
- False
- True
-
-
- 1
- 3
- 3
- 4
-
-
-
True
@@ -189,6 +67,128 @@
GTK_FILL
+
+
+ True
+ True
+ True
+ False
+ True
+
+
+ 1
+ 3
+ 3
+ 4
+
+
+
+
+
+ True
+ True
+ True
+ admin
+
+
+ 1
+ 3
+ 2
+ 3
+
+
+
+
+
+ 117
+ True
+ 1
+ 3
+ 3
+ Server:
+
+
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ 3
+ 3
+ Database:
+
+
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+
+ True
+ False
+ False
+ True
+ 16
+ localhost
+
+
+ 1
+ 2
+
+
+
+
+
+ True
+ True
+ Change
+ True
+ 0
+
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ 3
+ 3
+ Password:
+ GTK_JUSTIFY_RIGHT
+
+
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ 3
+ 3
+ User:
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
1
@@ -1870,130 +1870,6 @@
2
5
4
-
-
- True
- 1
- Default _value:
- True
- ent_value
-
-
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- False
- True
- False
-
-
- 1
- 2
- 2
- 3
-
-
-
-
-
- True
- False
- True
- False
-
-
- 1
- 2
- 1
- 2
-
-
-
-
-
- True
- False
- True
- False
-
-
- 1
- 2
-
-
-
-
-
- True
- 1
- _Domain:
- True
- GTK_JUSTIFY_RIGHT
- ent_domain
-
-
- 1
- 2
- GTK_FILL
-
-
-
-
-
- True
- 1
- Field _Name:
- True
- GTK_JUSTIFY_RIGHT
- ent_field
-
-
- GTK_FILL
-
-
-
-
-
- True
- 0
-
-
- True
- 12
-
-
- True
-
-
-
-
-
-
-
-
-
- True
- <b>Value applicable if:</b>
- True
-
-
- label_item
-
-
-
-
- 2
- 4
- 5
- GTK_FILL
-
-
True
@@ -2061,6 +1937,130 @@
GTK_FILL
+
+
+ True
+ 0
+
+
+ True
+ 12
+
+
+ True
+
+
+
+
+
+
+
+
+
+ True
+ <b>Value applicable if:</b>
+ True
+
+
+ label_item
+
+
+
+
+ 2
+ 4
+ 5
+ GTK_FILL
+
+
+
+
+ True
+ 1
+ Field _Name:
+ True
+ GTK_JUSTIFY_RIGHT
+ ent_field
+
+
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ _Domain:
+ True
+ GTK_JUSTIFY_RIGHT
+ ent_domain
+
+
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+
+ True
+ False
+ True
+ False
+
+
+ 1
+ 2
+
+
+
+
+
+ True
+ False
+ True
+ False
+
+
+ 1
+ 2
+ 1
+ 2
+
+
+
+
+
+ True
+ False
+ True
+ False
+
+
+ 1
+ 2
+ 2
+ 3
+
+
+
+
+
+ True
+ 1
+ Default _value:
+ True
+ ent_value
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
2
@@ -3649,337 +3649,43 @@ Each version is given a distinguishing version number. If the Program specifies
15
2
-
+
True
- 0
- <Ctrl> + O
+ 2
+ <b>Shortcuts for Tryton</b>
+ True
+ GTK_JUSTIFY_CENTER
- 1
- 2
- GTK_FILL
+ 2
+ 5
-
+
True
0
- Connect
+ Close window without saving
1
2
- 1
- 2
+ 14
+ 15
GTK_FILL
-
+
True
0
- <Ctrl> + F
+ <Ctrl> + <Esc>
- 5
- 6
- GTK_FILL
-
-
-
-
-
- True
- 0
- Find / Search
-
-
- 1
- 2
- 5
- 6
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Ctrl> + D
-
-
- 4
- 5
- GTK_FILL
-
-
-
-
-
- True
- 0
- Delete
-
-
- 1
- 2
- 4
- 5
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Ctrl> + N
-
-
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- 0
- New
-
-
- 1
- 2
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Ctrl> + <PgUp>
-
-
- 9
- 10
- GTK_FILL
-
-
-
-
-
- True
- 0
- Previous tab
-
-
- 1
- 2
- 9
- 10
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Ctrl> + <PgDn>
-
-
- 10
- 11
- GTK_FILL
-
-
-
-
-
- True
- 0
- Next Tab
-
-
- 1
- 2
- 10
- 11
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Ctrl> + S
-
-
- 3
- 4
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Ctrl> + W
-
-
- 11
- 12
- GTK_FILL
-
-
-
-
-
- True
- 0
- Save
-
-
- 1
- 2
- 3
- 4
- GTK_FILL
-
-
-
-
-
- True
- 0
- Close Tab
-
-
- 1
- 2
- 11
- 12
- GTK_FILL
-
-
-
-
-
- True
- 0
- <PgUp>
-
-
- 6
- 7
- GTK_FILL
-
-
-
-
-
- True
- 0
- <PgDn>
-
-
- 7
- 8
- GTK_FILL
-
-
-
-
-
- True
- 0
- Previous record
-
-
- 1
- 2
- 6
- 7
- GTK_FILL
-
-
-
-
-
- True
- 0
- Next record
-
-
- 1
- 2
- 7
- 8
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Ctrl> + L
-
-
- 8
- 9
- GTK_FILL
-
-
-
-
-
- True
- 0
- Switch view mode
-
-
- 1
- 2
- 8
- 9
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Ctrl> + <Enter>
-
-
- 13
- 14
- GTK_FILL
-
-
-
-
-
- True
- 0
- Save and Close window
-
-
- 1
- 2
- 13
- 14
+ 14
+ 15
GTK_FILL
@@ -4002,45 +3708,339 @@ Each version is given a distinguishing version number. If the Program specifies
-
+
True
0
- <Ctrl> + <Esc>
-
-
- 14
- 15
- GTK_FILL
-
-
-
-
-
- True
- 0
- Close window without saving
+ Save and Close window
1
2
- 14
- 15
+ 13
+ 14
GTK_FILL
-
+
True
- 2
- <b>Shortcuts for Tryton</b>
- True
- GTK_JUSTIFY_CENTER
+ 0
+ <Ctrl> + <Enter>
+ 13
+ 14
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Switch view mode
+
+
+ 1
2
+ 8
+ 9
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + L
+
+
+ 8
+ 9
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Next record
+
+
+ 1
+ 2
+ 7
+ 8
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Previous record
+
+
+ 1
+ 2
+ 6
+ 7
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <PgDn>
+
+
+ 7
+ 8
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <PgUp>
+
+
+ 6
+ 7
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Close Tab
+
+
+ 1
+ 2
+ 11
+ 12
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Save
+
+
+ 1
+ 2
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + W
+
+
+ 11
+ 12
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + S
+
+
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Next Tab
+
+
+ 1
+ 2
+ 10
+ 11
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + <PgDn>
+
+
+ 10
+ 11
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Previous tab
+
+
+ 1
+ 2
+ 9
+ 10
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + <PgUp>
+
+
+ 9
+ 10
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ New
+
+
+ 1
+ 2
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + N
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Delete
+
+
+ 1
+ 2
+ 4
+ 5
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + D
+
+
+ 4
+ 5
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Find / Search
+
+
+ 1
+ 2
+ 5
+ 6
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + F
+
+
+ 5
+ 6
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Connect
+
+
+ 1
+ 2
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + O
+
+
+ 1
+ 2
+ GTK_FILL
- 5
@@ -4062,182 +4062,57 @@ Each version is given a distinguishing version number. If the Program specifies
10
2
-
+
True
0
- <Ctrl> + X
+ F2
+ GTK_JUSTIFY_CENTER
- 1
- 2
+ 9
+ 10
GTK_FILL
-
+
True
- 0
- <Ctrl> + C
+ <b>Shortcuts in relation fields</b>
+ True
- 2
- 3
+ 2
+ 7
+ 8
GTK_FILL
+ 5
-
+
True
- 0
- <Ctrl> + V
+ <b>Shortcuts in text entries</b>
+ True
- 3
- 4
- GTK_FILL
+ 2
+ 5
-
+
True
0
- Cut selected text
+ Open current field
1
2
- 1
- 2
- GTK_FILL
-
-
-
-
-
- True
- 0
- Copy selected text
-
-
- 1
- 2
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- 0
- Paste selected text
-
-
- 1
- 2
- 3
- 4
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Tab>
-
-
- 4
- 5
- GTK_FILL
-
-
-
-
-
- True
- 0
- Next editable widget
-
-
- 1
- 2
- 4
- 5
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Shist> + <Tab>
-
-
- 5
- 6
- GTK_FILL
-
-
-
-
-
- True
- 0
- Previous editable widget
-
-
- 1
- 2
- 5
- 6
- GTK_FILL
-
-
-
-
-
- True
- 0
- <Enter>
-
-
- 6
- 7
- GTK_FILL
-
-
-
-
-
- True
- 0
- Auto-Complete text field
-
-
- 1
- 2
- 6
- 7
- GTK_FILL
-
-
-
-
-
- True
- 0
- F1
-
-
- 8
- 9
+ 9
+ 10
GTK_FILL
@@ -4258,57 +4133,182 @@ Each version is given a distinguishing version number. If the Program specifies
-
+
True
0
- Open current field
+ F1
+
+
+ 8
+ 9
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Auto-Complete text field
1
2
- 9
- 10
+ 6
+ 7
GTK_FILL
-
- True
- <b>Shortcuts in text entries</b>
- True
-
-
- 2
-
- 5
-
-
-
-
- True
- <b>Shortcuts in relation fields</b>
- True
-
-
- 2
- 7
- 8
- GTK_FILL
-
- 5
-
-
-
-
+
True
0
- F2
- GTK_JUSTIFY_CENTER
+ <Enter>
- 9
- 10
+ 6
+ 7
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Previous editable widget
+
+
+ 1
+ 2
+ 5
+ 6
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Shist> + <Tab>
+
+
+ 5
+ 6
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Next editable widget
+
+
+ 1
+ 2
+ 4
+ 5
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Tab>
+
+
+ 4
+ 5
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Paste selected text
+
+
+ 1
+ 2
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Copy selected text
+
+
+ 1
+ 2
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ Cut selected text
+
+
+ 1
+ 2
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + V
+
+
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + C
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+ 0
+ <Ctrl> + X
+
+
+ 1
+ 2
GTK_FILL
@@ -4726,67 +4726,36 @@ Each version is given a distinguishing version number. If the Program specifies
8
9
-
+
True
- 1
- Field Separater:
-
-
- GTK_FILL
-
-
-
-
-
- True
- 1
- Encoding:
-
-
- 1
- 2
- GTK_FILL
-
-
-
-
-
- True
- True
- 1
- 1
- ,
+ UTF-8
+Latin1
+
+
+
+
1
2
+ 1
+ 2
GTK_FILL
-
+ GTK_FILL
-
- True
- 1
- Text Delimiter:
-
-
- 2
- 3
- GTK_FILL
-
-
-
-
-
+
True
True
- 1
- "
+ 0 0 100 1 10 10
+ 1
3
4
+ 1
+ 2
GTK_FILL
@@ -4807,15 +4776,54 @@ Each version is given a distinguishing version number. If the Program specifies
-
+
True
True
- 0 0 100 1 10 10
- 1
+ 1
+ "
3
4
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ Text Delimiter:
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+ True
+ 1
+ 1
+ ,
+
+
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ Encoding:
+
+
1
2
GTK_FILL
@@ -4823,22 +4831,14 @@ Each version is given a distinguishing version number. If the Program specifies
-
+
True
- UTF-8
-Latin1
-
-
-
-
+ 1
+ Field Separater:
- 1
- 2
- 1
- 2
GTK_FILL
- GTK_FILL
+
@@ -4955,38 +4955,22 @@ Latin1
True
12
- 3
+ 2
2
6
-
+
True
1
+ 0
3
- 3
- Port:
+ Server:
- 1
- 2
GTK_FILL
-
-
- True
- True
- True
- 16
- localhost
-
-
- 1
- 2
-
-
-
True
@@ -5005,46 +4989,32 @@ Latin1
-
+
True
- 1
- 3
- 3
- Protocol connection:
-
-
- 2
- 3
- GTK_FILL
-
-
-
-
-
- 170
- True
- 1
- 0
- 3
- Server:
-
-
- GTK_FILL
-
-
-
-
-
- True
-
+ True
+ True
+ 16
+ localhost
1
2
- 2
- 3
+
+
+
+
+
+ True
+ 1
+ 3
+ 3
+ Port:
+
+
+ 1
+ 2
GTK_FILL
- GTK_FILL
+
@@ -5132,17 +5102,93 @@ Latin1
3
3
-
+
True
- False
- False
- True
- 16
- http://localhost:8069
+ 1
+ 3
+ 3
+ Password:
+ GTK_JUSTIFY_RIGHT
+
+
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ Database:
+
+
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+
+
+ True
+
+
+
+
+ True
+ 0
+ True
+
+
+ False
+ False
+ 1
+
+
1
- 2
+ 3
+ 2
+ 3
+ GTK_FILL
+ GTK_FILL
+
+
+
+
+ True
+ True
+ True
+ 16
+ False
+ True
+ 16
+
+
+ 1
+ 3
+ 1
+ 2
+
+
+
+
+
+ 117
+ True
+ 1
+ 3
+ 3
+ Server:
+
+
+ GTK_FILL
@@ -5197,93 +5243,17 @@ Latin1
-
- 117
+
True
- 1
- 3
- 3
- Server:
-
-
- GTK_FILL
-
-
-
-
-
- True
- True
- True
- 16
- False
+ False
+ False
True
16
+ http://localhost:8069
1
- 3
- 1
- 2
-
-
-
-
-
- True
-
-
- True
-
-
-
-
- True
- 0
- True
-
-
- False
- False
- 1
-
-
-
-
- 1
- 3
- 2
- 3
- GTK_FILL
- GTK_FILL
-
-
-
-
- True
- 1
- Database:
-
-
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- 1
- 3
- 3
- Password:
- GTK_JUSTIFY_RIGHT
-
-
- 1
- 2
- GTK_FILL
+ 2
@@ -5379,31 +5349,91 @@ Latin1
-
- 117
+
True
- 1
- 3
- 3
- Server:
+ 3
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+ True
+ 0
+ (must not contain any special char)
+
+
+ 1
+ 3
+ 4
+ 5
GTK_FILL
-
+
True
- False
- False
+ True
+ ●
True
16
- http://localhost:8069
1
- 2
+ 3
+ 3
+ 4
+
+
+
+
+
+ True
+ 0
+ New database name:
+
+
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ 3
+ 3
+ Password:
+ GTK_JUSTIFY_RIGHT
+
+
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+
+ True
+ True
+ True
+ 16
+ False
+ True
+ 16
+
+
+ 1
+ 3
+ 1
+ 2
@@ -5458,93 +5488,34 @@ Latin1
-
+
True
- True
- True
- 16
- False
+ False
+ False
True
16
+ http://localhost:8069
1
- 3
- 1
- 2
+ 2
-
+
+ 117
True
1
3
3
- Password:
- GTK_JUSTIFY_RIGHT
+ Server:
- 1
- 2
GTK_FILL
-
-
- True
- 0
- New database name:
-
-
- 3
- 4
- GTK_FILL
-
-
-
-
-
- True
- True
- ●
- 16
-
-
- 1
- 3
- 3
- 4
-
-
-
-
-
- True
- 0
- (must not contain any special char)
-
-
- 1
- 3
- 4
- 5
- GTK_FILL
-
-
-
-
-
- True
-
-
- 3
- 2
- 3
- GTK_FILL
-
-
False
@@ -5646,32 +5617,159 @@ Latin1
-
- 117
+
True
- 1
- 3
- 3
- Tryton server:
+ 0
+ (must not contain any special character)
+ True
+ 1
+ 3
+ 5
+ 6
GTK_FILL
-
+
True
- False
- This is the URL of the Tryton server. Use 'localhost' if the server is installed on this computer. Click on 'Change' to change the address.
- False
- True
- 16
- http://localhost:8069
+ Choose the default language that will be installed for this database. You will be able to install new languages after installation through the administration menu.
+
+
+ True
+
+
+
1
2
+ 6
+ 7
+ GTK_SHRINK | GTK_FILL
+
+
+
+
+ True
+ Hello World
+
+
+
+
+
+ 5
+ 6
+ GTK_FILL
+ GTK_FILL
+
+
+
+
+ True
+ True
+ True
+ This is the password of the user that have the rights to administer databases. This is not a Tryton user, just a super administrator. If you did not changed it, the password is 'admin' after installation.
+ 16
+ False
+ True
+ 16
+
+
+ 1
+ 3
+ 1
+ 2
+
+
+
+
+
+ True
+ 0
+ (use 'admin', if you did not changed it)
+ True
+
+
+ 1
+ 3
+ 2
+ 3
+ GTK_FILL
+
+
+
+
+
+ True
+
+
+ 3
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+ True
+ True
+ Choose the name of the database that will be created. The name must not contain any special character. Exemple: 'terp'.
+ 16
+ ●
+ True
+ 16
+
+
+ 1
+ 3
+ 4
+ 5
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ New database name:
+
+
+ 4
+ 5
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ Default language:
+
+
+ 6
+ 7
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ 3
+ 3
+ Super admin password:
+ GTK_JUSTIFY_RIGHT
+
+
+ 1
+ 2
+ GTK_FILL
@@ -5726,158 +5824,31 @@ Latin1
-
+
True
- 1
- 3
- 3
- Super admin password:
- GTK_JUSTIFY_RIGHT
-
-
- 1
- 2
- GTK_FILL
-
-
-
-
-
- True
- 1
- Default language:
-
-
- 6
- 7
- GTK_FILL
-
-
-
-
-
- True
- 1
- New database name:
-
-
- 4
- 5
- GTK_FILL
-
-
-
-
-
- True
- True
- Choose the name of the database that will be created. The name must not contain any special character. Exemple: 'terp'.
- 16
- ●
+ False
+ This is the URL of the Tryton server. Use 'localhost' if the server is installed on this computer. Click on 'Change' to change the address.
+ False
True
16
-
-
- 1
- 3
- 4
- 5
- GTK_FILL
-
-
-
-
-
- True
-
-
- 3
- 3
- 4
- GTK_FILL
-
-
-
-
- True
- 0
- (use 'admin', if you did not changed it)
- True
-
-
- 1
- 3
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- True
- True
- This is the password of the user that have the rights to administer databases. This is not a Tryton user, just a super administrator. If you did not changed it, the password is 'admin' after installation.
- 16
- False
- True
- 16
-
-
- 1
- 3
- 1
- 2
-
-
-
-
-
- True
- Hello World
-
-
-
-
-
- 5
- 6
- GTK_FILL
- GTK_FILL
-
-
-
-
- True
- Choose the default language that will be installed for this database. You will be able to install new languages after installation through the administration menu.
-
-
- True
-
-
-
+ http://localhost:8069
1
2
- 6
- 7
- GTK_SHRINK | GTK_FILL
+
-
+
+ 117
True
- 0
- (must not contain any special character)
- True
+ 1
+ 3
+ 3
+ Tryton server:
- 1
- 3
- 5
- 6
GTK_FILL
@@ -5970,70 +5941,47 @@ Latin1
3
3
-
+
True
- 1
- New password confirmation:
-
-
- 3
- 4
- GTK_FILL
-
-
-
-
-
- True
- 1
- New password:
-
-
- 2
- 3
- GTK_FILL
-
-
-
-
-
- True
- 1
- Old password:
-
-
- 1
- 2
- GTK_FILL
-
-
-
-
-
- 117
- True
- 1
- 3
- 3
- Server:
-
-
- GTK_FILL
-
-
-
-
-
- True
- False
- False
- True
- 16
- http://localhost:8069
+ True
+ 16
+ False
1
- 2
+ 3
+ 3
+ 4
+
+
+
+
+
+ True
+ True
+ 16
+ False
+
+
+ 1
+ 3
+ 2
+ 3
+
+
+
+
+
+ True
+ True
+ 16
+ False
+
+
+ 1
+ 3
+ 1
+ 2
@@ -6088,47 +6036,70 @@ Latin1
-
+
True
- True
- 16
- False
+ False
+ False
+ True
+ 16
+ http://localhost:8069
1
- 3
+ 2
+
+
+
+
+
+ 117
+ True
+ 1
+ 3
+ 3
+ Server:
+
+
+ GTK_FILL
+
+
+
+
+
+ True
+ 1
+ Old password:
+
+
1
2
+ GTK_FILL
-
+
True
- True
- 16
- False
+ 1
+ New password:
- 1
- 3
2
3
+ GTK_FILL
-
+
True
- True
- 16
- False
+ 1
+ New password confirmation:
- 1
- 3
3
4
+ GTK_FILL
diff --git a/tryton/action/main.py b/tryton/action/main.py
index a8d08c26cf..d83e775a0e 100644
--- a/tryton/action/main.py
+++ b/tryton/action/main.py
@@ -22,16 +22,23 @@ class Action(object):
ids = datas['ids']
del datas['ids']
if not ids:
- ids = rpc.session.rpc_exec_auth('/object', 'execute',
- datas['model'], 'search', [])
+ try:
+ ids = rpc.execute('object', 'execute', datas['model'],
+ 'search', [])
+ except Exception, exception:
+ rpc.process_exception(exception, Main.get_main().window)
+ return False
if ids == []:
message(_('Nothing to print!'), Main.get_main().window)
return False
datas['id'] = ids[0]
- ctx = rpc.session.context.copy()
+ ctx = rpc.CONTEXT.copy()
ctx.update(context)
- res = rpc.session.rpc_exec_auth('/report', 'execute', name,
- ids, datas, ctx)
+ try:
+ res = rpc.execute('report', 'execute', name, ids, datas, ctx)
+ except Exception, exception:
+ rpc.process_exception(exception, Main.get_main().window)
+ return False
if not res:
return False
(type, data) = res
@@ -44,20 +51,34 @@ class Action(object):
@staticmethod
def execute(act_id, datas, action_type=None, context=None):
+ from tryton.gui import Main
if context is None:
context = {}
- ctx = rpc.session.context.copy()
+ ctx = rpc.CONTEXT.copy()
ctx.update(context)
if not action_type:
- res = rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.action', 'read', act_id, ['type'], ctx)
+ res = False
+ try:
+ res = rpc.execute('object', 'execute', 'ir.action', 'read',
+ act_id, ['type'], ctx)
+ except Exception, exception:
+ rpc.process_exception(exception, Main.get_main().window)
+ return
if not res:
raise Exception, 'ActionNotFound'
action_type = res['type']
- act_id2 = rpc.session.rpc_exec_auth('/object', 'execute', action_type,
+ try:
+ act_id2 = rpc.execute('object', 'execute', action_type,
'search', [('action', '=', act_id)], 0, None, None, ctx)[0]
- res = rpc.session.rpc_exec_auth('/object', 'execute', action_type,
+ except Exception, exception:
+ rpc.process_exception(exception, Main.get_main().window)
+ return
+ try:
+ res = rpc.execute('object', 'execute', action_type,
'read', act_id2, False, ctx)
+ except Exception, exception:
+ rpc.process_exception(exception, Main.get_main().window)
+ return
Action._exec_action(res, datas)
@staticmethod
@@ -100,7 +121,7 @@ class Action(object):
ctx = {
'active_id': datas.get('id',False),
'active_ids': datas.get('ids',[]),
- 'user': rpc.session.user,
+ 'user': rpc._USER,
}
ctx.update(eval(action.get('context','{}'), ctx.copy()))
ctx.update(context)
@@ -126,17 +147,17 @@ class Action(object):
@staticmethod
def exec_keyword(keyword, data=None, context=None, warning=True):
+ from tryton.gui import Main
actions = []
if 'id' in data:
+ model_id = data.get('id', False)
try:
- model_id = data.get('id', False)
- actions = rpc.session.rpc_exec_auth('/object', 'execute',
+ actions = rpc.execute('object', 'execute',
'ir.action.keyword', 'get_keyword', keyword,
(data['model'], model_id))
- except rpc.RPCException, exp:
+ except Exception, exception:
from tryton.gui import Main
- error(_('Error: ')+str(exp.type), exp.message,
- Main.get_main().window, exp.data)
+ rpc.process_exception(exception, Main.get_main().window)
return False
keyact = {}
diff --git a/tryton/common/common.py b/tryton/common/common.py
index da227f00ba..cb1a86887f 100644
--- a/tryton/common/common.py
+++ b/tryton/common/common.py
@@ -322,7 +322,7 @@ def sur_3b(msg, parent):
else:
return 'cancel'
-def ask(question, parent):
+def ask(question, parent, visibility=True):
win = gtk.Dialog(_('Tryton'), parent,
gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
@@ -339,6 +339,7 @@ def ask(question, parent):
vbox.pack_start(gtk.Label(question))
entry = gtk.Entry()
entry.set_activates_default(True)
+ entry.set_visibility(visibility)
vbox.pack_start(entry)
hbox.pack_start(vbox)
win.vbox.pack_start(hbox)
diff --git a/tryton/gui/main.py b/tryton/gui/main.py
index b77def9cd0..13ce97c1b7 100644
--- a/tryton/gui/main.py
+++ b/tryton/gui/main.py
@@ -17,15 +17,15 @@ import base64
_ = gettext.gettext
-def _refresh_dblist(db_widget, url, dbtoload=None):
+def _refresh_dblist(db_widget, host, port, dbtoload=None):
if not dbtoload:
dbtoload = CONFIG['login.db']
index = 0
liststore = db_widget.get_model()
liststore.clear()
- result = rpc.session.list_db(url)
- if result == -1:
- return -1
+ result = rpc.db_list(host, port)
+ if result is None:
+ return None
for db_num, dbname in enumerate(result):
liststore.append([dbname])
if dbname == dbtoload:
@@ -33,10 +33,10 @@ def _refresh_dblist(db_widget, url, dbtoload=None):
db_widget.set_active(index)
return len(liststore)
-def _refresh_langlist(lang_widget, url):
+def _refresh_langlist(lang_widget, host, port):
liststore = lang_widget.get_model()
liststore.clear()
- lang_list = rpc.session.db_exec_no_except(url, 'list_lang')
+ lang_list = rpc.db_exec(host, port, 'list_lang')
for key, val in lang_list:
liststore.insert(0, (val, key))
lang_widget.set_active(0)
@@ -52,39 +52,20 @@ def _server_ask(server_widget, parent):
win.set_default_response(gtk.RESPONSE_OK)
host_widget = win_gl.get_widget('ent_host')
port_widget = win_gl.get_widget('ent_port')
- protocol_widget = win_gl.get_widget('protocol')
- protocols = {
- 'XML-RPC': 'http://',
- 'XML-RPC secure': 'https://',
- 'NET-RPC (faster)': 'socket://',
- }
- listprotocol = gtk.ListStore(str)
- protocol_widget.set_model(listprotocol)
-
-
- url_m = re.match('^(http[s]?://|socket://)([\w.-]+):(\d{1,5})$',
+ url_m = re.match('^([\w.-]+):(\d{1,5})$',
server_widget.get_text())
if url_m:
- host_widget.set_text(url_m.group(2))
- port_widget.set_text(url_m.group(3))
-
- index = 0
- i = 0
- for protocol in protocols:
- listprotocol.append([protocol])
- if url_m and protocols[protocol] == url_m.group(1):
- index = i
- i += 1
- protocol_widget.set_active(index)
+ host_widget.set_text(url_m.group(1))
+ port_widget.set_text(url_m.group(2))
res = win.run()
if res == gtk.RESPONSE_OK:
- protocol = protocols[protocol_widget.get_active_text()]
- url = '%s%s:%s' % (protocol, host_widget.get_text(),
- port_widget.get_text())
+ host = host_widget.get_text()
+ port = int(port_widget.get_text())
+ url = '%s:%d' % (host, port)
server_widget.set_text(url)
- result = url
+ result = (host, port)
parent.present()
win.destroy()
return result
@@ -96,9 +77,9 @@ class DBLogin(object):
self.win_gl = glade.XML(GLADE, "win_login", gettext.textdomain())
@staticmethod
- def refreshlist(widget, db_widget, label, url, butconnect=None):
- res = _refresh_dblist(db_widget, url)
- if res == -1:
+ def refreshlist(widget, db_widget, label, host, port, butconnect=None):
+ res = _refresh_dblist(db_widget, host, port)
+ if res is None:
label.set_label(''+_('Could not connect to server !')+'')
db_widget.hide()
label.show()
@@ -120,9 +101,10 @@ class DBLogin(object):
@staticmethod
def refreshlist_ask(widget, server_widget, db_widget, label,
- butconnect=False, url=False, parent=None):
- url = _server_ask(server_widget, parent) or url
- return DBLogin.refreshlist(widget, db_widget, label, url, butconnect)
+ butconnect=False, host=False, port=0, parent=None):
+ host, port = _server_ask(server_widget, parent) or (host, port)
+ return DBLogin.refreshlist(widget, db_widget, label, host, port,
+ butconnect)
def run(self, dbname, parent):
win = self.win_gl.get_widget('win_login')
@@ -141,10 +123,9 @@ class DBLogin(object):
label.hide()
host = CONFIG['login.server']
- port = CONFIG['login.port']
- protocol = CONFIG['login.protocol']
+ port = int(CONFIG['login.port'])
- url = '%s%s:%s' % (protocol, host, port)
+ url = '%s:%d' % (host, port)
server_widget.set_text(url)
login.set_text(CONFIG['login.login'])
@@ -155,9 +136,9 @@ class DBLogin(object):
db_widget.pack_start(cell, True)
db_widget.add_attribute(cell, 'text', 0)
- res = self.refreshlist(None, db_widget, label, url, but_connect)
+ res = self.refreshlist(None, db_widget, label, host, port, but_connect)
change_button.connect_after('clicked', DBLogin.refreshlist_ask,
- server_widget, db_widget, label, but_connect, url, win)
+ server_widget, db_widget, label, but_connect, host, port, win)
if dbname:
i = liststore.get_iter_root()
@@ -168,16 +149,15 @@ class DBLogin(object):
i = liststore.iter_next(i)
res = win.run()
- url_m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$',
+ url_m = re.match('^([\w.\-]+):(\d{1,5})$',
server_widget.get_text() or '')
if url_m:
- CONFIG['login.server'] = url_m.group(2)
+ CONFIG['login.server'] = url_m.group(1)
CONFIG['login.login'] = login.get_text()
- CONFIG['login.port'] = url_m.group(3)
- CONFIG['login.protocol'] = url_m.group(1)
+ CONFIG['login.port'] = url_m.group(2)
CONFIG['login.db'] = db_widget.get_active_text()
- result = (login.get_text(), passwd.get_text(), url_m.group(2),
- url_m.group(3), url_m.group(1), db_widget.get_active_text())
+ result = (login.get_text(), passwd.get_text(), url_m.group(1),
+ int(url_m.group(2)), db_widget.get_active_text())
else:
parent.present()
win.destroy()
@@ -204,10 +184,10 @@ class DBCreate(object):
return sensitive
def server_change(self, widget, parent):
- url = _server_ask(self.server_widget, parent)
+ host, port = _server_ask(self.server_widget, parent)
try:
- if self.lang_widget and url:
- _refresh_langlist(self.lang_widget, url)
+ if self.lang_widget and host and port:
+ _refresh_langlist(self.lang_widget, host, port)
self.set_sensitive(True)
except:
self.set_sensitive(False)
@@ -230,15 +210,15 @@ class DBCreate(object):
change_button = self.dialog.get_widget('but_server_new')
change_button.connect_after('clicked', self.server_change, win)
- protocol = CONFIG['login.protocol']
- url = '%s%s:%s' % (protocol, CONFIG['login.server'],
- CONFIG['login.port'])
+ host = CONFIG['login.server']
+ port = int(CONFIG['login.port'])
+ url = '%s:%d' % (host, port)
self.server_widget.set_text(url)
liststore = gtk.ListStore(str, str)
self.lang_widget.set_model(liststore)
try:
- _refresh_langlist(self.lang_widget, url)
+ _refresh_langlist(self.lang_widget, host, port)
except:
self.set_sensitive(False)
@@ -262,18 +242,17 @@ class DBCreate(object):
and self.lang_widget.get_model().get_value(langidx, 1)
passwd = pass_widget.get_text()
url = self.server_widget.get_text()
- url_m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$',
+ url_m = re.match('^([\w.\-]+):(\d{1,5})$',
url or '')
if url_m:
- CONFIG['login.server'] = url_m.group(2)
- CONFIG['login.port'] = url_m.group(3)
- CONFIG['login.protocol'] = url_m.group(1)
+ CONFIG['login.server'] = host = url_m.group(1)
+ CONFIG['login.port'] = port = url_m.group(2)
parent.present()
win.destroy()
if res == gtk.RESPONSE_OK:
try:
- users = rpc.session.db_exec_no_except(url, 'create', passwd, dbname,
+ users = rpc.db_exec(host, int(port), 'create', passwd, dbname,
langreal)
except:
common.warning(_('The server crashed during installation.\n' \
@@ -486,14 +465,17 @@ class Main(object):
def shortcut_set(self):
def _action_shortcut(widget, action):
- ctx = rpc.session.context.copy()
+ ctx = rpc.CONTEXT.copy()
Action.exec_keyword('tree_open', {'model': 'ir.ui.menu',
'id': action, 'ids': [action],
'window': self.window}, context=ctx)
- user = rpc.session.user
- shortcuts = rpc.session.rpc_exec_auth_try('/object', 'execute',
- 'ir.ui.view_sc', 'get_sc', user, 'ir.ui.menu',
- rpc.session.context)
+ user = rpc._USER
+ try:
+ shortcuts = rpc.execute('object', 'execute',
+ 'ir.ui.view_sc', 'get_sc', user, 'ir.ui.menu',
+ rpc.CONTEXT)
+ except:
+ shortcuts = []
menu = gtk.Menu()
for shortcut in shortcuts:
menuitem = gtk.MenuItem(shortcut['name'])
@@ -599,37 +581,31 @@ class Main(object):
return ([], [])
def sig_login(self, widget=None, dbname=False, res=None):
- try:
- if not res:
- try:
- dblogin = DBLogin()
- res = dblogin.run(dbname, self.window)
- except Exception, exception:
- if exception.args == ('QueryCanceled',):
- return False
- raise
- self.window.present()
- self.sig_logout(widget)
- log_response = rpc.session.login(*res)
- if log_response == 1:
- CONFIG.save()
- menu_id = self.sig_win_menu(quiet=False)
- if menu_id:
- self.sig_home_new(quiet=True, except_id=menu_id)
- if res[4] == 'https://':
- self.secure_img.show()
- else:
- self.secure_img.hide()
- self.request_set()
- elif log_response==-1:
- common.message(_('Connection error !\n' \
- 'Unable to connect to the server !'), self.window)
- elif log_response==-2:
- common.message(_('Connection error !\n' \
- 'Bad username or password !'), self.window)
- self.shortcut_set()
- except rpc.RPCException:
- rpc.session.logout()
+ if not res:
+ try:
+ dblogin = DBLogin()
+ res = dblogin.run(dbname, self.window)
+ except Exception, exception:
+ if exception.args == ('QueryCanceled',):
+ return False
+ raise
+ self.window.present()
+ self.sig_logout(widget)
+ log_response = rpc.login(*res)
+ if log_response == 1:
+ CONFIG.save()
+ menu_id = self.sig_win_menu(quiet=False)
+ if menu_id:
+ self.sig_home_new(quiet=True, except_id=menu_id)
+ self.secure_img.hide()
+ self.request_set()
+ elif log_response==-1:
+ common.message(_('Connection error !\n' \
+ 'Unable to connect to the server !'), self.window)
+ elif log_response==-2:
+ common.message(_('Connection error !\n' \
+ 'Bad username or password !'), self.window)
+ self.shortcut_set()
self.glade.get_widget('but_menu').set_sensitive(True)
self.glade.get_widget('user').set_sensitive(True)
self.glade.get_widget('form').set_sensitive(True)
@@ -660,7 +636,7 @@ class Main(object):
self.glade.get_widget('user').set_sensitive(False)
self.glade.get_widget('form').set_sensitive(False)
self.glade.get_widget('plugins').set_sensitive(False)
- rpc.session.logout()
+ rpc.logout()
return True
def sig_tips(self, *args):
@@ -710,16 +686,15 @@ class Main(object):
def sig_win_new(self, widget=None, menu_type='menu', quiet=True,
except_id=False):
try:
- prefs = rpc.session.rpc_exec_auth('/object', 'execute',
- 'res.user', 'get_preferences', False, rpc.session.context)
+ prefs = rpc.execute('object', 'execute',
+ 'res.user', 'get_preferences', False, rpc.CONTEXT)
except:
return False
sb_id = self.sb_username.get_context_id('message')
self.sb_username.push(sb_id, prefs['name'] or '')
sb_id = self.sb_servername.get_context_id('message')
- data = urlparse.urlsplit(rpc.session._url)
- self.sb_servername.push(sb_id, data[0]+':'+(data[1] and '//'+data[1] \
- or data[2])+' ['+CONFIG['login.db']+']')
+ self.sb_servername.push(sb_id, '%s@%s:%d' % (rpc._USERNAME,
+ rpc._SOCK.host, rpc._SOCK.port))
if not prefs[menu_type]:
if quiet:
return False
@@ -727,15 +702,15 @@ class Main(object):
'Ask the administrator to verify\n' \
'you have an action defined for your user.'),
'Access Denied!', self.window)
- rpc.session.logout()
+ rpc.logout()
return False
act_id = prefs[menu_type]
if except_id and act_id == except_id:
return act_id
Action.execute(act_id, {'window': self.window})
try:
- prefs = rpc.session.rpc_exec_auth_wo('/object', 'execute',
- 'res.user', 'get_preferences', False, rpc.session.context)
+ prefs = rpc.execute('object', 'execute',
+ 'res.user', 'get_preferences', False, rpc.CONTEXT)
if prefs[menu_type]:
act_id = prefs[menu_type]
except:
@@ -881,13 +856,16 @@ class Main(object):
if not dbname:
return
- res = rpc.session.db_exec(url, 'drop', passwd, dbname)
- if res:
- common.message(_("Database dropped successfully!"),
- parent=self.window)
- else:
+ host, port = url.split(':')
+
+ try:
+ rpc.db_exec(host, int(port), 'drop', passwd, dbname)
+ except:
common.message(_('Unable to drop the database!'),
parent=self.window)
+ return
+ common.message(_("Database dropped successfully!"),
+ parent=self.window)
def sig_db_restore(self, widget):
filename = common.file_selection(_('Open...'), parent=self.window,
@@ -900,7 +878,9 @@ class Main(object):
file_p = file(filename, 'rb')
data_b64 = base64.encodestring(file_p.read())
file_p.close()
- res = rpc.session.db_exec(url, 'restore', passwd, dbname, data_b64)
+ host, port = url.split(':')
+ res = rpc.db_exec(host, int(port), 'restore', passwd, dbname,
+ data_b64)
if res:
common.message(_("Database restored successfully!"),
parent=self.window)
@@ -924,9 +904,8 @@ class Main(object):
lambda a,b: _server_ask(b, win), server_widget)
host = CONFIG['login.server']
- port = CONFIG['login.port']
- protocol = CONFIG['login.protocol']
- url = '%s%s:%s' % (protocol, host, port)
+ port = int(CONFIG['login.port'])
+ url = '%s:%d' % (host, port)
server_widget.set_text(url)
res = win.run()
@@ -940,7 +919,7 @@ class Main(object):
"new password, operation cancelled!"),
_("Validation Error."), parent=win)
else:
- rpc.session.db_exec(url, 'change_admin_password',
+ rpc.db_exec(host, port, 'change_admin_password',
old_passwd, new_passwd)
self.window.present()
win.destroy()
@@ -954,7 +933,8 @@ class Main(object):
preview=False)
if filename:
- dump_b64 = rpc.session.db_exec(url, 'dump', passwd, dbname)
+ host, port = url.split(':')
+ dump_b64 = rpc.db_exec(host, int(port), 'dump', passwd, dbname)
dump = base64.decodestring(dump_b64)
file_ = file(filename, 'wb')
file_.write(dump)
@@ -963,8 +943,8 @@ class Main(object):
parent=self.window)
def _choose_db_select(self, title=_("Backup a database")):
- def refreshlist(widget, db_widget, label, url):
- res = _refresh_dblist(db_widget, url)
+ def refreshlist(widget, db_widget, label, host, port):
+ res = _refresh_dblist(db_widget, host, port)
if res == -1:
label.set_label('' + \
_('Could not connect to server !') + '')
@@ -982,11 +962,11 @@ class Main(object):
def refreshlist_ask(widget, server_widget, db_widget, label,
parent=None):
- url = _server_ask(server_widget, parent)
+ host, port = _server_ask(server_widget, parent)
if not url:
return None
- refreshlist(widget, db_widget, label, url)
- return url
+ refreshlist(widget, db_widget, label, host, port)
+ return (host, port)
dialog = glade.XML(GLADE, "win_db_select",
gettext.textdomain())
@@ -1004,15 +984,15 @@ class Main(object):
dialog.get_widget('db_select_label').set_markup(''+title+'')
- protocol = CONFIG['login.protocol']
- url = '%s%s:%s' % (protocol, CONFIG['login.server'],
- CONFIG['login.port'])
+ host = CONFIG['login.server']
+ port = int(CONFIG['login.port'])
+ url = '%s:%d' % (host, port)
server_widget.set_text(url)
liststore = gtk.ListStore(str)
db_widget.set_model(liststore)
- refreshlist(None, db_widget, label, url)
+ refreshlist(None, db_widget, label, host, port)
change_button = dialog.get_widget('but_server_select')
change_button.connect_after('clicked', refreshlist_ask,
server_widget, db_widget, label, win)
@@ -1046,9 +1026,7 @@ class Main(object):
widget_pass = dialog.get_widget('ent_password')
widget_url = dialog.get_widget('ent_server')
- protocol = CONFIG['login.protocol']
- url = '%s%s:%s' % (protocol, CONFIG['login.server'],
- CONFIG['login.port'])
+ url = '%s:%d' % (CONFIG['login.server'], int(CONFIG['login.port']))
widget_url.set_text(url)
change_button = dialog.get_widget('but_server_change')
diff --git a/tryton/gui/window/attachment.py b/tryton/gui/window/attachment.py
index dad3c95594..1f10b249b5 100644
--- a/tryton/gui/window/attachment.py
+++ b/tryton/gui/window/attachment.py
@@ -36,8 +36,12 @@ class Attachment(object):
selection.set_mode(gtk.SELECTION_SINGLE)
selection.connect('changed', self._sig_changed)
- view = rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.attachment', 'fields_view_get', False, 'tree')
+ try:
+ view = rpc.execute('object', 'execute',
+ 'ir.attachment', 'fields_view_get', False, 'tree')
+ except Exception, exception:
+ rpc.process_exception(exception, parent)
+ raise
parse = Parse(view['fields'])
parse.parse(view['arch'], self.view)
@@ -73,16 +77,20 @@ class Attachment(object):
end = textview.get_buffer().get_end_iter()
comment = textview.get_buffer().get_text(start, end)
model, iter = self.view.get_selection().get_selected()
- context = copy.copy(rpc.session.context)
+ context = copy.copy(rpc.CONTEXT)
if not iter:
common.warning(_('You must put a text comment to an attachement.'),
self.win, _('Text not saved!'))
return None
obj_id = model.get_value(iter, 0)
if obj_id:
- rpc.session.rpc_exec_auth('/object', 'execute',
+ args = ('object', 'execute',
'ir.attachment', 'write', [int(obj_id)],
{'description': comment}, context)
+ try:
+ rpc.execute(*args)
+ except Exception, exception:
+ rpc.process_exception(exception, self.win, *args)
else:
common.warning(_('You must put a text comment to an attachement.'),
self.win, _('Text not saved!'))
@@ -95,8 +103,11 @@ class Attachment(object):
if obj_id:
if common.sur(_('Are you sure you want to remove this attachment?'),
self.win):
- rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.attachment', 'unlink', [int(obj_id)])
+ try:
+ rpc.execute('object', 'execute',
+ 'ir.attachment', 'unlink', [int(obj_id)])
+ except Exception, exception:
+ rpc.process_exception(exception, self.win, *args)
self.reload()
def _sig_link(self, widget):
@@ -106,13 +117,19 @@ class Attachment(object):
try:
if filename:
fname = os.path.basename(filename)
- obj_id = rpc.session.rpc_exec_auth('/object', 'execute',
+ args = ('object', 'execute',
'ir.attachment', 'create', {
'name': fname,
'res_model': self.ressource[0],
'res_id': self.ressource[1],
'link': filename,
})
+ try:
+ obj_id = rpc.execute(*args)
+ except Exception, exception:
+ obj_id = rpc.process_exception(exception, self.win, *args)
+ if not obj_id:
+ return
self.reload(preview=False)
self.preview(int(obj_id))
except IOError:
@@ -124,8 +141,12 @@ class Attachment(object):
return None
obj_id = model.get_value(iter, 0)
if obj_id:
- data = rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.attachment', 'read', int(obj_id))
+ try:
+ data = rpc.execute('object', 'execute',
+ 'ir.attachment', 'read', int(obj_id))
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return None
if not data:
return None
filename = common.file_selection(_('Save As...'),
@@ -162,13 +183,19 @@ class Attachment(object):
for filename in filenames:
value = file(filename, 'rb').read()
name = os.path.basename(filename)
- obj_id = rpc.session.rpc_exec_auth('/object', 'execute',
+ args = ('object', 'execute',
'ir.attachment', 'create', {
'name': name,
'datas': base64.encodestring(value),
'res_model': self.ressource[0],
'res_id': self.ressource[1],
})
+ try:
+ obj_id = rpc.execute(*args)
+ except Exception, exception:
+ obj_id = rpc.process_exception(exception, self.win, *args)
+ if not obj_id:
+ return
self.reload(preview=False)
self.preview(int(obj_id))
@@ -183,8 +210,12 @@ class Attachment(object):
iter = self.model.get_iter(path)
obj_id = self.model.get_value(iter, 0)
if obj_id:
- data = rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.attachment', 'read', int(obj_id))
+ try:
+ data = rpc.execute('object', 'execute',
+ 'ir.attachment', 'read', int(obj_id))
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return None
if not data:
return None
file_name = data['link']
@@ -199,8 +230,12 @@ class Attachment(object):
common.file_open(file_name, ext, self.parent)
def preview(self, obj_id):
- data = rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.attachment', 'read', obj_id)
+ try:
+ data = rpc.execute('object', 'execute',
+ 'ir.attachment', 'read', obj_id)
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return None
if not data:
return None
@@ -254,14 +289,22 @@ class Attachment(object):
def reload(self, preview=True):
self.model.clear()
- ids = rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.attachment', 'search', [
- ('res_model', '=', self.ressource[0]),
- ('res_id', '=', self.ressource[1]),
- ])
- res_ids = rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.attachment', 'read', ids,
- self.fields_order + ['link'])
+ try:
+ ids = rpc.execute('object', 'execute',
+ 'ir.attachment', 'search', [
+ ('res_model', '=', self.ressource[0]),
+ ('res_id', '=', self.ressource[1]),
+ ])
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return
+ try:
+ res_ids = rpc.execute('object', 'execute',
+ 'ir.attachment', 'read', ids,
+ self.fields_order + ['link'])
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return
for res in res_ids:
num = self.model.append()
args = []
diff --git a/tryton/gui/window/preference.py b/tryton/gui/window/preference.py
index 4d9a48506f..8b8384b67c 100644
--- a/tryton/gui/window/preference.py
+++ b/tryton/gui/window/preference.py
@@ -30,14 +30,22 @@ class Preference(object):
user = RPCProxy('res.user')
- res = user.get_preferences_fields_view(rpc.session.context)
+ try:
+ res = user.get_preferences_fields_view(rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, parent)
+ raise
arch = res['arch']
fields = res['fields']
self.screen = Screen('res.user', view_type=[], window=self.win)
self.screen.new(default=False)
self.screen.add_view_custom(arch, fields, display=True)
- preferences = user.get_preferences(False, rpc.session.context)
+ try:
+ preferences = user.get_preferences(False, rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, parent)
+ raise
self.screen.current_model.set(preferences)
width, height = self.screen.screen_container.size_get()
@@ -57,7 +65,11 @@ class Preference(object):
if self.screen.current_model.validate():
val = copy.copy(self.screen.get())
user = RPCProxy('res.user')
- user.set_preferences(val, rpc.session.context)
+ try:
+ user.set_preferences(val, rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ break
res = True
break
else:
diff --git a/tryton/gui/window/tree.py b/tryton/gui/window/tree.py
index c44b27b63a..0c1b91a1cc 100644
--- a/tryton/gui/window/tree.py
+++ b/tryton/gui/window/tree.py
@@ -25,15 +25,27 @@ class Tree(SignalEvent):
if context is None:
context = {}
if view_id:
- view_base = rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.ui.view', 'read', view_id,
- ['model', 'type'], context)
- view = rpc.session.rpc_exec_auth('/object', 'execute',
- view_base['model'], 'fields_view_get', view_id,
- view_base['type'],context)
+ try:
+ view_base = rpc.execute('object', 'execute',
+ 'ir.ui.view', 'read', view_id,
+ ['model', 'type'], context)
+ except Exception, exception:
+ rpc.process_exception(exception, window)
+ raise
+ try:
+ view = rpc.execute('object', 'execute',
+ view_base['model'], 'fields_view_get', view_id,
+ view_base['type'],context)
+ except Exception, exception:
+ rpc.process_exception(exception, window)
+ raise
else:
- view = rpc.session.rpc_exec_auth('/object', 'execute', model,
+ try:
+ view = rpc.execute('object', 'execute', model,
'fields_view_get', False, view_type, context)
+ except Exception, exception:
+ rpc.process_exception(exception, window)
+ raise
self.glade = glade.XML(GLADE, 'win_tree_container',
gettext.textdomain())
@@ -50,7 +62,7 @@ class Tree(SignalEvent):
self.context = context
- self.tree_res = ViewTree(view, [], True,
+ self.tree_res = ViewTree(view, [], self.window, True,
context=context)
self.tree_res.view.connect('row-activated', self.sig_activate)
self.tree_res.view.connect('key_press_event', self.sig_key_press)
@@ -70,7 +82,7 @@ class Tree(SignalEvent):
widget_sc = self.glade.get_widget('win_tree_sc')
widget_sc.connect('row-activated', self.sc_go)
- self.tree_sc = ViewTreeSC(widget_sc, self.model)
+ self.tree_sc = ViewTreeSC(widget_sc, self.model, self.window)
self.handlers = {
'but_reload': self.sig_reload,
'but_switch': self.sig_edit,
@@ -91,8 +103,12 @@ class Tree(SignalEvent):
self.glade.signal_connect(signal, signals[signal])
def sig_reload(self, widget=None):
- ids = rpc.session.rpc_exec_auth('/object', 'execute', self.model,
- 'search', self.domain2)
+ try:
+ ids = rpc.execute('object', 'execute', self.model,
+ 'search', self.domain2)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return
if self.tree_res.toolbar:
icon_name = 'icon'
@@ -100,9 +116,13 @@ class Tree(SignalEvent):
for child in wid.get_children():
wid.remove(child)
ctx = {}
- ctx.update(rpc.session.context)
- results = rpc.session.rpc_exec_auth_try('/object', 'execute',
- self.view['model'], 'read', ids, ['name', icon_name], ctx)
+ ctx.update(rpc.CONTEXT)
+ try:
+ results = rpc.execute('object', 'execute',
+ self.view['model'], 'read', ids, ['name', icon_name], ctx)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return
radiotb = None
for res in results:
radiotb = gtk.RadioToolButton(group=radiotb)
@@ -141,9 +161,13 @@ class Tree(SignalEvent):
if widget.get_active():
obj_id = widget.get_data('id')
- ids = rpc.session.rpc_exec_auth('/object', 'execute', self.model,
- 'read', obj_id, [self.view['field_childs']])\
- [self.view['field_childs']]
+ try:
+ ids = rpc.execute('object', 'execute', self.model,
+ 'read', obj_id, [self.view['field_childs']])\
+ [self.view['field_childs']]
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
self.tree_res.ids = ids
self.tree_res.reload()
@@ -208,24 +232,30 @@ class Tree(SignalEvent):
obj_id = self.tree_sc.sel_id_get()
if obj_id != None:
sc_id = int(self.tree_sc.value_get(2))
- rpc.session.rpc_exec_auth('/object', 'execute', 'ir.ui.view_sc',
- 'unlink', [sc_id])
+ try:
+ rpc.execute('object', 'execute', 'ir.ui.view_sc',
+ 'unlink', [sc_id])
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
self.tree_sc.update()
def sc_add(self, widget):
ids = self.ids_get()
if len(ids):
- res = rpc.session.rpc_exec_auth('/object', 'execute', self.model,
- 'name_get', ids, rpc.session.context)
- for (obj_id, name) in res:
- user = rpc.session.user
- rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.ui.view_sc', 'create', {
- 'resource': self.model,
- 'user_id': user,
- 'res_id': obj_id,
- 'name': name,
- })
+ try:
+ res = rpc.execute('object', 'execute', self.model,
+ 'name_get', ids, rpc.CONTEXT)
+ for (obj_id, name) in res:
+ user = rpc._USER
+ rpc.execute('object', 'execute',
+ 'ir.ui.view_sc', 'create', {
+ 'resource': self.model,
+ 'user_id': user,
+ 'res_id': obj_id,
+ 'name': name,
+ })
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
self.tree_sc.update()
def sc_go(self, widget=None, *args):
diff --git a/tryton/gui/window/view_form/model/field.py b/tryton/gui/window/view_form/model/field.py
index 5ec6cfa8a4..2f63c11792 100644
--- a/tryton/gui/window/view_form/model/field.py
+++ b/tryton/gui/window/view_form/model/field.py
@@ -168,7 +168,10 @@ class M2OField(CharField):
def set(self, model, value, test_state=False, modified=False):
if value and isinstance(value, (int, str, unicode, long)):
rpc2 = RPCProxy(self.attrs['relation'])
- result = rpc2.name_get([value], rpc.session.context)
+ try:
+ result = rpc2.name_get([value], rpc.CONTEXT)
+ except:
+ return
model.value[self.name] = result[0]
else:
model.value[self.name] = value
@@ -235,8 +238,8 @@ class O2MField(CharField):
def create(self, model):
from group import ModelRecordGroup
- mod = ModelRecordGroup(resource=self.attrs['relation'],
- fields={}, parent=model)
+ mod = ModelRecordGroup(self.attrs['relation'], {}, model.window,
+ parent=model)
mod.signal_connect(mod, 'model-changed', self._model_changed)
return mod
@@ -268,8 +271,8 @@ class O2MField(CharField):
def set(self, model, value, test_state=False, modified=False):
from group import ModelRecordGroup
- mod = ModelRecordGroup(resource=self.attrs['relation'],
- fields={}, parent=model)
+ mod = ModelRecordGroup(self.attrs['relation'], {}, model.window,
+ parent=model)
mod.signal_connect(mod, 'model-changed', self._model_changed)
model.value[self.name] = mod
#self.internal.signal_connect(self.internal, 'model-changed',
@@ -288,10 +291,13 @@ class O2MField(CharField):
if value and len(value):
context = self.context_get(model)
rpc2 = RPCProxy(self.attrs['relation'])
- fields = rpc2.fields_get(value[0].keys(), context)
+ try:
+ fields = rpc2.fields_get(value[0].keys(), context)
+ except:
+ return False
model.value[self.name] = ModelRecordGroup(
- resource=self.attrs['relation'], fields=fields, parent=model)
+ self.attrs['relation'], fields, model.window, parent=model)
model.value[self.name].signal_connect(model.value[self.name],
'model-changed', self._model_changed)
mod = None
@@ -349,7 +355,10 @@ class ReferenceField(CharField):
return
ref_model, ref_id = value.split(',')
rpc2 = RPCProxy(ref_model)
- result = rpc2.name_get([ref_id], rpc.session.context)
+ try:
+ result = rpc2.name_get([ref_id], rpc.CONTEXT)
+ except:
+ return
if result:
model.value[self.name] = ref_model, result[0]
else:
@@ -359,7 +368,8 @@ class ReferenceField(CharField):
model.modified_fields.setdefault(self.name)
TYPES = {
- 'char' : CharField,
+ 'char': CharField,
+ 'sha': CharField,
'float_time': FloatField,
'integer' : IntegerField,
'float' : FloatField,
diff --git a/tryton/gui/window/view_form/model/group.py b/tryton/gui/window/view_form/model/group.py
index 203ed1cb90..ebaf7fc63f 100644
--- a/tryton/gui/window/view_form/model/group.py
+++ b/tryton/gui/window/view_form/model/group.py
@@ -42,11 +42,12 @@ class ModelList(list):
class ModelRecordGroup(SignalEvent):
- def __init__(self, resource, fields, ids=None, parent=None, context=None):
+ def __init__(self, resource, fields, window, ids=None, parent=None, context=None):
super(ModelRecordGroup, self).__init__()
+ self.window = window
self.parent = parent
self._context = context or {}
- self._context.update(rpc.session.context)
+ self._context.update(rpc.CONTEXT)
self.resource = resource
self.rpc = RPCProxy(resource)
self.fields = fields
@@ -74,7 +75,11 @@ class ModelRecordGroup(SignalEvent):
def writen(self, edited_id):
if not self.on_write:
return
- new_ids = getattr(self.rpc, self.on_write)(edited_id, self.context)
+ try:
+ new_ids = getattr(self.rpc, self.on_write)(edited_id, self.context)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return
model_idx = self.models.index(self[edited_id])
result = False
for new_id in new_ids:
@@ -85,7 +90,7 @@ class ModelRecordGroup(SignalEvent):
model.reload()
if cont:
continue
- newmod = ModelRecord(self.resource, new_id,
+ newmod = ModelRecord(self.resource, new_id, self.window,
parent=self.parent, group=self)
newmod.reload()
if not result:
@@ -100,7 +105,7 @@ class ModelRecordGroup(SignalEvent):
if len(ids)>10:
self.models.lock_signal = True
for obj_id in ids:
- newmod = ModelRecord(self.resource, obj_id,
+ newmod = ModelRecord(self.resource, obj_id, self.window,
parent=self.parent, group=self)
self.model_add(newmod)
if display:
@@ -114,7 +119,7 @@ class ModelRecordGroup(SignalEvent):
if len(values)>10:
self.models.lock_signal = True
for value in values:
- newmod = ModelRecord(self.resource, value['id'],
+ newmod = ModelRecord(self.resource, value['id'], self.window,
parent=self.parent, group=self)
newmod.set(value)
self.models.append(newmod)
@@ -128,9 +133,13 @@ class ModelRecordGroup(SignalEvent):
return True
if not self.fields:
return self.pre_load(ids, display)
- ctx = rpc.session.context.copy()
+ ctx = rpc.CONTEXT.copy()
ctx.update(self.context)
- values = self.rpc.read(ids, self.fields.keys(), ctx)
+ try:
+ values = self.rpc.read(ids, self.fields.keys(), ctx)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
if not values:
return False
newmod = False
@@ -171,7 +180,7 @@ class ModelRecordGroup(SignalEvent):
return model
def model_new(self, default=True, domain=None, context=None):
- newmod = ModelRecord(self.resource, None, group=self,
+ newmod = ModelRecord(self.resource, None, self.window, group=self,
parent=self.parent, new=True)
newmod.signal_connect(self, 'record-changed', self._record_changed)
if default:
@@ -253,9 +262,13 @@ class ModelRecordGroup(SignalEvent):
new.append(model)
ctx = context.copy()
if len(old) and len(to_add):
- ctx.update(rpc.session.context)
+ ctx.update(rpc.CONTEXT)
ctx.update(self.context)
- values = self.rpc.read(old, to_add, ctx)
+ try:
+ values = self.rpc.read(old, to_add, ctx)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
if values:
for value in values:
value_id = value['id']
@@ -264,7 +277,11 @@ class ModelRecordGroup(SignalEvent):
self[value_id].set(value, signal=False)
if len(new) and len(to_add):
ctx.update(self.context)
- values = self.rpc.default_get(to_add, ctx)
+ try:
+ values = self.rpc.default_get(to_add, ctx)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
for field_to_add in to_add:
if field_to_add not in values:
values[field_to_add] = False
diff --git a/tryton/gui/window/view_form/model/record.py b/tryton/gui/window/view_form/model/record.py
index 800284c68f..0023cbcd6a 100644
--- a/tryton/gui/window/view_form/model/record.py
+++ b/tryton/gui/window/view_form/model/record.py
@@ -23,8 +23,9 @@ class EvalEnvironment(object):
class ModelRecord(SignalEvent):
- def __init__(self, resource, obj_id, group=None, parent=None, new=False ):
+ def __init__(self, resource, obj_id, window, group=None, parent=None, new=False ):
super(ModelRecord, self).__init__()
+ self.window = window
self.resource = resource
self.rpc = RPCProxy(self.resource)
self.id = obj_id
@@ -88,7 +89,13 @@ class ModelRecord(SignalEvent):
self._check_load()
if not self.id:
value = self.get(get_readonly=False)
- self.id = self.rpc.create(value, self.context_get())
+ try:
+ self.id = self.rpc.create(value, self.context_get())
+ except Exception, exception:
+ rpc.process_exception(exception, self.window, 'object',
+ 'execute', self.resource, 'create', value,
+ self.context_get())
+ return False
else:
if not self.is_modified():
return self.id
@@ -97,8 +104,13 @@ class ModelRecord(SignalEvent):
context = context.copy()
#XXX must compute delta on server side
context['read_delta'] = time.time() - self.read_time
- if not rpc.session.rpc_exec_auth('/object', 'execute',
- self.resource, 'write', [self.id], value, context):
+ args = ('object', 'execute', self.resource, 'write',
+ [self.id], value, context)
+ try:
+ if not rpc.execute(*args):
+ return False
+ except Exception, exception:
+ rpc.process_exception(exception, self.window, *args)
return False
self._loaded = False
if force_reload:
@@ -109,7 +121,11 @@ class ModelRecord(SignalEvent):
if domain is None:
domain = []
if len(self.mgroup.fields):
- val = self.rpc.default_get(self.mgroup.fields.keys(), context)
+ try:
+ val = self.rpc.default_get(self.mgroup.fields.keys(), context)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return
for clause in domain:
if clause[0] in self.mgroup.fields:
if clause[1] == '=':
@@ -119,7 +135,11 @@ class ModelRecord(SignalEvent):
self.set_default(val)
def name_get(self):
- name = self.rpc.name_get([self.id], rpc.session.context)[0]
+ try:
+ name = self.rpc.name_get([self.id], rpc.CONTEXT)[0]
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
return name
def validate_set(self):
@@ -187,9 +207,13 @@ class ModelRecord(SignalEvent):
def reload(self):
if not self.id:
return
- ctx = rpc.session.context.copy()
+ ctx = rpc.CONTEXT.copy()
ctx.update(self.context_get())
- res = self.rpc.read([self.id], self.mgroup.mfields.keys(), ctx)
+ try:
+ res = self.rpc.read([self.id], self.mgroup.mfields.keys(), ctx)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return
if res:
value = res[0]
self.read_time = time.time()
@@ -218,26 +242,38 @@ class ModelRecord(SignalEvent):
for arg in attr:
args[arg] = self.expr_eval(arg)
ids = self.id and [self.id] or []
- res = getattr(self.rpc, 'on_change_' + field)(ids, args,
- rpc.session.context)
+ try:
+ res = getattr(self.rpc, 'on_change_' + field)(ids, args,
+ rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return
if res:
self.set(res, modified=True)
self.signal('record-changed')
def cond_default(self, field_name, value):
ir_default = RPCProxy('ir.default')
- ctx = rpc.session.context.copy()
+ ctx = rpc.CONTEXT.copy()
ctx.update(self.context_get())
- self.set_default(ir_default.get_default(self.resource,
- field_name + '=' + str(value), ctx))
+ try:
+ self.set_default(ir_default.get_default(self.resource,
+ field_name + '=' + str(value), ctx))
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
def get_attachment_count(self, reload=False):
if not self.id:
return 0
if self.attachment_count < 0 or reload:
ir_attachment = RPCProxy('ir.attachment')
- self.attachment_count = ir_attachment.search_count([
- ('res_model', '=', self.resource),
- ('res_id', '=', self.id),
- ])
+ try:
+ self.attachment_count = ir_attachment.search_count([
+ ('res_model', '=', self.resource),
+ ('res_id', '=', self.id),
+ ])
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return 0
return self.attachment_count
diff --git a/tryton/gui/window/view_form/screen/screen.py b/tryton/gui/window/view_form/screen/screen.py
index 3aa49ad44e..fa2b3a9f93 100644
--- a/tryton/gui/window/view_form/screen/screen.py
+++ b/tryton/gui/window/view_form/screen/screen.py
@@ -49,15 +49,15 @@ class Screen(SignalEvent):
self.resource = model_name
self.rpc = RPCProxy(model_name)
self.context = context
- self.context.update(rpc.session.context)
+ self.context.update(rpc.CONTEXT)
self.views = []
self.fields = {}
self.view_ids = view_ids
self.models = None
self.parent = parent
self.window = window
- models = ModelRecordGroup(model_name, self.fields, parent=self.parent,
- context=self.context)
+ models = ModelRecordGroup(model_name, self.fields, self.window,
+ parent=self.parent, context=self.context)
self.models_set(models)
self.current_model = None
self.screen_container = ScreenContainer()
@@ -83,9 +83,12 @@ class Screen(SignalEvent):
if active and self.show_search:
if not self.filter_widget:
if not self.fields_view_tree:
- self.fields_view_tree = rpc.session.rpc_exec_auth('/object',
- 'execute', self.name, 'fields_view_get', False,
- 'tree', self.context)
+ try:
+ self.fields_view_tree = rpc.execute('object',
+ 'execute', self.name, 'fields_view_get', False,
+ 'tree', self.context)
+ except:
+ return
self.filter_widget = Form(self.fields_view_tree['arch'],
self.fields_view_tree['fields'], self.name, self.window,
self.domain, (self, self.search_filter))
@@ -112,10 +115,13 @@ class Screen(SignalEvent):
not (key == 'active' \
and self.context.get('active_test', False)):
values.append((key, operator, value))
- ids = rpc.session.rpc_exec_auth_try('/object', 'execute',
- self.name, 'search', values, offset,limit, 0, self.context)
- self.search_count = rpc.session.rpc_exec_auth_try('/object', 'execute',
- self.name, 'search_count', values, self.context)
+ try:
+ ids = rpc.execute('object', 'execute',
+ self.name, 'search', values, offset,limit, 0, self.context)
+ self.search_count = rpc.execute('object', 'execute',
+ self.name, 'search_count', values, self.context)
+ except:
+ ids = []
self.clear()
self.load(ids)
return True
@@ -220,8 +226,12 @@ class Screen(SignalEvent):
toolbar=self.views_preload[view_type].get('toolbar', False),
context=context)
else:
- view = self.rpc.fields_view_get(view_id, view_type, self.context,
- self.hastoolbar)
+ try:
+ view = self.rpc.fields_view_get(view_id, view_type, self.context,
+ self.hastoolbar)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ raise
return self.add_view(view['arch'], view['fields'], display,
toolbar=view.get('toolbar', False), context=context)
@@ -382,7 +392,11 @@ class Screen(SignalEvent):
if self.current_view.view_type == 'form' and self.current_model:
obj_id = self.current_model.id
if unlink and obj_id:
- if not self.rpc.unlink([obj_id]):
+ try:
+ if not self.rpc.unlink([obj_id]):
+ return False
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
return False
idx = self.models.models.index(self.current_model)
self.models.remove(self.current_model)
@@ -397,7 +411,11 @@ class Screen(SignalEvent):
if self.current_view.view_type == 'tree':
ids = self.current_view.sel_ids_get()
if unlink and ids:
- if not self.rpc.unlink(ids):
+ try:
+ if not self.rpc.unlink(ids):
+ return False
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
return False
for model in self.current_view.sel_models_get():
self.models.remove(model)
diff --git a/tryton/gui/window/view_form/view/form.py b/tryton/gui/window/view_form/view/form.py
index 1163f02b3b..46dc149e84 100644
--- a/tryton/gui/window/view_form/view/form.py
+++ b/tryton/gui/window/view_form/view/form.py
@@ -178,7 +178,7 @@ class ViewForm(ParserView):
def display(self):
model = self.screen.current_model
- values = rpc.session.context.copy()
+ values = rpc.CONTEXT.copy()
values['state'] = 'draft'
if model:
for field in model.mgroup.fields:
diff --git a/tryton/gui/window/view_form/view/form_gtk/action.py b/tryton/gui/window/view_form/view/form_gtk/action.py
index 7aa41326e1..c774b61a26 100644
--- a/tryton/gui/window/view_form/view/form_gtk/action.py
+++ b/tryton/gui/window/view_form/view/form_gtk/action.py
@@ -13,15 +13,23 @@ class Action(WidgetInterface):
super(Action, self).__init__(window, parent, model, attrs)
self.act_id = attrs['name']
- res = rpc.session.rpc_exec_auth('/object', 'execute',
- 'ir.actions.actions', 'read', [self.act_id], ['type'],
- rpc.session.context)
+ try:
+ res = rpc.execute('object', 'execute',
+ 'ir.actions.actions', 'read', [self.act_id], ['type'],
+ rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ raise
if not res:
raise Exception('ActionNotFound')
atype = res[0]['type']
- self.action = rpc.session.rpc_exec_auth('/object', 'execute', atype,
- 'read', self.act_id, False, rpc.session.context)
+ try:
+ self.action = rpc.execute('object', 'execute', atype,
+ 'read', self.act_id, False, rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ raise
if 'view_mode' in attrs:
self.action['view_mode'] = attrs['view_mode']
@@ -85,9 +93,13 @@ class Action(WidgetInterface):
return True
def display(self, model, model_field):
- res_id = rpc.session.rpc_exec_auth('/object', 'execute',
- self.action['res_model'], 'search', self.domain, 0,
- self.action.get('limit', 80))
+ try:
+ res_id = rpc.execute('object', 'execute',
+ self.action['res_model'], 'search', self.domain, 0,
+ self.action.get('limit', 80))
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ return False
self.screen.clear()
self.screen.load(res_id)
return True
diff --git a/tryton/gui/window/view_form/view/form_gtk/calendar.py b/tryton/gui/window/view_form/view/form_gtk/calendar.py
index 6377216c04..09a791094e 100644
--- a/tryton/gui/window/view_form/view/form_gtk/calendar.py
+++ b/tryton/gui/window/view_form/view/form_gtk/calendar.py
@@ -176,11 +176,11 @@ class DateTime(WidgetInterface):
locale.D_FMT).replace('%y', '%Y') + ' ' + HM_FORMAT)
except:
return False
- if 'timezone' in rpc.session.context and timezone:
+ if 'timezone' in rpc.CONTEXT and timezone:
try:
import pytz
- lzone = pytz.timezone(rpc.session.context['timezone'])
- szone = pytz.timezone(rpc.session.timezone)
+ lzone = pytz.timezone(rpc.CONTEXT['timezone'])
+ szone = pytz.timezone(rpc.TIMEZONE)
datetime = DT.datetime(date[0], date[1], date[2], date[3],
date[4], date[5], date[6])
ldt = lzone.localize(datetime, is_dst=True)
@@ -205,11 +205,11 @@ class DateTime(WidgetInterface):
self.entry.set_text('')
else:
date = time.strptime(dt_val, DHM_FORMAT)
- if 'timezone' in rpc.session.context and timezone:
+ if 'timezone' in rpc.CONTEXT and timezone:
try:
import pytz
- lzone = pytz.timezone(rpc.session.context['timezone'])
- szone = pytz.timezone(rpc.session.timezone)
+ lzone = pytz.timezone(rpc.CONTEXT['timezone'])
+ szone = pytz.timezone(rpc.TIMEZONE)
datetime = DT.datetime(date[0], date[1], date[2], date[3],
date[4], date[5], date[6])
sdt = szone.localize(datetime, is_dst=True)
diff --git a/tryton/gui/window/view_form/view/form_gtk/char.py b/tryton/gui/window/view_form/view/form_gtk/char.py
index 3ca0d75794..0896cb687f 100644
--- a/tryton/gui/window/view_form/view/form_gtk/char.py
+++ b/tryton/gui/window/view_form/view/form_gtk/char.py
@@ -36,3 +36,10 @@ class Char(WidgetInterface):
super(Char, self)._readonly_set(value)
self.entry.set_editable(not value)
self.entry.set_sensitive(not value)
+
+
+class Sha(Char):
+
+ def __init__(self, window, parent, model, attrs=None):
+ super(Sha, self).__init__(window, parent, model=model, attrs=attrs)
+ self.entry.set_visibility(False)
diff --git a/tryton/gui/window/view_form/view/form_gtk/interface.py b/tryton/gui/window/view_form/view/form_gtk/interface.py
index 603e216008..fc4277c70c 100644
--- a/tryton/gui/window/view_form/view/form_gtk/interface.py
+++ b/tryton/gui/window/view_form/view/form_gtk/interface.py
@@ -55,13 +55,17 @@ def field_pref_set(field, name, model, value, dependance=None, window=None):
break
user = False
if radio.get_active():
- user = rpc.session.user
+ user = rpc._USER
window.present()
win.destroy()
if res == gtk.RESPONSE_OK:
ir_default = RPCProxy('ir.default')
- ir_default.set_default(model, field, clause, value, user,
- rpc.session.context)
+ try:
+ ir_default.set_default(model, field, clause, value, user,
+ rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, window)
+ return False
return True
return False
@@ -96,7 +100,7 @@ class WidgetInterface(object):
.get('readonly', False):
return False
model = self._view.modelfield.parent.resource
- res = rpc.session.rpc_exec_auth_try('/object', 'execute', model,
+ res = rpc.execute('object', 'execute', model,
'default_get', [self.attrs['name']])
self._view.modelfield.set(self._view.model,
res.get(self.attrs['name'], False))
diff --git a/tryton/gui/window/view_form/view/form_gtk/many2many.py b/tryton/gui/window/view_form/view/form_gtk/many2many.py
index 070d18dc51..4036f869e9 100644
--- a/tryton/gui/window/view_form/view/form_gtk/many2many.py
+++ b/tryton/gui/window/view_form/view/form_gtk/many2many.py
@@ -57,9 +57,13 @@ class Many2Many(WidgetInterface):
domain = self._view.modelfield.domain_get(self._view.model)
context = self._view.modelfield.context_get(self._view.model)
- ids = rpc.session.rpc_exec_auth('/object', 'execute',
- self.attrs['relation'], 'name_search',
- self.wid_text.get_text(), domain, 'ilike', context)
+ try:
+ ids = rpc.execute('object', 'execute',
+ self.attrs['relation'], 'name_search',
+ self.wid_text.get_text(), domain, 'ilike', context)
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ return False
ids = [x[0] for x in ids]
if len(ids) != 1:
win = WinSearch(self.attrs['relation'], sel_multi=True, ids=ids,
diff --git a/tryton/gui/window/view_form/view/form_gtk/many2one.py b/tryton/gui/window/view_form/view/form_gtk/many2one.py
index a923440d0d..24e61fd10f 100644
--- a/tryton/gui/window/view_form/view/form_gtk/many2one.py
+++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py
@@ -145,8 +145,13 @@ class Many2One(WidgetInterface):
self.completion = gtk.EntryCompletion()
self.liststore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
if attrs.get('completion', False):
- ids = rpc.session.rpc_exec_auth('/object', 'execute',
- self.attrs['relation'], 'name_search', '', [], 'ilike', {})
+ try:
+ ids = rpc.execute('object', 'execute',
+ self.attrs['relation'], 'name_search', '', [],
+ 'ilike', {})
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ ids = []
if ids:
self.load_completion(ids)
@@ -180,9 +185,13 @@ class Many2One(WidgetInterface):
name = model[iter][1]
domain = self._view.modelfield.domain_get(self._view.model)
context = self._view.modelfield.context_get(self._view.model)
- ids = rpc.session.rpc_exec_auth('/object', 'execute',
- self.attrs['relation'], 'name_search', name, domain, 'ilike',
- context)
+ try:
+ ids = rpc.execute('object', 'execute',
+ self.attrs['relation'], 'name_search', name, domain, 'ilike',
+ context)
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ return False
if len(ids)==1:
self._view.modelfield.set_client(self._view.model, ids[0])
self.display(self._view.model, self._view.modelfield)
@@ -192,14 +201,16 @@ class Many2One(WidgetInterface):
domain=domain, window=self._window)
ids = win.go()
if ids:
- name = rpc.session.rpc_exec_auth('/object', 'execute',
- self.attrs['relation'], 'name_get', [ids[0]],
- rpc.session.context)[0]
+ try:
+ name = rpc.execute('object', 'execute',
+ self.attrs['relation'], 'name_get', [ids[0]],
+ rpc.CONTEXT)[0]
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ return False
self._view.modelfield.set_client(self._view.model, name)
return True
-
-
def _readonly_set(self, value):
self._readonly = value
self.wid_text.set_editable(not value)
@@ -221,9 +232,15 @@ class Many2One(WidgetInterface):
context = self._view.modelfield.context_get(self._view.model)
self.wid_text.grab_focus()
- ids = rpc.session.rpc_exec_auth('/object', 'execute',
- self.attrs['relation'], 'name_search',
- self.wid_text.get_text(), domain, 'ilike', context)
+ try:
+ ids = rpc.execute('object', 'execute',
+ self.attrs['relation'], 'name_search',
+ self.wid_text.get_text(), domain, 'ilike', context)
+ except Exception, exception:
+ self.focus_out = True
+ rpc.process_exception(exception, self._window)
+ self.changed = True
+ return False
if len(ids)==1:
self._view.modelfield.set_client(self._view.model, ids[0],
force_change=True)
@@ -236,9 +253,15 @@ class Many2One(WidgetInterface):
domain=domain, parent=self._window)
ids = win.run()
if ids:
- name = rpc.session.rpc_exec_auth('/object', 'execute',
- self.attrs['relation'], 'name_get', [ids[0]],
- rpc.session.context)[0]
+ try:
+ name = rpc.execute('object', 'execute',
+ self.attrs['relation'], 'name_get', [ids[0]],
+ rpc.CONTEXT)[0]
+ except Exception, exception:
+ self.focus_out = True
+ rpc.process_exception(exception, self._window)
+ self.changed = True
+ return False
self._view.modelfield.set_client(self._view.model, name,
force_change=True)
self.focus_out = True
@@ -277,9 +300,15 @@ class Many2One(WidgetInterface):
context = self._view.modelfield.context_get(self._view.model)
self.wid_text.grab_focus()
- ids = rpc.session.rpc_exec_auth('/object', 'execute',
- self.attrs['relation'], 'name_search',
- self.wid_text.get_text(), domain, 'ilike', context)
+ try:
+ ids = rpc.execute('object', 'execute',
+ self.attrs['relation'], 'name_search',
+ self.wid_text.get_text(), domain, 'ilike', context)
+ except Exception, exception:
+ self.focus_out = True
+ rpc.process_exception(exception, self._window)
+ self.changed = True
+ return False
if ids and len(ids)==1:
self._view.modelfield.set_client(self._view.model, ids[0],
force_change=True)
@@ -292,9 +321,15 @@ class Many2One(WidgetInterface):
domain=domain, parent=self._window)
ids = win.run()
if ids:
- name = rpc.session.rpc_exec_auth('/object', 'execute',
- self.attrs['relation'], 'name_get', [ids[0]],
- rpc.session.context)[0]
+ try:
+ name = rpc.execute('object', 'execute',
+ self.attrs['relation'], 'name_get', [ids[0]],
+ rpc.CONTEXT)[0]
+ except Exception, exception:
+ self.focus_out = True
+ rpc.process_exception(exception, self._window)
+ self.changed = True
+ return False
self._view.modelfield.set_client(self._view.model, name,
force_change=True)
self.focus_out = True
@@ -349,7 +384,7 @@ class Many2One(WidgetInterface):
value = self._view.modelfield.get(self._view.model)
ir_action_keyword = RPCProxy('ir.action.keyword')
relates = ir_action_keyword.get_keyword('form_relate',
- (self.model_type, 0), rpc.session.context)
+ (self.model_type, 0), rpc.CONTEXT)
menu_entries = []
menu_entries.append((None, None, None))
menu_entries.append((_('Actions'),
diff --git a/tryton/gui/window/view_form/view/form_gtk/one2many.py b/tryton/gui/window/view_form/view/form_gtk/one2many.py
index 9e2c2aa8c3..8c9c7348e9 100644
--- a/tryton/gui/window/view_form/view/form_gtk/one2many.py
+++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py
@@ -56,6 +56,7 @@ class Dialog(object):
viewport.set_shadow_type(gtk.SHADOW_NONE)
scroll.add(viewport)
+ self.dia.show_all()
self.screen = Screen(model_name, view_type=[], parent=parent,
window=self.dia)
self.screen.models._context.update(model_ctx)
@@ -74,8 +75,8 @@ class Dialog(object):
viewport.add(self.screen.widget)
width, height = self.screen.screen_container.size_get()
viewport.set_size_request(width, height + 30)
- self.dia.show_all()
self.screen.display()
+ self.dia.show_all()
def new(self):
model = self.screen.new(context=self.default_get_ctx)
diff --git a/tryton/gui/window/view_form/view/form_gtk/parser.py b/tryton/gui/window/view_form/view/form_gtk/parser.py
index 01bc80d4dc..7b785f2623 100644
--- a/tryton/gui/window/view_form/view/form_gtk/parser.py
+++ b/tryton/gui/window/view_form/view/form_gtk/parser.py
@@ -41,16 +41,22 @@ class Button(object):
common.sur(self.attrs['confirm']):
button_type = self.attrs.get('type', 'workflow')
if button_type == 'workflow':
- rpc.session.rpc_exec_auth('/object', 'exec_workflow',
- self.form.screen.name,
- self.attrs['name'], obj_id)
+ try:
+ rpc.execute('object', 'exec_workflow',
+ self.form.screen.name,
+ self.attrs['name'], obj_id)
+ except Exception, exception:
+ rpc.process_exception(exception, self.form.window)
elif button_type == 'object':
if not obj_id:
return
- rpc.session.rpc_exec_auth('/object', 'execute',
- self.form.screen.name,
- self.attrs['name'],
- [obj_id], model.context_get())
+ try:
+ rpc.execute('object', 'execute',
+ self.form.screen.name,
+ self.attrs['name'],
+ [obj_id], model.context_get())
+ except Exception, exception:
+ rpc.process_exception(exception, self.form.window)
elif button_type == 'action':
Action.execute(int(self.attrs['name']), {
'model': self.form.screen.name,
@@ -446,17 +452,25 @@ class ParserForm(ParserInterface):
return False
obj_id = self.screen.current_model.save(force_reload=False)
- lang_ids = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.lang',
- 'search', [('translatable','=','1')])
+ try:
+ lang_ids = rpc.execute('object', 'execute', 'ir.lang',
+ 'search', [('translatable','=','1')])
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
if not lang_ids:
common.message(_('No other language available!'),
parent=self.window)
return False
- langs = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.lang',
- 'read', lang_ids, ['code', 'name'])
+ try:
+ langs = rpc.execute('object', 'execute', 'ir.lang',
+ 'read', lang_ids, ['code', 'name'])
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
- code = rpc.session.context.get('language', 'en_US')
+ code = rpc.CONTEXT.get('language', 'en_US')
#change 'en' to false for context
def adapt_context(val):
@@ -538,10 +552,14 @@ class ParserForm(ParserInterface):
table.set_border_width(1)
i = 0
for lang in langs:
- context = copy.copy(rpc.session.context)
+ context = copy.copy(rpc.CONTEXT)
context['language'] = adapt_context(lang['code'])
- val = rpc.session.rpc_exec_auth('/object', 'execute', model,
- 'read', [obj_id], [name], context)
+ try:
+ val = rpc.execute('/object', 'execute', model,
+ 'read', [obj_id], [name], context)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
val = val[0]
if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL:
label = gtk.Label(_(':') + lang['name'])
@@ -586,11 +604,14 @@ class ParserForm(ParserInterface):
#update form field
if new_val['code'] == code:
value_set(widget_entry, new_val['value'])
- context = copy.copy(rpc.session.context)
+ context = copy.copy(rpc.CONTEXT)
context['language'] = adapt_context(new_val['code'])
- rpc.session.rpc_exec_auth('/object', 'execute', model,
- 'write', [obj_id], {str(name): new_val['value']},
- context)
+ args = ('object', 'execute', model, 'write', [obj_id],
+ {str(name): new_val['value']}, context)
+ try:
+ rpc.execute(*args)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window, *args)
if response == gtk.RESPONSE_CANCEL:
self.window.present()
win.destroy()
@@ -604,7 +625,7 @@ from calendar import Calendar, DateTime
from float import Float
from integer import Integer
from selection import Selection
-from char import Char
+from char import Char, Sha
from float_time import FloatTime
from checkbox import CheckBox
from reference import Reference
@@ -625,6 +646,7 @@ WIDGETS_TYPE = {
'integer': (Integer, 1, False, False),
'selection': (Selection, 1, False, False),
'char': (Char, 1, False, False),
+ 'sha': (Sha, 1, False, False),
'float_time': (FloatTime, 1, False, False),
'boolean': (CheckBox, 1, False, False),
'reference': (Reference, 1, False, False),
diff --git a/tryton/gui/window/view_form/view/form_gtk/reference.py b/tryton/gui/window/view_form/view/form_gtk/reference.py
index 6bad62fbed..e95993d416 100644
--- a/tryton/gui/window/view_form/view/form_gtk/reference.py
+++ b/tryton/gui/window/view_form/view/form_gtk/reference.py
@@ -75,8 +75,12 @@ class Reference(WidgetInterface):
self._selection2 = {}
selection = attrs.get('selection', [])
if not isinstance(selection, (list, tuple)):
- selection = rpc.session.rpc_exec_auth('/object', 'execute',
- self.model, selection, rpc.session.context)
+ try:
+ selection = rpc.execute('object', 'execute',
+ self.model, selection, rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ selection = []
selection.sort(lambda x, y: cmp(x[1], y[1]))
self.set_popdown(selection)
@@ -148,9 +152,15 @@ class Reference(WidgetInterface):
domain = self._view.modelfield.domain_get(self._view.model)
context = self._view.modelfield.context_get(self._view.model)
- ids = rpc.session.rpc_exec_auth('/object', 'execute', model,
- 'name_search', self.wid_text.get_text(), domain,
- 'ilike', context)
+ try:
+ ids = rpc.execute('object', 'execute', model,
+ 'name_search', self.wid_text.get_text(), domain,
+ 'ilike', context)
+ except Exception, exception:
+ self.focus_out = True
+ self.changed = True
+ rpc.process_exception(exception, self._window)
+ return False
if ids and len(ids) == 1:
obj_id, name = ids[0]
self._view.modelfield.set_client(self._view.model,
@@ -165,9 +175,15 @@ class Reference(WidgetInterface):
domain=domain, parent=self._window)
ids = win.run()
if ids:
- obj_id, name = rpc.session.rpc_exec_auth('/object',
- 'execute', model, 'name_get', [ids[0]],
- rpc.session.context)[0]
+ try:
+ obj_id, name = rpc.execute('object',
+ 'execute', model, 'name_get', [ids[0]],
+ rpc.CONTEXT)[0]
+ except Exception, exception:
+ self.focus_out = True
+ self.changed = True
+ rpc.process_exception(exception, self._window)
+ return False
self._view.modelfield.set_client(self._view.model,
(model, [obj_id, name]))
self.focus_out = True
@@ -232,8 +248,12 @@ class Reference(WidgetInterface):
if model:
child.set_text(self._selection2[model])
if not name and obj_id:
- obj_id, name = RPCProxy(model).name_get(obj_id,
- rpc.session.context)[0]
+ try:
+ obj_id, name = RPCProxy(model).name_get(obj_id,
+ rpc.CONTEXT)[0]
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ name = '???'
self.wid_text.set_text(name)
img.set_from_stock('gtk-open', gtk.ICON_SIZE_BUTTON)
self.but_open.set_image(img)
diff --git a/tryton/gui/window/view_form/view/form_gtk/selection.py b/tryton/gui/window/view_form/view/form_gtk/selection.py
index ff7ba29240..f18a391a91 100644
--- a/tryton/gui/window/view_form/view/form_gtk/selection.py
+++ b/tryton/gui/window/view_form/view/form_gtk/selection.py
@@ -24,13 +24,21 @@ class Selection(WidgetInterface):
self._selection = {}
selection = attrs.get('selection', [])
if 'relation' in attrs:
- selection = rpc.session.rpc_exec_auth('/object', 'execute',
- attrs['relation'], 'name_search', '',
- attrs.get('domain', []), 'ilike', rpc.session.context)
+ try:
+ selection = rpc.execute('object', 'execute',
+ attrs['relation'], 'name_search', '',
+ attrs.get('domain', []), 'ilike', rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ selection = []
else:
if not isinstance(selection, (list, tuple)):
- selection = rpc.session.rpc_exec_auth('/object', 'execute',
- self.model, selection, rpc.session.context)
+ try:
+ selection = rpc.execute('object', 'execute',
+ self.model, selection, rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self._window)
+ selection = []
selection.sort(lambda x, y: cmp(x[1], y[1]))
attrs['selection'] = selection
self.set_popdown(selection)
diff --git a/tryton/gui/window/view_form/view/list.py b/tryton/gui/window/view_form/view/list.py
index bdc2fc4d29..e35131b1b2 100644
--- a/tryton/gui/window/view_form/view/list.py
+++ b/tryton/gui/window/view_form/view/list.py
@@ -168,9 +168,13 @@ class ViewList(ParserView):
if path[1]._type == 'many2one':
value = model[path[1].name].get(model)
ir_action_keyword = RPCProxy('ir.action.keyword')
- relates = ir_action_keyword.get_keyword('form_relate',
- (self.screen.fields[path[1].name]['relation'], 0),
- rpc.session.context)
+ try:
+ relates = ir_action_keyword.get_keyword('form_relate',
+ (self.screen.fields[path[1].name]['relation'], 0),
+ rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False
menu_entries = []
menu_entries.append((None, None, None))
menu_entries.append((_('Actions'),
diff --git a/tryton/gui/window/view_form/view/list_gtk/parser.py b/tryton/gui/window/view_form/view/list_gtk/parser.py
index 4516227709..8cfff82915 100644
--- a/tryton/gui/window/view_form/view/list_gtk/parser.py
+++ b/tryton/gui/window/view_form/view/list_gtk/parser.py
@@ -250,11 +250,11 @@ class Datetime(Date):
if not value:
return ''
date = time.strptime(value, self.server_format)
- if 'timezone' in rpc.session.context:
+ if 'timezone' in rpc.CONTEXT:
try:
import pytz
- lzone = pytz.timezone(rpc.session.context['timezone'])
- szone = pytz.timezone(rpc.session.timezone)
+ lzone = pytz.timezone(rpc.CONTEXT['timezone'])
+ szone = pytz.timezone(rpc.TIMEZONE)
datetime = DT.datetime(date[0], date[1], date[2], date[3],
date[4], date[5], date[6])
sdt = szone.localize(datetime, is_dst=True)
@@ -276,11 +276,11 @@ class Datetime(Date):
date = tuple(datetime)
except:
return False
- if 'timezone' in rpc.session.context:
+ if 'timezone' in rpc.CONTEXT:
try:
import pytz
- lzone = pytz.timezone(rpc.session.context['timezone'])
- szone = pytz.timezone(rpc.session.timezone)
+ lzone = pytz.timezone(rpc.CONTEXT['timezone'])
+ szone = pytz.timezone(rpc.TIMEZONE)
datetime = DT.datetime(date[0], date[1], date[2], date[3],
date[4], date[5], date[6])
ldt = lzone.localize(datetime, is_dst=True)
@@ -336,7 +336,11 @@ class M2O(Char):
domain = model[self.field_name].domain_get(model)
context = model[self.field_name].context_get(model)
- names = rpc_relation.name_search(text, domain, 'ilike', context)
+ try:
+ names = rpc_relation.name_search(text, domain, 'ilike', context)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return '???'
if len(names) != 1:
return self.search_remote(relation, [x[0] for x in names],
domain=domain, context=context)[0]
@@ -355,7 +359,11 @@ class M2O(Char):
else:
rpc_relation = RPCProxy(relation)
- names = rpc_relation.name_search(text, domain, 'ilike', context)
+ try:
+ names = rpc_relation.name_search(text, domain, 'ilike', context)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False, False
if len(names) == 1:
return True, names[0]
searched = self.search_remote(relation, [x[0] for x in names],
@@ -379,7 +387,11 @@ class M2O(Char):
domain=domain)
found = win.go()
if found:
- return rpc_relation.name_get([found[0]], context)[0]
+ try:
+ return rpc_relation.name_get([found[0]], context)[0]
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False, None
else:
return False, None
@@ -417,7 +429,11 @@ class M2M(Char):
rpc_relation = RPCProxy(relation)
domain = model[self.field_name].domain_get(model)
context = model[self.field_name].context_get(model)
- names = rpc_relation.name_search(text, domain, 'ilike', context)
+ try:
+ names = rpc_relation.name_search(text, domain, 'ilike', context)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return []
ids = [x[0] for x in names]
win = WinSearch(relation, sel_multi=True, ids=ids, context=context,
domain=domain)
@@ -434,7 +450,11 @@ class M2M(Char):
if create:
if text and len(text) and text[0] != '(':
domain.append(('name', '=', text))
- ids = rpc_relation.search(domain)
+ try:
+ ids = rpc_relation.search(domain)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return False, None
if ids and len(ids)==1:
return True, ids
else:
@@ -455,13 +475,21 @@ class Selection(Char):
selection_data = gtk.ListStore(str, str)
selection = self.attrs.get('selection', [])
if 'relation' in self.attrs:
- selection = rpc.session.rpc_exec_auth('/object', 'execute',
- self.attrs['relation'], 'name_search', '',
- self.attrs.get('domain', []), 'ilike', rpc.session.context)
+ try:
+ selection = rpc.execute('object', 'execute',
+ self.attrs['relation'], 'name_search', '',
+ self.attrs.get('domain', []), 'ilike', rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ selection = []
else:
if not isinstance(selection, (list, tuple)):
- selection = rpc.session.rpc_exec_auth('/object', 'execute',
- self.model, selection, rpc.session.context)
+ try:
+ selection = rpc.execute('object', 'execute',
+ self.model, selection, rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ selection = []
selection.sort(lambda x, y: cmp(x[1], y[1]))
self.attrs['selection'] = selection
self.selection = selection
diff --git a/tryton/gui/window/view_tree/view_tree.py b/tryton/gui/window/view_tree/view_tree.py
index 828c182915..c278b3dabe 100644
--- a/tryton/gui/window/view_tree/view_tree.py
+++ b/tryton/gui/window/view_tree/view_tree.py
@@ -51,10 +51,10 @@ class ViewTreeModel(gtk.GenericTreeModel, gtk.TreeSortable):
def _read(self, ids, fields):
ctx = {}
- ctx.update(rpc.session.context)
+ ctx.update(rpc.CONTEXT)
ctx.update(self.context)
try:
- res_ids = rpc.session.rpc_exec_auth_try('/object', 'execute',
+ res_ids = rpc.execute('object', 'execute',
self.view['model'], 'read', ids, fields, ctx)
except:
res_ids = []
@@ -81,11 +81,11 @@ class ViewTreeModel(gtk.GenericTreeModel, gtk.TreeSortable):
for obj in res_ids:
if obj[field]:
date = time.strptime(obj[field], DHM_FORMAT)
- if 'timezone' in rpc.session.context:
+ if 'timezone' in rpc.CONTEXT:
try:
import pytz
- lzone = pytz.timezone(rpc.session.context['timezone'])
- szone = pytz.timezone(rpc.session.timezone)
+ lzone = pytz.timezone(rpc.CONTEXT['timezone'])
+ szone = pytz.timezone(rpc.TIMEZONE)
datetime = DT.datetime(date[0], date[1],
date[2], date[3], date[4], date[5],
date[6])
@@ -279,16 +279,21 @@ class ViewTreeModel(gtk.GenericTreeModel, gtk.TreeSortable):
class ViewTree(object):
"View tree"
- def __init__(self, view_info, ids, sel_multi=False,
+ def __init__(self, view_info, ids, window, sel_multi=False,
context=None):
+ self.window = window
self.view = gtk.TreeView()
self.view.set_headers_visible(not CONFIG['client.modepda'])
self.context = {}
- self.context.update(rpc.session.context)
+ self.context.update(rpc.CONTEXT)
if context:
self.context.update(context)
- self.fields = rpc.session.rpc_exec_auth('/object', 'execute',
- view_info['model'], 'fields_get', False, self.context)
+ try:
+ self.fields = rpc.execute('object', 'execute',
+ view_info['model'], 'fields_get', False, self.context)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ raise
parse = Parse(self.fields)
parse.parse(view_info['arch'], self.view)
self.toolbar = parse.toolbar
diff --git a/tryton/gui/window/view_tree/view_tree_sc.py b/tryton/gui/window/view_tree/view_tree_sc.py
index 47c7f21250..4e49d271f6 100644
--- a/tryton/gui/window/view_tree/view_tree_sc.py
+++ b/tryton/gui/window/view_tree/view_tree_sc.py
@@ -9,9 +9,10 @@ _ = gettext.gettext
class ViewTreeSC(object):
- def __init__(self, tree, model):
+ def __init__(self, tree, model, window):
self.model = model
self.tree = tree
+ self.window = window
self.tree.get_selection().set_mode('single')
column = gtk.TreeViewColumn (_('ID'), gtk.CellRendererText(), text=0)
self.tree.append_column(column)
@@ -25,10 +26,14 @@ class ViewTreeSC(object):
def update(self):
store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING)
- user = rpc.session.user
- view_sc = rpc.session.rpc_exec_auth_try('/object', 'execute',
- 'ir.ui.view_sc', 'get_sc', user, self.model,
- rpc.session.context)
+ user = rpc._USER
+ try:
+ view_sc = rpc.execute('object', 'execute',
+ 'ir.ui.view_sc', 'get_sc', user, self.model,
+ rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self.window)
+ return
for shortcut in view_sc:
num = store.append()
store.set(num, 0, shortcut['res_id'], 1, shortcut['name'],
diff --git a/tryton/gui/window/win_export.py b/tryton/gui/window/win_export.py
index 7ef7a358c4..2d150937b1 100644
--- a/tryton/gui/window/win_export.py
+++ b/tryton/gui/window/win_export.py
@@ -74,9 +74,13 @@ class WinExport(object):
self.fields[prefix_node+field] = (st_name,
fields[field].get('relation', False))
if fields[field].get('relation', False) and level>0:
- fields2 = rpc.session.rpc_exec_auth('/object', 'execute',
- fields[field]['relation'], 'fields_get', False,
- rpc.session.context)
+ try:
+ fields2 = rpc.execute('object', 'execute',
+ fields[field]['relation'], 'fields_get', False,
+ rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ continue
model_populate(fields2, prefix_node+field+'/', node,
st_name+'/', level-1)
model_populate(fields)
@@ -148,9 +152,17 @@ class WinExport(object):
def fill_predefwin(self):
ir_export = rpc.RPCProxy('ir.export')
ir_export_line = rpc.RPCProxy('ir.export.line')
- export_ids = ir_export.search([('resource', '=', self.model)])
+ try:
+ export_ids = ir_export.search([('resource', '=', self.model)])
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return
for export in ir_export.read(export_ids):
- fields = ir_export_line.read(export['export_fields'])
+ try:
+ fields = ir_export_line.read(export['export_fields'])
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ continue
self.predef_model.append((
export['id'],
[f['name'] for f in fields],
@@ -171,8 +183,12 @@ class WinExport(object):
field_name = self.model2.get_value(iter, 1)
fields.append(field_name)
iter = self.model2.iter_next(iter)
- new_id = ir_export.create({'name' : name, 'resource' : self.model,
- 'export_fields' : [(0, 0, {'name' : f}) for f in fields]})
+ try:
+ new_id = ir_export.create({'name' : name, 'resource' : self.model,
+ 'export_fields' : [(0, 0, {'name' : f}) for f in fields]})
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return
self.predef_model.append((
new_id,
fields,
@@ -189,7 +205,11 @@ class WinExport(object):
return None
ir_export = rpc.RPCProxy('ir.export')
export_id = model.get_value(i, 0)
- ir_export.unlink(export_id)
+ try:
+ ir_export.unlink(export_id)
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return
for i in range(len(self.predef_model)):
if self.predef_model[i][0] == export_id:
del self.predef_model[i]
@@ -214,7 +234,7 @@ class WinExport(object):
action = self.wid_action.get_active()
self.parent.present()
self.win.destroy()
- result = WinExport.datas_read(self.ids, self.model, fields,
+ result = self.datas_read(self.ids, self.model, fields,
context=self.context)
if action == 0:
@@ -254,12 +274,15 @@ class WinExport(object):
"(%s)" % (exception[0],), self.parent)
return False
- @staticmethod
- def datas_read(ids, model, fields, context=None):
+ def datas_read(self, ids, model, fields, context=None):
if context is None:
context = {}
ctx = context.copy()
- ctx.update(rpc.session.context)
- datas = rpc.session.rpc_exec_auth('/object', 'execute', model,
- 'export_data', ids, fields, ctx)
+ ctx.update(rpc.CONTEXT)
+ try:
+ datas = rpc.execute('object', 'execute', model,
+ 'export_data', ids, fields, ctx)
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return []
return datas
diff --git a/tryton/gui/window/win_import.py b/tryton/gui/window/win_import.py
index f12bd32ec2..a6da4266c0 100644
--- a/tryton/gui/window/win_import.py
+++ b/tryton/gui/window/win_import.py
@@ -74,10 +74,13 @@ class WinImport(object):
self.fields[prefix_node+field] = st_name
self.fields_invert[st_name] = prefix_node+field
if fields[field]['type'] == 'one2many' and level > 0:
- fields2 = rpc.session.rpc_exec_auth('/object',
- 'execute', fields[field]['relation'],
- 'fields_get', False,
- rpc.session.context)
+ try:
+ fields2 = rpc.execute('object',
+ 'execute', fields[field]['relation'],
+ 'fields_get', False, rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ continue
model_populate(fields2, prefix_node+field+'/', node,
st_name+'/', level-1)
model_populate(fields)
@@ -196,11 +199,10 @@ class WinImport(object):
datas.append([x.decode(csv_data['combo']).encode('utf-8') \
for x in line])
try:
- res = rpc.session.rpc_exec_auth('/object', 'execute',
+ res = rpc.execute('object', 'execute',
model, 'import_data', fields, datas)
except Exception, exception:
- common.warning(str(exception), self.parent,
- _('XML-RPC error!'))
+ rpc.process_exception(exception, self.win)
return False
if res[0] >= 0:
common.message(_('Imported %d objects!') % (res[0],), self.parent)
diff --git a/tryton/gui/window/win_search.py b/tryton/gui/window/win_search.py
index 0323c1e252..7fad456d69 100644
--- a/tryton/gui/window/win_search.py
+++ b/tryton/gui/window/win_search.py
@@ -14,7 +14,7 @@ class WinSearch(object):
domain=None, parent=None):
self.domain = domain or []
self.context = context or {}
- self.context.update(rpc.session.context)
+ self.context.update(rpc.CONTEXT)
self.sel_multi = sel_multi
self.parent = parent
@@ -53,8 +53,13 @@ class WinSearch(object):
self.model_name = model
- view_form = rpc.session.rpc_exec_auth('/object', 'execute',
- self.model_name, 'fields_view_get', False, 'tree', self.context)
+ try:
+ view_form = rpc.execute('object', 'execute',
+ self.model_name, 'fields_view_get', False, 'tree',
+ self.context)
+ except Exception, exception:
+ rpc.process_exception(exception, self.parent)
+ raise
self.form = widget_search.Form(view_form['arch'], view_form['fields'],
model, parent=self.win)
@@ -103,9 +108,13 @@ class WinSearch(object):
self.old_limit = limit
value = self.form.value
value += self.domain
- self.ids = rpc.session.rpc_exec_auth_try('/object', 'execute',
- self.model_name, 'search', value, offset, limit, 0,
- rpc.session.context)
+ try:
+ self.ids = rpc.execute('object', 'execute',
+ self.model_name, 'search', value, offset, limit, 0,
+ rpc.CONTEXT)
+ except Exception, exception:
+ rpc.process_exception(exception, self.win)
+ return False
self.reload()
self.old_search = self.form.value
self.win.set_title(self.title_results % len(self.ids))
diff --git a/tryton/gui/window/window.py b/tryton/gui/window/window.py
index 27b9edf17a..39144fb24d 100644
--- a/tryton/gui/window/window.py
+++ b/tryton/gui/window/window.py
@@ -11,7 +11,7 @@ class Window(object):
from tryton.gui import Main
if context is None:
context = {}
- context.update(rpc.session.context)
+ context.update(rpc.CONTEXT)
if view_type == 'form':
from form import Form
diff --git a/tryton/rpc.py b/tryton/rpc.py
index 4ad4a5b0a0..a1d52bfe2a 100644
--- a/tryton/rpc.py
+++ b/tryton/rpc.py
@@ -1,407 +1,182 @@
-import xmlrpclib
-import logging
-import socket
import pysocket
-import common
-from config import CONFIG
-import re
import translate
-import gettext
+from config import CONFIG
import gtk
+import logging
+import common
+import socket
-_ = gettext.gettext
-
+_SOCK = None
+_USER = 0
+_USERNAME = ''
+_PASSWORD = ''
+_DATABASE = ''
+CONTEXT = {}
_VIEW_CACHE = {}
+TIMEZONE = 'utc'
-class RPCException(Exception):
-
- def __init__(self, code, backtrace):
- Exception.__init__(self)
- self.code = code
- self.args = backtrace
- if hasattr(code, 'split'):
- lines = code.split('\n')
-
- self.type = lines[0].split(' -- ')[0]
- self.message = ''
- if len(lines[0].split(' -- ')) > 1:
- self.message = lines[0].split(' -- ')[1]
-
- self.data = '\n'.join(lines[2:])
- else:
- self.type = 'error'
- self.message = backtrace
- self.data = backtrace
-
- self.backtrace = backtrace
-
- logging.getLogger('rpc.exception').warning('CODE %s: %s' % \
- (str(code), self.message))
-
-class GWInter(object):
- __slots__ = ('_url', '_db', '_user', '_passwd', '_sock', '_obj')
-
- def __init__(self, url, database, user, passwd, obj='/object'):
- self._url = url
- self._db = database
- self._user = user
- self._obj = obj
- self._passwd = passwd
-
- def exec_auth(self, method, *args):
- pass
-
- def execute(self, method, *args):
- pass
-
-class XMLRpcGW(GWInter):
- __slots__ = ('_url', '_db', '_user', '_passwd', '_sock', '_obj')
-
- def __init__(self, url, database, user, passwd, obj='/object'):
- GWInter.__init__(self, url, database, user, passwd, obj)
- self._sock = xmlrpclib.ServerProxy(url+obj)
-
- def exec_auth(self, method, *args):
- logging.getLogger('rpc.request').info(str((method, self._db, self._user,
- self._passwd, args)))
- res = self.execute(method, self._user, self._passwd, *args)
- logging.getLogger('rpc.result').debug(str(res))
+def db_list(host, port):
+ global _SOCK
+ if _SOCK:
+ _SOCK.disconnect()
+ _SOCK = None
+ try:
+ _SOCK = pysocket.PySocket()
+ _SOCK.connect(host, port)
+ _SOCK.send(('db', 'list'))
+ res = _SOCK.receive()
return res
+ except:
+ return None
- def __convert(self, result):
- if type(result) == type(u''):
- return result.encode('utf-8')
- elif type(result) == type([]):
- return [self.__convert(x) for x in result]
- elif type(result) == type({}):
- newres = {}
- for i in result.keys():
- newres[i] = self.__convert(result[i])
- return newres
+def db_exec(host, port, method, *args):
+ global _SOCK
+ if _SOCK:
+ _SOCK.disconnect()
+ _SOCK = None
+ _SOCK= pysocket.PySocket()
+ _SOCK.connect(host, port)
+ _SOCK.send(('db', method) + args)
+ res = _SOCK.receive()
+ return res
+
+def login(username, password, host, port, database):
+ global _SOCK, _USER, _USERNAME, _PASSWORD, _DATABASE, _VIEW_CACHE
+ if _SOCK:
+ _SOCK.disconnect()
+ _SOCK = None
+ _USER = 0
+ _USERNAME = ''
+ _PASSWORD = ''
+ _DATABASE = ''
+ _VIEW_CACHE = {}
+ try:
+ _SOCK = pysocket.PySocket()
+ _SOCK.connect(host, port)
+ _SOCK.send(('common', 'login', database, username, password))
+ res = _SOCK.receive()
+ except socket.error:
+ return -1
+ if not res:
+ return -2
+ _USER = res
+ _USERNAME = username
+ _PASSWORD = password
+ _DATABASE = database
+ context_reload()
+ return 1
+
+def logout():
+ global _SOCK, _USER, _USERNAME, _PASSWORD, _DATABASE, _VIEW_CACHE
+ if _SOCK:
+ _SOCK.disconnect()
+ _SOCK = None
+ _USER = 0
+ _USERNAME = ''
+ _PASSWORD = ''
+ _DATABASE = ''
+ _VIEW_CACHE = {}
+
+def context_reload():
+ global CONTEXT, TIMEZONE
+ CONTEXT = {}
+ user = RPCProxy('res.user')
+ lang = RPCProxy('ir.lang')
+ context = user.get_preferences(True, {})
+ for i in context:
+ value = context[i]
+ if value:
+ CONTEXT[i] = value
+ #TODO add direction to get_preferences
+ #if i == 'lang':
+ # translate.setlang(value)
+ # CONFIG['client.lang'] = value
+ # ids = lang.search([('code', '=', value)])
+ # if ids:
+ # lang = lang.read(ids[0], ['direction'])
+ # if lang and 'direction' in lang:
+ # if lang['direction'] == 'rtl':
+ # gtk.widget_set_default_direction(gtk.TEXT_DIR_RTL)
+ # else:
+ # gtk.widget_set_default_direction(gtk.TEXT_DIR_LTR)
+ if i == 'timezone':
+ TIMEZONE = execute('common', 'timezone_get')
+
+def execute(obj, method, *args):
+ global _SOCK
+ if not _SOCK:
+ raise Exception('Not logged!')
+ logging.getLogger('rpc.request').info(str((obj, method, args)))
+ key = False
+ if len(args) >= 7 and args[3] == 'fields_view_get':
+ key = str(args)
+ if key in _VIEW_CACHE and _VIEW_CACHE[key][0]:
+ args = args[:]
+ args = args + (_VIEW_CACHE[key][0],)
+ try:
+ _SOCK.send((obj, method, _DATABASE, _USER, _PASSWORD) + args)
+ result = _SOCK.receive()
+ except socket.error:
+ _SOCK.reconnect()
+ _SOCK.send((obj, method, _DATABASE, _USER, _PASSWORD) + args)
+ result = _SOCK.receive()
+ if key:
+ if result is True and key in _VIEW_CACHE:
+ result = _VIEW_CACHE[key][1]
else:
- return result
+ _VIEW_CACHE[key] = (result['md5'], result)
+ return result
- def execute(self, method, *args):
- key = False
- if len(args) >= 7 and args[3] == 'fields_view_get':
- key = str(args)
- if key in _VIEW_CACHE and _VIEW_CACHE[key][0]:
- args = args[:]
- args = args + (_VIEW_CACHE[key][0],)
- result = getattr(self._sock, method)(self._db, *args)
- if key:
- if result is True and key in _VIEW_CACHE:
- result = _VIEW_CACHE[key][1]
- else:
- _VIEW_CACHE[key] = (result['md5'], result)
- return self.__convert(result)
-
-class PySocketGW(GWInter):
- __slots__ = ('_url', '_db', '_user', '_passwd', '_sock', '_obj')
-
- def __init__(self, url, database, user, passwd, obj='/object'):
- GWInter.__init__(self, url, database, user, passwd, obj)
- self._obj = obj[1:]
-
- def exec_auth(self, method, *args):
- logging.getLogger('rpc.request').info(str((method, self._db, self._user,
- self._passwd, args)))
- res = self.execute(method, self._user, self._passwd, *args)
- logging.getLogger('rpc.result').debug(str(res))
- return res
-
- def execute(self, method, *args):
- key = False
- if len(args) >= 7 and args[3] == 'fields_view_get':
- key = str(args)
- if key in _VIEW_CACHE and _VIEW_CACHE[key][0]:
- args = args[:]
- args = args + (_VIEW_CACHE[key][0],)
- try:
- self._sock.send((self._obj, method, self._db)+args)
- result = self._sock.receive()
- except:
- self._sock.reconnect()
- self._sock.send((self._obj, method, self._db)+args)
- result = self._sock.receive()
- if key:
- if result is True and key in _VIEW_CACHE:
- result = _VIEW_CACHE[key][1]
- else:
- _VIEW_CACHE[key] = (result['md5'], result)
- return result
-
-
-class RPCSession(object):
- __slots__ = ('_open', '_url', 'user', 'uname', '_passwd', '_gw', 'database',
- 'context', 'timezone', '_sock')
- def __init__(self):
- self._open = False
- self._url = None
- self._passwd = None
- self.user = None
- self.context = {}
- self.uname = None
- self._gw = None
- self.database = None
- self.timezone = 'utc'
- self._sock = None
-
- def rpc_exec(self, obj, method, *args):
- try:
- sock = self._gw(self._url, self.database, self.user,
- self._passwd, obj)
- return sock.execute(method, *args)
- except socket.error, exception:
- from gui import Main
- common.error(_('Connection refused !'), str(exception),
- Main.get_main().window)
- raise RPCException(69, _('Connection refused!'))
- except xmlrpclib.Fault, exception:
- raise RPCException(exception.faultCode, exception.faultString)
-
- def rpc_exec_auth_try(self, obj, method, *args):
- if self._open:
- sock = self._gw(self._url, self.database, self.user,
- self._passwd, obj)
- return sock.exec_auth(method, *args)
- else:
- raise RPCException(1, 'not logged')
-
- def rpc_exec_auth_wo(self, obj, method, *args):
- try:
- sock = self._gw(self._url, self.database, self.user,
- self._passwd, obj)
- return sock.exec_auth(method, *args)
- except xmlrpclib.Fault, exception:
- rcp_exception = RPCException(exception.faultCode,
- exception.faultString)
- except pysocket.PySocketException, exception:
- rpc_exception = RPCException(exception.faultCode,
- exception.faultString)
- if rpc_exception.code in ('warning', 'UserError'):
- from gui import Main
- common.warning(rcp_exception.data, Main.get_main().window,
- rpc_exception.message)
- return None
- raise
-
- def _process_exception(self, exception, obj, method, *args):
- rpc_exception = RPCException(exception.faultCode,
- exception.faultString)
- if rpc_exception.type in ('warning','UserError'):
- if rpc_exception.message in ('ConcurrencyException') \
- and len(args) > 4:
- if concurrency(args[0], args[2][0], args[4]):
- if 'read_delta' in args[4]:
- del args[4]['read_delta']
- return self.rpc_exec_auth(obj, method, *args)
- else:
- from gui import Main
- common.warning(rpc_exception.data, Main.get_main().window,
- rpc_exception.message)
- else:
- from gui import Main
- common.error(_('Application Error'), exception.faultCode,
- Main.get_main().window, exception.faultString)
-
- def rpc_exec_auth(self, obj, method, *args):
- if self._open:
- try:
- sock = self._gw(self._url, self.database, self.user,
- self._passwd, obj)
- return sock.exec_auth(method, *args)
- except socket.error, exception:
- from gui import Main
- common.error(_('Connection refused !'), str(exception),
- Main.get_main().window)
- raise RPCException(69, 'Connection refused!')
- except xmlrpclib.Fault, exception:
- self._process_exception(exception, obj, method, args)
- except pysocket.PySocketException, exception:
- self._process_exception(exception, obj, method, args)
- except Exception, exception:
- from gui import Main
- common.error(_('Application Error'), str(exception),
- Main.get_main().window)
- else:
- raise RPCException(1, 'not logged')
-
- def login(self, uname, passwd, url, port, protocol, database):
- _protocol = protocol
- if _protocol == 'http://' or _protocol == 'https://':
- _url = _protocol + url+':'+str(port)+'/xmlrpc'
- _sock = xmlrpclib.ServerProxy(_url+'/common')
- self._gw = XMLRpcGW
- try:
- res = _sock.login(database or '', uname or '', passwd or '')
- except socket.error:
- return -1
- if not res:
- self._open = False
- self.user = False
- return -2
- else:
- _url = _protocol+url+':'+str(port)
- try:
- if self._sock:
- self._sock.disconnect()
- self._sock = pysocket.PySocket()
- self._sock.connect(url, int(port))
- self._gw = PySocketGW
- self._gw._sock = self._sock
- self._sock.send(('common', 'login', database or '', uname or '',
- passwd or ''))
- res = self._sock.receive()
- except socket.error:
- return -1
- if not res:
- self._open = False
- self.user = False
- return -2
- self._url = _url
- self._open = True
- self.user = res
- self.uname = uname
- self._passwd = passwd
- self.database = database
-
- self._gw(self._url, self.database, self.user, self._passwd)
- self.context_reload()
- return 1
-
- def list_db(self, url):
- match = re.match('^(http[s]?://|socket://)([\w:.\-]+):(\d{1,5})$',
- url or '')
- if not match:
- return -1
- if match.group(1) == 'http://' or match.group(1) == 'https://':
- sock = xmlrpclib.ServerProxy(url + '/xmlrpc/db')
- try:
- return sock.list()
- except:
- return -1
- else:
- try:
- if self._sock:
- self._sock.disconnect()
- self._sock = pysocket.PySocket()
- self._sock.connect(match.group(2), int(match.group(3)))
- self._sock.send(('db', 'list'))
- res = self._sock.receive()
- return res
- except:
- return -1
-
- def db_exec_no_except(self, url, method, *args):
- match = re.match('^(http[s]?://|socket://)([\w:.\-]+):(\d{1,5})$',
- url or '')
- if match.group(1) == 'http://' or match.group(1) == 'https://':
- sock = xmlrpclib.ServerProxy(url + '/xmlrpc/db')
- return getattr(sock, method)(*args)
- else:
- if self._sock:
- self._sock.disconnect()
- self._sock = pysocket.PySocket()
- self._sock.connect(match.group(2), int(match.group(3)))
- self._sock.send(('db', method)+args)
- res = self._sock.receive()
- return res
-
- def db_exec(self, url, method, *args):
- res = False
- try:
- res = self.db_exec_no_except(url, method, *args)
- except socket.error:
- from gui import Main
- common.warning(_('Could not contact server!'),
- Main.get_main().window)
- except xmlrpclib.Fault, exception:
- if exception.faultString == 'AccessDenied:None' \
- or str(exception) == 'AccessDenied':
- from gui import Main
- common.warning(_('Bad database administrator password!'),
- Main.get_main().window)
- except pysocket.PySocketException, exception:
- if exception.faultString == 'AccessDenied:None' \
- or str(exception) == 'AccessDenied':
- from gui import Main
- common.warning(_('Bad database administrator password!'),
- Main.get_main().window)
- return res
-
- def context_reload(self):
- self.context = {}
- self.timezone = 'utc'
- user = RPCProxy('res.user')
- lang = RPCProxy('ir.lang')
- context = user.get_preferences(True, {})
- for name in context:
- value = context[name]
- if value:
- self.context[name] = value
- if name == 'lang':
- translate.setlang(value)
- CONFIG['client.lang'] = value
- ids = lang.search([('code', '=', value)])
- if ids:
- lang = lang.read(ids[0], ['direction'])
- if lang and 'direction' in lang:
- if lang['direction'] == 'rtl':
- gtk.widget_set_default_direction(gtk.TEXT_DIR_RTL)
- else:
- gtk.widget_set_default_direction(gtk.TEXT_DIR_LTR)
- elif name == 'timezone':
- self.timezone = self.rpc_exec_auth('/common', 'timezone_get')
+def process_exception(exception, parent, obj='', method='', *args):
+ global _USERNAME, _DATABASE
+ type = 'error'
+ data = str(exception.args[0])
+ description = data
+ details = str(exception.args[1])
+ if hasattr(data, 'split'):
+ lines = data.split('\n')
+ type = lines[0].split(' -- ')[0]
+ description = ''
+ if len(lines[0].split(' -- ')) > 1:
+ description = lines[0].split(' -- ')[1]
+ if len(lines) > 2:
+ details = '\n'.join(lines[2:])
+ if type == 'warning':
+ if description == 'ConcurrencyException' \
+ and len(args) > 4:
+ if concurrency(args[0], args[2][0], args[4], parent):
+ if 'read_delta' in args[4]:
+ del args[4]['read_delta']
try:
- import pytz
- except:
- from gui import Main
- common.warning(_('Could not find pytz library !\n' \
- 'The timezone functionality will be disable.'),
- Main.get_main().window)
-
- def logged(self):
- return self._open
-
- def logout(self):
- if self._open:
- self._open = False
- self.uname = None
- self.user = None
- self._passwd = None
+ return execute(obj, method, *args)
+ except Exception, exception:
+ return process_exception(exception, parent, obj,
+ method, *args)
else:
- pass
- if self._sock:
- self._sock.disconnect()
- self._sock = None
- self._gw = None
-
-SESSION = RPCSession()
-session = SESSION
+ common.warning(details, parent, description)
+ else:
+ common.error(type, description, parent, details)
class RPCProxy(object):
- def __init__(self, resource):
- self.resource = resource
+ def __init__(self, name):
+ self.name = name
self.__attrs = {}
- def __getattr__(self, name):
- if not name in self.__attrs:
- self.__attrs[name] = RPCFunction(self.resource, name)
- return self.__attrs[name]
-
+ def __getattr__(self, attr):
+ if attr not in self.__attrs:
+ self.__attrs[attr] = RPCFunction(self.name, attr)
+ return self.__attrs[attr]
class RPCFunction(object):
- def __init__(self, resource, func_name):
- self.object = resource
+ def __init__(self, name, func_name):
+ self.name = name
self.func = func_name
def __call__(self, *args):
- return SESSION.rpc_exec_auth('/object', 'execute', self.object,
- self.func, *args)
+ return execute('object', 'execute', self.name, self.func, *args)
def concurrency(resource, obj_id, context, parent):
dia = glade.XML(GLADE, 'dialog_concurrency_exception', gettext.textdomain())
@@ -421,5 +196,3 @@ def concurrency(resource, obj_id, context, parent):
Window.create(False, resource, obj_id, [], 'form', None, context,
'form,tree')
return False
-
-
diff --git a/tryton/wizard/main.py b/tryton/wizard/main.py
index 075f06ae2a..82d6592c69 100644
--- a/tryton/wizard/main.py
+++ b/tryton/wizard/main.py
@@ -80,7 +80,11 @@ class Wizard(object):
from tryton.action import Action
if not 'form' in datas:
datas['form'] = {}
- wiz_id = rpc.session.rpc_exec_auth('/wizard', 'create', action)
+ try:
+ wiz_id = rpc.execute('wizard', 'create', action)
+ except Exception, exception:
+ rpc.process_exception(exception, parent)
+ return
dia = None
while state != 'end':
wizardprogress = WizardProgress(wiz_id, state, datas,
@@ -130,7 +134,10 @@ class Wizard(object):
if dia:
dia.destroy()
dia = None
- rpc.session.rpc_exec_auth('/wizard', 'delete', wiz_id)
+ try:
+ rpc.execute('wizard', 'delete', wiz_id)
+ except:
+ pass
class WizardProgress(object):
@@ -148,10 +155,10 @@ class WizardProgress(object):
def run(self):
def start(wiz_id, datas, state, context):
- ctx = rpc.session.context.copy()
+ ctx = rpc.CONTEXT.copy()
ctx.update(context)
try:
- self.res = rpc.session.rpc_exec_auth_try('/wizard',
+ self.res = rpc.execute('wizard',
'execute', wiz_id, datas, state, ctx)
except Exception, exception:
self.error = True
@@ -204,32 +211,5 @@ class WizardProgress(object):
win.destroy()
gtk.main_iteration()
if self.exception:
- import xmlrpclib
- import socket
- from tryton.pysocket import PySocketException
- from tryton.rpc import RPCException
- try:
- raise self.exception
- except socket.error, exception:
- common.error(_('Connection refused !'), str(exception),
- self.parent, str(exception))
- except xmlrpclib.Fault, err:
- rpc_exception = RPCException(err.faultCode, err.faultString)
- if rpc_exception.type in ('warning', 'UserError'):
- common.warning(rpc_exception.data, self.parent,
- rpc_exception.message)
- else:
- common.error(_('Application Error'), err.faultCode,
- self.parent, err.faultString)
- except PySocketException, err:
- rpc_exception = RPCException(err.faultCode, err.faultString)
- if rpc_exception.type in ('warning', 'UserError'):
- common.warning(rpc_exception.data, self.parent,
- rpc_exception.message)
- else:
- common.error(_('Application Error'), err.faultCode,
- self.parent, err.faultString)
- except Exception, exception:
- common.error(_('Application Error'), _('View details'),
- self.parent, str(exception))
+ rpc.process_exception(self.exception, self.parent)
return self.res