Inter-Company Invoice Errors
When using Odoo's multi-company features with inter-company transactions:
UserError: You cannot create an invoice for another company.
AccessError: You are not allowed to access documents of company 'Company B'.
ValidationError: The inter-company invoice could not be created.
Missing partner mapping for company 'Company A' in company 'Company B'.
UserError: No inter-company rule found for this transaction.Understanding Inter-Company in Odoo
Odoo can automatically generate corresponding documents between companies:
- Sale order in Company A → Purchase order in Company B
- Invoice in Company A → Vendor bill in Company B
- This requires the inter-company rules module and proper configuration
Fix 1: Install and Configure Inter-Company Rules
# Install the module:
# Apps > search "Inter Company Rules" > Install
# Module name: inter_company_rules
# Configure rules:
# Settings > General Settings > Multi Companies
# For each company pair, set:
# - "Inter-Company Transactions" → Enabled
# - Rule type: "Synchronize Sales/Purchase Orders" or "Invoice/Bill"
# Via Settings on each company:
# Settings > Companies > select company
# Inter-Company tab:
# - Rule: "Create corresponding invoice/bill"
# - Warehouse: select default warehouse for purchase ordersFix 2: Partner Mapping
# Each company must be represented as a Partner in the other company
# Company A must have Company B as a partner (vendor/supplier)
# Company B must have Company A as a partner (customer)
# Check partner mapping:
# Contacts > search for "Company A" in Company B context
# Contacts > search for "Company B" in Company A context
# If missing, create the partner:
# 1. Switch to Company B
# 2. Create a new contact "Company A"
# 3. Set "Is a Company" = True
# 4. Link it: Company field → Company A
# The link is via res_company.partner_id:
sudo -u postgres psql -d mydb -c "
SELECT rc.name, rp.name as partner_name, rp.id as partner_id
FROM res_company rc
JOIN res_partner rp ON rc.partner_id = rp.id;
"Fix 3: User Must Belong to Both Companies
# The user creating the transaction must have access to both companies
# Check user's allowed companies:
# Settings > Users > select user > "Allowed Companies"
# The user needs at least read access in both companies
# For automatic inter-company transactions:
# The inter-company user (often admin) needs full access
# Set the inter-company user:
# Settings > Companies > Company A > Inter-Company tab
# "Responsible User" → select a user with access to both companiesFix 4: Wrong Company Context
# Error: creating invoice in wrong company context
# In custom code, ensure correct company context:
with_company_b = self.env['account.move'].with_company(company_b)
invoice = with_company_b.create({
'partner_id': company_a_partner_id,
'move_type': 'in_invoice',
'company_id': company_b.id, # Explicit company
})
# Common mistake: not switching company context
# The env.company might still be Company A when creating in Company BFix 5: Chart of Accounts per Company
# Each company must have its own chart of accounts
# Inter-company entries use each company's respective accounts
# Check accounts exist in both companies:
sudo -u postgres psql -d mydb -c "
SELECT rc.name, COUNT(aa.id) as accounts
FROM res_company rc
LEFT JOIN account_account aa ON aa.company_id = rc.id
GROUP BY rc.name;
"
# If a company has no accounts, install a chart:
# Switch to that company > Accounting > Settings > Fiscal LocalizationFix 6: Tax and Fiscal Position Mapping
# Inter-company invoices need correct tax treatment
# Company A's sale tax may differ from Company B's purchase tax
# Configure fiscal positions for inter-company:
# Accounting > Configuration > Fiscal Positions
# Create a fiscal position for inter-company transactions
# Map: Sale Tax (Company A) → Purchase Tax (Company B)
# Set this fiscal position on the inter-company partner:
# Contacts > Company B partner > Sales & Purchase tab
# Fiscal Position → Inter-CompanyFix 7: Debugging Inter-Company Transactions
# Enable logging for inter-company:
# In odoo.conf:
log_handler = odoo.addons.inter_company_rules:DEBUG
# Check the automatic transaction log:
# Each company's partner should show linked documents
# Company A: Sale Order SO001 → Company B: Purchase Order PO001
# Verify the rule is triggering:
# Check if the scheduled action runs:
# Settings > Technical > Scheduled Actions > "Inter Company Rules"Prevention
DeployMonkey's AI agent configures inter-company rules, partner mappings, and fiscal positions automatically for multi-company setups. The agent validates cross-company transaction flows before activation.