How to use property fields in Odoo
Odoo is a very robust framework, there are many useful features of odoo which are not known by the normal users.
Let me give you some background of why I am writing this blog post. A few days back, one of our clients pinged me, he wanted my help in resolving a warning he is facing.
The client is having a multi company setup with 2 companies running smoothly in the same DB. A few days ago, they registered a new company with the same business operations. So they don't have any customized business flow involved. Having a person with good Odoo understanding in house, they created a new company in Odoo on their own.
For other 2 companies we had implemented earlier, we created modules to simulate the Chart of Accounts and installed them . For the new company, the chart of accounts is identical to the other 2 companies. So, they exported the accounts from one of the companies and imported the CSV file in the new company. The accounts were verified and COA looked good. So far so good.
After setting up the accounts, they tried to create a Vendor Payment and got the error message shown below
After many unsuccessful trials and errors, one day their IT messaged me if I could do something.
We got on a call, I asked him to do the same operation again. The error was there. I asked him to open the vendor for whom they were trying to do the payment and I noticed something. In the vendor form, the receivable accounts and the payable accounts are not set. We set both the accounts and we are done! No more error message, the vendor payment was through.
So, what was the issue? Missing Receivable and Payable accounts. Why were those accounts missing? Because, the client did not have the Chart of accounts module installed. Is it mandatory to have a module for Chart of Accounts? Certainly, not. Then, how to avoid such configuration mistakes while implementing the Odoo?
Well, Odoo has property fields to set default values in particular fields. Where to find them? Enable the Debug mode from the Settings> General Settings.
Go to Settings> Technical> Parameters> Company Properties. Click on create. Give the name of the property, select company if you are in a multi company setup. In the ‘Field’, select the field. Start writing Account Receivable, the system will show relevant options. Select Account Receivable (res.partner), as we want to set the default value for receivable account in the partner form. Keep the resource field blank, the receivable and payable accounts are going to be the same for all partners. Select Many2One in the Type field. At last, in the value field, write account.account,6. 6 is the database id of the receivable account. Check the image below.
This way you need to set all default values of accounts like the Payable account, Inventory account, default income and expense accounts etc. to get the correct setup. It is advisable to have a custom module for Chart of accounts for your company to avoid all this manual work but having a module is not mandatory! Apart from the accounts also, you get default value in many fields. So, if you want to change any default value, Company Properties is the place to go.
How to know the database ID of the account? Go to Accounting> Configuration> Accounting> Chart of Accounts. Open the form view of the Account Receivable. Open Developer Tools, select View Metadata.
When you click on View Metadata, the first field you see is the ID of the record, in our case, the ID of the receivable account, 6.
Hope this blog post will be useful to Odoo users, implementers and customers. Comments, feedback are welcome.