Search code examples
pythonpython-2.7odoo-8odoo

Using bank account as account_id on account.move - Odoo v8


I need to use the bank account of the company to do an account.move.

I've looked into the addons for some example, with the user_type field, which is a Many2one to model account.account.type , with no luck.

Any example on hoy can I declare it?

I mean, I have methods which create account.move but what I need is just an example line on how to declare a bank type account_id.

EDIT

Actually, what I need is to use the default company bank account, but still confused on how to declare it.


Solution

  • company = self.env.user.company_id
    

    Then:

    • company.bank_ids will give you all the bank accounts (objects) of the company of the current user.
    • company.bank_ids[0] will give you the first bank account (the object) found of the company of the current user (it will give you an error if the company doesn't have anyone).
    • company.partner_id.property_account_receivable will give you the account (the object) where the company pays its purchases.
    • company.partner_id.property_account_payable will give you the account (the object) where the company charges its sales.

    Is that what you were looking for?