vendor_payment_diff_amount/TEST_UPGRADE.md
2025-12-06 10:24:16 +07:00

4.1 KiB

Testing the Upgrade to v2.0

Pre-Upgrade Checklist

  1. Backup your database

    pg_dump your_database > backup_before_v2.sql
    
  2. Check for existing payments with deductions

    # In Odoo shell
    payments = env['account.payment'].search([
        ('amount_substract', '>', 0)
    ])
    print(f"Found {len(payments)} payments with deductions")
    

Upgrade Steps

1. Update the Module

From Odoo UI:

  • Go to Apps
  • Remove "Apps" filter
  • Search for "Vendor Payment Diff Amount"
  • Click "Upgrade"

Or from command line:

./odoo-bin -u vendor_payment_diff_amount -d your_database --stop-after-init

2. Verify Installation

Check that:

  • Module upgraded successfully without errors
  • New model payment.deduction.line is created
  • Security rules are applied

3. Test Basic Functionality

Test 1: Create Payment with Single Deduction

  1. Go to Accounting > Vendors > Payments
  2. Create new outbound payment
  3. Enter amount: 1000
  4. Add deduction line:
    • Account: Select a tax/expense account
    • Amount: 100
    • Description: "Withholding Tax"
  5. Verify:
    • Total Deductions: 100
    • Final Payment Amount: 900
  6. Post the payment
  7. Check journal entry:
    • Expense/Payable: Debit 1000
    • Tax Account: Credit 100
    • Bank: Credit 900

Test 2: Create Payment with Multiple Deductions

  1. Create new outbound payment
  2. Enter amount: 2000
  3. Add first deduction:
    • Account: PPh 21 account
    • Amount: 100
    • Description: "PPh 21"
  4. Add second deduction:
    • Account: PPh 29 account
    • Amount: 50
    • Description: "PPh 29"
  5. Verify:
    • Total Deductions: 150
    • Final Payment Amount: 1850
  6. Post and verify journal entry:
    • Expense/Payable: Debit 2000
    • PPh 21: Credit 100
    • PPh 29: Credit 50
    • Bank: Credit 1850

Test 3: Batch Payment with Deductions

  1. Go to Accounting > Vendors > Batch Payments
  2. Create new batch payment
  3. Add payment line
  4. Click on the line to open form view
  5. In "Deductions" section, add deduction lines
  6. Save the line
  7. Verify total deductions shown in tree
  8. Generate payments
  9. Verify deductions transferred to generated payment

Common Issues and Solutions

Issue: "company_id field missing"

Solution: This was fixed in the latest version. Make sure you have the updated view files.

Issue: "Cannot locate form view"

Solution: The view now includes both tree and form definitions. Upgrade to latest version.

Issue: Existing payments not showing deductions

Solution: Old payments need manual migration. See UPGRADE_TO_V2.md for migration script.

Rollback Procedure

If you need to rollback:

  1. Stop Odoo
  2. Restore database:
    dropdb your_database
    createdb your_database
    psql your_database < backup_before_v2.sql
    
  3. Checkout previous version of the module
  4. Restart Odoo

Post-Upgrade Tasks

Migrate Existing Data (if needed)

If you have existing payments with the old single deduction structure, run this migration:

# In Odoo shell: ./odoo-bin shell -d your_database

# Find payments that might need migration
# Note: In v2.0, amount_substract is computed, so we can't query it directly
# Instead, look for payments that should have deductions but don't have deduction lines

# Manual migration example:
payment = env['account.payment'].browse(123)  # Replace with actual ID

# Create deduction line
env['payment.deduction.line'].create({
    'payment_id': payment.id,
    'amount_substract': 100.0,  # The old amount
    'substract_account_id': 456,  # The old account ID
    'name': 'Migrated deduction',
    'sequence': 10,
})

env.cr.commit()

Verification Checklist

After upgrade, verify:

  • Module shows version 2.0.0
  • Can create new payments with multiple deductions
  • Deductions calculate correctly
  • Journal entries are correct
  • Batch payments work with deductions
  • No errors in log files
  • Existing payments still accessible
  • Reports show correct amounts

Support

If you encounter issues:

  1. Check the error log
  2. Review UPGRADE_TO_V2.md
  3. Contact module maintainer