Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lefilament_projets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Le Filament
lefilament_projets
Commits
f910bd7b
Commit
f910bd7b
authored
7 years ago
by
Benjamin
Browse files
Options
Downloads
Patches
Plain Diff
fix erreurs requetes _delay et _total_days
parent
18a9bf5a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
models/lefilament_projets.py
+30
-12
30 additions, 12 deletions
models/lefilament_projets.py
with
30 additions
and
12 deletions
models/lefilament_projets.py
+
30
−
12
View file @
f910bd7b
...
...
@@ -86,14 +86,27 @@ class FilamentProjet(models.Model):
@api.one
def
_delay
(
self
):
account_id
=
self
.
analytic_account_id
.
id
self
.
_cr
.
execute
(
"""
SELECT
date(d_invoice) - date(d_cost) as datediff
from
(select date FROM account_analytic_line where account_id=%s and amount < 0 order by date limit 1) as d_cost,
(select date FROM account_analytic_line where account_id=%s and amount > 0 order by date limit 1) as d_invoice
;
"""
,
(
account_id
,
account_id
)
)
self
.
lf_delay
=
self
.
_cr
.
fetchone
()[
0
]
self
.
env
.
cr
.
execute
(
"""
SELECT date
FROM account_analytic_line
where account_id=%s and amount < 0 order by date limit 1
;
"""
,
(
account_id
,
)
)
d_cost
=
self
.
env
.
cr
.
fetchone
()
self
.
env
.
cr
.
execute
(
"""
SELECT date
FROM account_analytic_line
where account_id=%s and amount > 0 order by date limit 1
;
"""
,
(
account_id
,
)
)
d_invoice
=
self
.
env
.
cr
.
fetchone
()
if
d_cost
:
if
d_invoice
:
self
.
lf_delay
=
(
datetime
.
strptime
(
d_invoice
[
0
],
"
%Y-%m-%d
"
).
date
()
-
datetime
.
strptime
(
d_cost
[
0
],
"
%Y-%m-%d
"
).
date
()).
days
else
:
self
.
lf_delay
=
(
datetime
.
now
().
date
()
-
datetime
.
strptime
(
d_cost
[
0
],
"
%Y-%m-%d
"
).
date
()).
days
else
:
self
.
lf_delay
=
0
## Total Days
@api.one
...
...
@@ -106,7 +119,12 @@ class FilamentProjet(models.Model):
(select date FROM account_analytic_line where account_id=%s order by date limit 1) as d_first,
(select date FROM account_analytic_line where account_id=%s order by date desc limit 1) as d_last
;
"""
,
(
account_id
,
account_id
,
)
)
self
.
lf_total_days
=
self
.
_cr
.
fetchone
()[
0
]
lf_total_days
=
self
.
_cr
.
fetchone
()
if
lf_total_days
:
self
.
lf_total_days
=
lf_total_days
[
0
]
else
:
self
.
lf_total_days
=
0
## Balance
@api.one
...
...
@@ -127,10 +145,10 @@ class FilamentProjet(models.Model):
self
.
env
.
cr
.
execute
(
"""
SELECT sum(amount) as Total
FROM account_analytic_line
WHERE account_id=
31
WHERE account_id=
%s
and date < (case when
(select date FROM account_analytic_line where account_id=
31
and amount > 0 order by date limit 1) IS NOT NULL then
(select date FROM account_analytic_line where account_id=
31
and amount > 0 order by date limit 1) else current_date end
(select date FROM account_analytic_line where account_id=
%s
and amount > 0 order by date limit 1) IS NOT NULL then
(select date FROM account_analytic_line where account_id=
%s
and amount > 0 order by date limit 1) else current_date end
);
"""
,
(
account_id
,
account_id
,
account_id
,
)
)
self
.
lf_advance
=
self
.
_cr
.
fetchone
()[
0
]
...
...
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