mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Add an init hook and a migration in order to make sure that account move lines connected with stock moves get the connecting purchase order line.
21 lines
582 B
Python
21 lines
582 B
Python
# Copyright 2022 ForgeFlow S.L.
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
|
|
def post_init_hook(cr, registry):
|
|
|
|
"""INIT purchase_line_id in acount move line"""
|
|
# FOR stock moves
|
|
cr.execute(
|
|
"""
|
|
UPDATE account_move_line aml SET purchase_line_id = sm.purchase_line_id
|
|
FROM account_move_line aml2
|
|
INNER JOIN account_move am
|
|
ON am.id = aml2.move_id
|
|
INNER JOIN stock_move sm ON
|
|
am.stock_move_id = sm.id
|
|
WHERE aml.id = aml2.id
|
|
AND sm.purchase_line_id IS NOT NULL;
|
|
"""
|
|
)
|