Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dwsproject
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dws
dwsproject
Commits
efd13e07
Commit
efd13e07
authored
Sep 15, 2025
by
马丽华
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jzjx_project' into 'master'
Jzjx project See merge request
!26
parents
034ca17e
260a1d01
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
25 deletions
+60
-25
roke_product_income_expense/controller/main.py
+60
-25
No files found.
roke_product_income_expense/controller/main.py
View file @
efd13e07
...
...
@@ -52,43 +52,78 @@ class ProductIncomeExpenseIframe(http.Controller):
@http.route
(
"/roke/product/product_income_expense/get"
,
type
=
"json"
,
auth
=
'none'
,
cors
=
'*'
,
csrf
=
False
)
def
product_income_expense_get_list
(
self
):
_self
=
http
.
request
limit
=
_self
.
jsonrequest
.
get
(
"limit"
,
20
)
page
=
_self
.
jsonrequest
.
get
(
"page"
,
1
)
limit
=
int
(
_self
.
jsonrequest
.
get
(
"limit"
,
20
)
)
page
=
int
(
_self
.
jsonrequest
.
get
(
"page"
,
1
)
)
start_date
=
_self
.
jsonrequest
.
get
(
"start_date"
,
""
)
end_date
=
_self
.
jsonrequest
.
get
(
"end_date"
,
""
)
type_str
=
_self
.
jsonrequest
.
get
(
"type_str"
,
False
)
# income收入/expenditure支出
machinery_type
=
_self
.
jsonrequest
.
get
(
"machinery_type"
,
False
)
customer
=
_self
.
jsonrequest
.
get
(
"customer"
,
False
)
abstract
=
_self
.
jsonrequest
.
get
(
"abstract"
,
False
)
domain
=
[]
# 拼接 SQL 条件
where_clauses
=
[
"1=1"
]
params
=
[]
if
start_date
and
end_date
:
domain
.
append
((
"business_date"
,
">="
,
start_date
))
domain
.
append
((
"business_date"
,
"<="
,
end_date
))
if
type_str
:
domain
.
append
((
type_str
,
">"
,
0
))
where_clauses
.
append
(
"business_date >=
%
s"
)
where_clauses
.
append
(
"business_date <=
%
s"
)
params
.
extend
([
start_date
,
end_date
])
if
type_str
:
# income 或 expenditure
where_clauses
.
append
(
f
"{type_str} > 0"
)
if
machinery_type
:
domain
.
append
((
"machinery_type"
,
"="
,
machinery_type
))
where_clauses
.
append
(
"machinery_type =
%
s"
)
params
.
append
(
machinery_type
)
if
customer
:
domain
.
append
((
"customer"
,
"ilike"
,
customer
))
where_clauses
.
append
(
"customer ILIKE
%
s"
)
params
.
append
(
"
%%%
s
%%
"
%
customer
)
if
abstract
:
domain
.
append
((
"abstract"
,
"ilike"
,
abstract
))
data_list
=
_self
.
env
[
"roke.product.income.expense"
]
.
sudo
()
.
search
(
domain
,
limit
=
limit
,
offset
=
(
page
-
1
)
*
limit
,
order
=
"business_date desc, create_date desc"
)
count
=
_self
.
env
[
"roke.product.income.expense"
]
.
sudo
()
.
search_count
(
domain
)
where_clauses
.
append
(
"abstract ILIKE
%
s"
)
params
.
append
(
"
%%%
s
%%
"
%
abstract
)
where_sql
=
" AND "
.
join
(
where_clauses
)
# 查询数据
offset
=
(
page
-
1
)
*
limit
sql
=
f
"""
SELECT id, business_date, abstract, customer, income, expenditure, balance, machinery_type, create_uid, create_date
FROM roke_product_income_expense
WHERE {where_sql}
ORDER BY business_date DESC, create_date DESC
LIMIT
%
s OFFSET
%
s
"""
params
.
extend
([
limit
,
offset
])
_self
.
env
.
cr
.
execute
(
sql
,
params
)
rows
=
_self
.
env
.
cr
.
dictfetchall
()
# 查询总数
sql_count
=
f
"SELECT COUNT(*) FROM roke_product_income_expense WHERE {where_sql}"
_self
.
env
.
cr
.
execute
(
sql_count
,
params
[:
-
2
])
# 去掉 limit 和 offset
count
=
_self
.
env
.
cr
.
fetchone
()[
0
]
data
=
[]
for
v
in
data_list
:
for
v
in
rows
:
business_date
=
v
[
"business_date"
]
.
strftime
(
'
%
Y-
%
m-
%
d'
)
if
v
[
"business_date"
]
else
""
create_date
=
(
v
[
"create_date"
]
+
datetime
.
timedelta
(
hours
=
8
))
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
)
if
v
[
"create_date"
]
else
""
user_name
=
_self
.
env
[
'res.users'
]
.
sudo
()
.
browse
(
v
[
"create_uid"
])
.
name
or
""
data
.
append
({
"id"
:
v
.
id
,
"business_date"
:
v
.
business_date
and
v
.
business_date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
,
"abstract"
:
v
.
abstract
or
""
,
"customer"
:
v
.
customer
or
""
,
"income"
:
round
(
v
.
income
,
2
)
or
0
,
"machinery_type"
:
v
.
machinery_type
or
"其他"
,
"expenditure"
:
round
(
v
.
expenditure
)
or
0
,
"balance"
:
round
(
v
.
balance
,
2
)
or
0
,
"user_name"
:
v
.
create_uid
.
name
or
""
,
"create_date"
:
(
v
.
create_date
+
datetime
.
timedelta
(
hours
=
8
))
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
)
,
"id"
:
v
[
"id"
]
,
"business_date"
:
business_date
,
"abstract"
:
v
[
"abstract"
]
or
""
,
"customer"
:
v
[
"customer"
]
or
""
,
"income"
:
round
(
v
[
"income"
]
or
0
,
2
)
,
"machinery_type"
:
v
[
"machinery_type"
]
or
"其他"
,
"expenditure"
:
round
(
v
[
"expenditure"
]
or
0
,
2
)
,
"balance"
:
round
(
v
[
"balance"
]
or
0
,
2
)
,
"user_name"
:
user_name
,
"create_date"
:
create_date
,
})
return
{
"code"
:
0
,
"message"
:
"获取成功!"
,
"data"
:
data
,
"count"
:
count
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment