Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Odoo scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo scripts
Commits
161317f2
Commit
161317f2
authored
3 years ago
by
Vincent Hatakeyama
Browse files
Options
Downloads
Patches
Plain Diff
new method to ease developing scripts
parent
5bf563e0
No related branches found
No related tags found
1 merge request
!64
Topic/default/odoo connect
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
NEWS.rst
+5
-0
5 additions, 0 deletions
NEWS.rst
odoo_scripts/__init__.py
+1
-1
1 addition, 1 deletion
odoo_scripts/__init__.py
odoo_scripts/odoo.py
+18
-2
18 additions, 2 deletions
odoo_scripts/odoo.py
with
24 additions
and
3 deletions
NEWS.rst
+
5
−
0
View file @
161317f2
...
@@ -2,6 +2,11 @@
...
@@ -2,6 +2,11 @@
History
History
=======
=======
13.1.0
------
Add a handy method in odoo.py when writing scripts.
13.0.0
13.0.0
------
------
...
...
This diff is collapsed.
Click to expand it.
odoo_scripts/__init__.py
+
1
−
1
View file @
161317f2
...
@@ -2,5 +2,5 @@
...
@@ -2,5 +2,5 @@
__author__
=
"
XCG Consulting
"
__author__
=
"
XCG Consulting
"
# expose some useful functions
# expose some useful functions
from
.odoo
import
odoo_connect_parser
,
odoo_login
# noqa: F401
from
.odoo
import
odoo_connect
,
odoo_connect_parser
,
odoo_login
# noqa: F401
from
.parsing
import
logging_from_verbose
# noqa: F401
from
.parsing
import
logging_from_verbose
# noqa: F401
This diff is collapsed.
Click to expand it.
odoo_scripts/odoo.py
+
18
−
2
View file @
161317f2
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
argparse
import
argparse
import
getpass
import
getpass
import
logging
import
logging
from
typing
import
Optional
from
typing
import
Optional
,
Tuple
import
odoorpc
import
odoorpc
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
port
:
int
,
port
:
int
,
protocol
:
str
,
protocol
:
str
,
timeout
:
int
,
timeout
:
int
,
):
)
->
Tuple
[
odoorpc
.
ODOO
,
Optional
[
int
]]
:
_logger
.
info
(
_logger
.
info
(
"
Connecting to Odoo on <%s://%s:%s> (%s DB)
"
,
"
Connecting to Odoo on <%s://%s:%s> (%s DB)
"
,
protocol
,
protocol
,
...
@@ -78,3 +78,19 @@
...
@@ -78,3 +78,19 @@
"
-d
"
,
"
--database
"
,
help
=
"
Odoo database
"
,
required
=
True
"
-d
"
,
"
--database
"
,
help
=
"
Odoo database
"
,
required
=
True
)
)
return
parser
return
parser
def
odoo_connect
(
namespace
:
argparse
.
Namespace
,
)
->
Tuple
[
odoorpc
.
ODOO
,
Optional
[
int
]]:
"""
Return a connection and session id obtained from a namespace obtained
from parsing :func:odoo_connect_parser.
"""
return
odoo_login
(
login
=
namespace
.
login
,
password
=
namespace
.
password
,
port
=
namespace
.
port
,
host
=
namespace
.
host
,
protocol
=
namespace
.
protocol
,
timeout
=
namespace
.
timeout
,
database
=
namespace
.
database
,
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment