Analyzes and resolves Odoo 16.0 issues including SVL linking problems, queue job failures, view errors, and business logic bugs...
This skill provides systematic debugging approaches for common Odoo 16.0 issues, with specialized knowledge of SVL (Stock Valuation Layer) linking, queue jobs, view inheritance problems, and business logic errors specific to the Siafa project.
Stock valuation layers not linking properly to vendor bills or account moves.
Background jobs failing or getting stuck in queue_job system.
Views not rendering, XPath inheritance issues, missing fields.
Computed fields not calculating, onchange not triggering, constraints failing.
Orphaned records, inconsistent data, broken relationships.
Slow queries, N+1 problems, inefficient computed fields.
Permission errors, record rules blocking access.
Ask for:
Identify which category the issue falls into and follow the specialized workflow.
Common Symptoms:
Investigation Script:
# In Odoo shell (python3 src/odoo-bin shell -c src/odoo.conf -d DATABASE_NAME)
# Get SVL record
svl = env['stock.valuation.layer'].browse(SVL_ID)
# Check SVL details
print(f"SVL ID: {svl.id}")
print(f"Product: {svl.product_id.name}")
print(f"Quantity: {svl.quantity}")
print(f"Value: {svl.value}")
print(f"Unit Cost: {svl.unit_cost}")
print(f"Stock Move: {svl.stock_move_id.name if svl.stock_move_id else 'NONE'}")
print(f"Account Move: {svl.account_move_id.name if svl.account_move_id else 'NONE'}")
# Check stock move linkage
if svl.stock_move_id:
move = svl.stock_move_id
print(f"\nStock Move Details:")
print(f" Name: {move.name}")
print(f" State: {move.state}")
print(f" Picking: {move.picking_id.name if move.picking_id else 'NONE'}")
print(f" Purchase Line: {move.purchase_line_id.id if move.purchase_line_id else 'NONE'}")
# Check for vendor bill
if move.purchase_line_id:
po_line = move.purchase_line_id
print(f"\nPurchase Order Line:")
print(f" Order: {po_line.order_id.name}")
print(f" Invoice Lines: {po_line.invoice_lines}")
for inv_line in po_line.invoice_lines:
print(f" Invoice: {inv_line.move_id.name}, State: {inv_line.move_id.state}")
# Check account move lines
if svl.account_move_id:
print(f"\nAccount Move Lines:")
for line in svl.account_move_id.line_ids:
print(f" Account: {line.account_id.code} - {line.account_id.name}")
print(f" Debit: {line.debit}, Credit: {line.credit}")
print(f" SVL ID in context: {line.stock_valuation_layer_id.id if line.stock_valuation_layer_id else 'NONE'}")
# Find orphaned SVLs (SQL)
env.cr.execute("""
SELECT svl.id, svl.product_id, svl.quantity, svl.value
FROM stock_valuation_layer svl
WHERE svl.stock_move_id IS NULL
OR svl.account_move_id IS NULL
LIMIT 100
""")
orphaned = env.cr.dictfetchall()
print(f"\nFound {len(orphaned)} potentially orphaned SVLs")
Common Fixes:
svl = env['stock.valuation.layer'].browse(SVL_ID)
account_move = env['account.move'].browse(ACCOUNT_MOVE_ID)
# Update SVL
svl.write({'account_move_id': account_move.id})
# Update account move lines
for line in account_move.line_ids:
if line.account_id == svl.product_id.categ_id.property_stock_valuation_account_id:
line.write({'stock_valuation_layer_id': svl.id})
stock_move = env['stock.move'].browse(MOVE_ID)
stock_move._create_stock_valuation_layers()
Investigation:
# Find failed jobs
failed_jobs = env['queue.job'].search([
('state', '=', 'failed'),
('date_created', '>=', '2025-01-01')
])
for job in failed_jobs:
print(f"\nJob: {job.name}")
print(f" UUID: {job.uuid}")
print(f" State: {job.state}")
print(f" Date Failed: {job.date_done}")
print(f" Exception:\n{job.exc_info}")
# Retry the job
# job.requeue()
Common Fixes:
job = env['queue.job'].browse(JOB_ID)
job.requeue()
job.write({'state': 'done'}) # or 'cancelled'
Common Issues:
Investigation:
view = env.ref('module_name.view_id')
print(view.arch_db) # Print XML
views = env['ir.ui.view'].search([('model', '=', 'stock.picking')])
for v in views:
print(f"{v.name}: {v.xml_id}")
from lxml import etree
view = env.ref('stock.view_picking_form')
arch = etree.fromstring(view.arch_db)
# Test xpath
result = arch.xpath("//field[@name='partner_id']")
print(f"Found {len(result)} elements")
Common Fixes:
Computed Field Not Updating:
# Force recompute
record = env['model.name'].browse(RECORD_ID)
record._recompute_field('field_name')
# Check dependencies
field = env['model.name']._fields['field_name']
print(f"Depends: {field.depends}")
# Test compute method directly
record._compute_field_name()
Onchange Not Triggering:
# Onchange methods only work in UI
# Test via form:
record.onchange('field_name', 'partner_id')
Constraint Failing:
# Test constraint
try:
record._check_constraint_name()
print("Constraint passed")
except ValidationError as e:
print(f"Constraint failed: {e}")
Finding Data Inconsistencies:
# Stock moves without SVL
env.cr.execute("""
SELECT sm.id, sm.name, sm.product_id, sm.state
FROM stock_move sm
LEFT JOIN stock_valuation_layer svl ON svl.stock_move_id = sm.id
WHERE sm.state = 'done'
AND svl.id IS NULL
AND sm.product_id IN (
SELECT id FROM product_product WHERE type = 'product'
)
LIMIT 50
""")
print(env.cr.dictfetchall())
# Vendor bills with no SVL link
env.cr.execute("""
SELECT am.id, am.name, am.partner_id, am.amount_total
FROM account_move am
WHERE am.move_type = 'in_invoice'
AND am.state = 'posted'
AND am.id NOT IN (
SELECT DISTINCT account_move_id
FROM stock_valuation_layer
WHERE account_move_id IS NOT NULL
)
LIMIT 50
""")
print(env.cr.dictfetchall())
In odoo.conf:
log_level = debug
log_handler = :DEBUG
Or via command line:
python3 src/odoo-bin -c src/odoo.conf --log-level=debug --log-handler=:DEBUG
import logging
_logger = logging.getLogger(__name__)
def method(self):
_logger.info('Method called with %s', self)
_logger.debug('Detailed debug info: %s', self.read())
_logger.warning('Something unusual: %s', issue)
_logger.error('Error occurred: %s', error)
import pdb; pdb.set_trace()
User does not have access rights
Fix: Check ir.model.access.csv and record rules
Constraint validation failed
Fix: Check @api.constrains methods
Record does not exist
Fix: Check if record was deleted, use exists() method
column does not exist
Fix: Update module to create/modify fields
Python script for automated SVL investigation - checks linkage, finds orphaned records, validates data consistency.
Script to analyze queue job status, identify stuck jobs, and generate repair commands.
Collection of useful SQL queries for data investigation and debugging common issues.
Database of known issues specific to the Siafa project with solutions and workarounds.