[IMP] : black, isort, prettier

This commit is contained in:
AaronHForgeFlow
2020-07-29 17:26:15 +02:00
parent 4707218585
commit f354ceb6c1
9 changed files with 244 additions and 205 deletions

View File

@@ -1,22 +1,26 @@
# Copyright 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import ast
from odoo import api, SUPERUSER_ID
from odoo import SUPERUSER_ID, api
def post_init_hook(cr, registry):
""" INIT sale references in acount move line """
# FOR stock moves
cr.execute("""
cr.execute(
"""
update account_move_line aml set sale_line_id = sm.sale_line_id
FROM account_move_line aml2
INNER JOIN stock_move sm ON
aml2.stock_move_id = sm.id
WHERE aml.id = aml2.id;
""")
"""
)
# FOR invoices
cr.execute("""
cr.execute(
"""
update account_move_line aml set sale_line_id = sol.id
FROM account_move_line aml2
INNER JOIN account_invoice ai ON
@@ -29,30 +33,36 @@ def post_init_hook(cr, registry):
rel.order_line_id = sol.id
AND sol.product_id = aml2.product_id
WHERE aml.id = aml2.id;
""")
"""
)
# NOW we can fill the SO
cr.execute("""
cr.execute(
"""
UPDATE account_move_line aml
SET sale_id = sol.order_id
FROM sale_order_line AS sol
WHERE aml.sale_line_id = sol.id
RETURNING aml.move_id
""")
"""
)
# NOW we can fill the lines without invoice_id (Odoo put it very
# complicated)
cr.execute("""
cr.execute(
"""
UPDATE account_move_line aml
SET sale_id = so.id
FROM sale_order_line so
LEFT JOIN account_move_line aml2
ON aml2.sale_id = so.id
ON aml2.sale_id = so.id
WHERE aml2.move_id = aml.move_id
""")
"""
)
cr.execute("""
cr.execute(
"""
update account_move_line aml set sale_line_id = sol.id
FROM account_move_line aml2
INNER JOIN sale_order so ON
@@ -61,4 +71,5 @@ def post_init_hook(cr, registry):
so.id = sol.order_id
AND sol.product_id = aml2.product_id
WHERE aml.id = aml2.id;
""")
"""
)