Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
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
Odoo
Coopdevs OCB mirror
Commits
9d6b9cc9
Commit
9d6b9cc9
authored
8 years ago
by
Quentin De Paoli
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] account: Filter on contact by total receivable/payable fixed. opw 669833
parent
4810513f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addons/account/models/partner.py
+22
-27
22 additions, 27 deletions
addons/account/models/partner.py
with
22 additions
and
27 deletions
addons/account/models/partner.py
+
22
−
27
View file @
9d6b9cc9
...
...
@@ -252,40 +252,35 @@ class ResPartner(models.Model):
partner
.
debit
=
-
val
@api.multi
def
_asset_difference_search
(
self
,
type
,
args
):
if
not
args
:
def
_asset_difference_search
(
self
,
account_type
,
operator
,
operand
):
if
operator
not
in
(
'
<
'
,
'
=
'
,
'
>
'
,
'
>=
'
,
'
<=
'
)
:
return
[]
having_values
=
tuple
(
map
(
itemgetter
(
2
),
args
))
where
=
'
AND
'
.
join
(
map
(
lambda
x
:
'
(SUM(bal2) %(operator)s %%s)
'
%
{
'
operator
'
:
x
[
1
]},
args
))
query
=
self
.
env
[
'
account.move.line
'
].
_query_get
()
self
.
_cr
.
execute
((
'
SELECT pid AS partner_id, SUM(bal2) FROM
'
\
'
(SELECT CASE WHEN bal IS NOT NULL THEN bal
'
\
'
ELSE 0.0 END AS bal2, p.id as pid FROM
'
\
'
(SELECT (debit-credit) AS bal, partner_id
'
\
'
FROM account_move_line l
'
\
'
WHERE account_id IN
'
\
'
(SELECT id FROM account_account
'
\
'
WHERE type=%s AND active)
'
\
'
AND reconciled IS FALSE
'
\
'
AND
'
+
query
+
'
) AS l
'
\
'
RIGHT JOIN res_partner p
'
\
'
ON p.id = partner_id ) AS pl
'
\
'
GROUP BY pid HAVING
'
+
where
),
(
type
,)
+
having_values
)
if
type
(
operand
)
not
in
(
float
,
int
):
return
[]
sign
=
1
if
account_type
==
'
payable
'
:
sign
=
-
1
res
=
self
.
_cr
.
execute
(
'''
SELECT partner.id
FROM res_partner partner
LEFT JOIN account_move_line aml ON aml.partner_id = partner.id
RIGHT JOIN account_account acc ON aml.account_id = acc.id
WHERE acc.internal_type = %s
AND NOT acc.deprecated
GROUP BY partner.id
HAVING %s * COALESCE(SUM(aml.amount_residual), 0)
'''
+
operator
+
'''
%s
'''
,
(
account_type
,
sign
,
operand
))
res
=
self
.
_cr
.
fetchall
()
if
not
res
:
return
[(
'
id
'
,
'
=
'
,
'
0
'
)]
return
[(
'
id
'
,
'
in
'
,
map
(
itemgetter
(
0
),
res
))]
@api.m
ulti
def
_credit_search
(
self
,
args
):
return
self
.
_asset_difference_search
(
'
receivable
'
,
args
)
@api.m
odel
def
_credit_search
(
self
,
operator
,
operand
):
return
self
.
_asset_difference_search
(
'
receivable
'
,
operator
,
operand
)
@api.m
ulti
def
_debit_search
(
self
,
args
):
return
self
.
_asset_difference_search
(
'
payable
'
,
args
)
@api.m
odel
def
_debit_search
(
self
,
operator
,
operand
):
return
self
.
_asset_difference_search
(
'
payable
'
,
operator
,
operand
)
@api.multi
def
_invoice_total
(
self
):
...
...
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