Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import logging
from odoo import SUPERUSER_ID, api
_logger = logging.getLogger(__name__)
def migrate(cr, version):
env = api.Environment(cr, SUPERUSER_ID, {})
purchase_orders = env["purchase.order"].search([("state", "=", "purchase")])
for order in purchase_orders:
try:
_logger.info(f"Processing Purchase Order: {order.name} (ID: {order.id})")
valued_lines = order.order_line.invoice_lines.filtered(
lambda line: line.product_id
and line.product_id.cost_method != "standard"
and (
not line.company_id.tax_lock_date
or line.date > line.company_id.tax_lock_date
)
)
svls, _amls = valued_lines._apply_price_difference()
if svls:
svls._validate_accounting_entries()
bills = order.invoice_ids.filtered(lambda bill: bill.state == "posted")
bills._stock_account_anglo_saxon_reconcile_valuation()
except Exception as e:
_logger.error(
(
f"Error processing Purchase Order {order.name} "
f"(ID: {order.id}): {str(e)}"
),
exc_info=True,
)

View File

@@ -0,0 +1,30 @@
from openupgradelib import openupgrade
def migrate(cr, version):
openupgrade.logged_query(
cr,
"""
ALTER TABLE account_move_line
ADD COLUMN IF NOT EXISTS oca_purchase_line_id INTEGER;
""",
)
openupgrade.logged_query(
cr,
"""
UPDATE account_move_line
SET oca_purchase_line_id = purchase_line_id;
""",
)
openupgrade.logged_query(
cr,
"""
UPDATE account_move_line
SET purchase_line_id = NULL
FROM account_move
WHERE account_move_line.move_id = account_move.id
AND account_move.move_type = 'entry';
""",
)