Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
odoo-somconnexio-python-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Som Connexió
Odoo
odoo-somconnexio-python-client
Commits
fa8eed0a
Commit
fa8eed0a
authored
2 years ago
by
Daniel Palomar
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
36a4f2ca
No related branches found
No related tags found
1 merge request
!64
Feature/contract catalog pack pagination
Pipeline
#24233
failed
2 years ago
Stage: style
Stage: test
Stage: package
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
odoo_somconnexio_python_client/resources/contract.py
+10
-24
10 additions, 24 deletions
odoo_somconnexio_python_client/resources/contract.py
odoo_somconnexio_python_client/resources/odoo_paging.py
+24
-5
24 additions, 5 deletions
odoo_somconnexio_python_client/resources/odoo_paging.py
with
34 additions
and
29 deletions
odoo_somconnexio_python_client/resources/contract.py
+
10
−
24
View file @
fa8eed0a
from
odoo_somconnexio_python_client.client
import
Client
from
odoo_somconnexio_python_client.client
import
Client
from
odoo_somconnexio_python_client.resources.odoo_paging
import
Paging
from
odoo_somconnexio_python_client.resources.odoo_paging
import
Paging
from
..exceptions
import
(
from
..exceptions
import
ResourceNotFound
InvalidSortOrder
,
NotNumericLimit
,
NotNumericOffset
,
ResourceNotFound
,
)
class
PagingContracts
:
class
PagingContracts
:
...
@@ -79,24 +74,15 @@ class Contract:
...
@@ -79,24 +74,15 @@ class Contract:
:return: Contracts object if exists and controls params to pagination
:return: Contracts object if exists and controls params to pagination
"""
"""
params
=
{
paging
=
Paging
(
"
customer_ref
"
:
customer_ref
,
customer_ref
=
customer_ref
,
}
limit
=
limit
,
offset
=
limit
,
if
not
type
(
limit
)
==
int
:
sortOrder
=
limit
,
raise
NotNumericLimit
(
limit
=
limit
)
)
params
[
"
limit
"
]
=
limit
paging
.
validate_pagintion
()
params
=
{
"
customer_ref
"
:
customer_ref
}
if
not
type
(
offset
)
==
int
:
params
.
update
(
paging
.
__dict__
)
raise
NotNumericOffset
(
offset
=
offset
)
params
[
"
offset
"
]
=
offset
if
sortBy
:
params
[
"
sortBy
"
]
=
sortBy
if
sortOrder
:
if
sortOrder
not
in
[
"
DESCENDING
"
,
"
ASCENDING
"
]:
raise
InvalidSortOrder
params
[
"
sortOrder
"
]
=
sortOrder
return
cls
.
_get
(
return
cls
.
_get
(
params
=
params
,
params
=
params
,
...
...
This diff is collapsed.
Click to expand it.
odoo_somconnexio_python_client/resources/odoo_paging.py
+
24
−
5
View file @
fa8eed0a
from
..exceptions
import
(
InvalidSortOrder
,
NotNumericLimit
,
NotNumericOffset
,
ResourceNotFound
,
)
class
Paging
:
class
Paging
:
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
self
.
limit
=
kwargs
.
get
(
"
limit
"
)
self
.
limit
=
kwargs
.
get
(
"
limit
"
,
10
)
self
.
total_number_records
=
kwargs
.
get
(
"
totalNumberOfRecords
"
)
self
.
offset
=
kwargs
.
get
(
"
offset
"
,
0
)
self
.
offset
=
kwargs
.
get
(
"
offset
"
)
self
.
sort_by
=
kwargs
.
get
(
"
sortBy
"
,
"
id
"
)
self
.
sort_by
=
kwargs
.
get
(
"
sortBy
"
)
self
.
sort_order
=
kwargs
.
get
(
"
sortOrder
"
,
"
DESCENDING
"
)
self
.
sort_order
=
kwargs
.
get
(
"
sortOrder
"
)
try
:
self
.
total_number_records
=
kwargs
[
"
totalNumberOfRecords
"
]
except
KeyError
:
pass
def
validate_pagintion
(
self
):
if
not
type
(
self
.
limit
)
==
int
:
raise
NotNumericLimit
(
limit
=
self
.
limit
)
if
not
type
(
self
.
offset
)
==
int
:
raise
NotNumericOffset
(
offset
=
self
.
offset
)
if
self
.
sortOrder
not
in
[
"
DESCENDING
"
,
"
ASCENDING
"
]:
raise
InvalidSortOrder
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