Skip to content

Commit

Permalink
[FIX] Exclude stock moves for projects, those should not create layer…
Browse files Browse the repository at this point in the history
…s, unless it is from projects to general stock or from general stock to projects
  • Loading branch information
AaronHForgeFlow committed Oct 21, 2024
1 parent f807aff commit 2cdeade
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions addons/stock_account/migrations/13.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,22 @@ def get_stock_moves(env, company_id, product_id, real_time):
sm.create_uid, sm.create_date, sm.write_uid, sm.write_date,
CASE WHEN (sl.usage <> 'internal' AND (sl.usage <> 'transit' OR sl.company_id <> sm.company_id))
AND (sld.usage = 'internal' OR (sld.usage = 'transit' AND sld.company_id = sm.company_id))
AND sl.analytic_account_id IS NULL AND sld.analytic_account_id IS NULL
THEN 'in'
WHEN (sl.usage = 'internal' OR (sl.usage = 'transit' AND sl.company_id = sm.company_id))
AND (sld.usage <> 'internal' AND (sld.usage <> 'transit' OR sld.company_id <> sm.company_id))
AND sl.analytic_account_id IS NULL AND sld.analytic_account_id IS NULL
THEN 'out'
WHEN sl.analytic_account_id IS NOT NULL
AND sld.analytic_account_id IS NULL
AND sl.usage = 'internal'
AND sld.usage = 'internal'
THEN 'in'
WHEN sld.analytic_account_id IS NOT NULL
AND sl.analytic_account_id IS NULL
AND sl.usage = 'internal'
AND sld.usage = 'internal'
THEN 'out'
WHEN sl.usage = 'supplier' AND sld.usage = 'customer' THEN 'dropship'
WHEN sl.usage = 'customer' AND sld.usage = 'supplier' THEN 'dropship_return'
ELSE 'other'
Expand All @@ -150,6 +162,13 @@ def get_stock_moves(env, company_id, product_id, real_time):
{account_move_join}
WHERE sm.company_id = %s AND sm.product_id = %s
AND state = 'done'
AND (
(sm.analytic_account_id IS NULL)
OR
(sl.analytic_account_id IS NOT NULL AND sld.analytic_account_id IS NULL AND sl.usage = 'internal' AND sld.usage = 'internal')
OR
(sld.analytic_account_id IS NOT NULL AND sl.analytic_account_id IS NULL AND sl.usage = 'internal' AND sld.usage = 'internal')
)
ORDER BY sm.date, sm.id
"""
account_move_table = ""
Expand Down

0 comments on commit 2cdeade

Please sign in to comment.