Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
970 Weergaven

I am trying to create new bank transactions automatically instead of having users input the info manually as described here: https://odoo.com/documentation/17.0/applications/finance/accounting/bank/transactions.html#transactions-register

I have tried the following code but it did not work:

name = 'account.bank.statement.line'
id = models.execute_kw(db, uid, password, name, 'create',
[{
'move_id': 1,
'payment_ref': 'TEST/0001',
'amount': 100,
}])

What did I do wrong?

Thank you!


Avatar
Annuleer
Beste antwoord
  1. Model Name: You've assigned the model name 'account.bank.statement.line' to the variable name, but it's unclear if this model exists in your Odoo instance. Make sure this is the correct model name.
  2. Field Names: Ensure that the field names you're using in the dictionary match the field names of the account.bank.statement.line model. The fields you've used ('move_id', 'payment_ref', 'amount') need to exist in the model and be spelled correctly.
  3. execute_kw Arguments: The execute_kw method requires the following arguments:
    • db: Database name
    • uid: User ID
    • password: User password
    • model: Model name
    • method: Method to execute (e.g., 'create')
    • args: List of dictionaries containing the data to be created

Let's refine your code with these considerations:

pythonCopy code# Assuming you have already imported necessary modules like models and requests
model = 'account.bank.statement.line'
data = {
    'move_id': 1,  # Assuming you have the move ID already
    'payment_ref': 'TEST/0001',
    'amount': 100,
    # Add other required fields here
}

# Make sure to replace 'db', 'uid', and 'password' with actual values
result = models.execute_kw(db, uid, password, model, 'create', [data])

# Print the result to check if the creation was successful
print("Created bank statement line with ID:", result)

Ensure you replace 'db', 'uid', and 'password' with the actual values for your Odoo instance. Also, make sure the user you're authenticating with has the necessary permissions to create bank statement lines. If there are any errors, the print statement will help you identify them.

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
sep. 25
5
4
sep. 25
1187
3
sep. 25
302
1
aug. 25
230
1
aug. 25
306