2
0

[IMP]hook. Odoo does not add the invoice_id in payable entries so need to use the product.

This commit is contained in:
ahenriquez 2020-05-18 15:34:53 +02:00 committed by AlexPForgeFlow
parent c6e4b41d4f
commit 46a6a6971a
2 changed files with 26 additions and 1 deletions

View File

@ -9,7 +9,7 @@
"Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-financial-tools",
"category": "Generic",
"depends": ["account", "sale"],
"depends": ["account_move_line_stock_info", "sale"],
"license": "AGPL-3",
"data": [
"security/account_security.xml",

View File

@ -27,6 +27,7 @@ def post_init_hook(cr, registry):
rel.invoice_line_id = ail.id
INNER JOIN sale_order_line sol ON
rel.order_line_id = sol.id
AND sol.product_id = aml2.product_id
WHERE aml.id = aml2.id;
""")
@ -36,4 +37,28 @@ def post_init_hook(cr, registry):
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("""
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
WHERE aml2.move_id = aml.move_id
""")
cr.execute("""
update account_move_line aml set sale_line_id = sol.id
FROM account_move_line aml2
INNER JOIN sale_order so ON
so.id = aml2.sale_id
INNER JOIN sale_order_line sol ON
so.id = sol.order_id
AND sol.product_id = aml2.product_id
WHERE aml.id = aml2.id;
""")