Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support question: How do I create expenses with tax correctly calculated? #11

Open
partoneoftwo opened this issue Mar 15, 2020 · 2 comments

Comments

@partoneoftwo
Copy link

partoneoftwo commented Mar 15, 2020

How do I create expenses with tax correctly calculated?

When I use odooly to create an expense, I am able to create the expense, with the correct product chosen, and the specified date and amount.
However the total is not correct, because the product I choose should have a TAX on it.
Since all transactions on my expenses must show excluding and including VAT.

**The goal here is: That the tax amount on the expense created by Odooly is calculated correctly. **

My server/Odoo instance: In my case it works perfectly when manually entered, and the views and frontend calculate the tax value correctly when I use the mouse to select the correct product, the correct values are also then persisted to the database when clicking save.

The command I have tried to run is the following:
``

env['hr.expense'].create({'name': "Tiny Lasagna", 'product_uom_id': '1', 'quantity': '1', 'company_id': '1', 'unit_amount': '20', 'date': '2020-01-19','currency_id': '14','account_id': '205','payment_mode': 'own_account','analytic_account_id': '' ,'create_uid': '6','product_id': '5','company_currency_id': '14','sale_order_id': '','currency_id': '14','analytic_tag_ids': '','tax_ids':'','can_be_reinvoiced': '1','sale_order_id':'','description':'Little Bits','reference': 'Interdimensional Cable'})

I have tried the following:

  • Scoured the model for expenses, to try and see which fields are required
  • Enabled full Postgresql logging, and tried reverse-engineering the transaction of creating a new expense
  • Browsed the Odoo database with pgadmin for hours, and trying out as much as I could.

There seems to be a hint from a tangentially related question on the Odoo forums: - https://www.odoo.com/fr_FR/forum/aide-1/question/account-invoice-tax-is-not-calculated-from-line-data-imported-to-account-invoice-136828

Maybe the clue lies in the view for hr.expense located at Views ---> hr.expense.sheet.form, which refers to several fields that seem relevant to tax on expense.

But I can't figure it out... And now I've exhausted all options

Any help or pointers?

@partoneoftwo
Copy link
Author

partoneoftwo commented Mar 17, 2020

After way too many hours, I managed to get the functionality in Odoo to trigger; calculate taxes on created Expenses.

It does indeed calculate taxes now, so this is great!

This was achieved by running this command from Odooly:
env['hr.expense'].create({'product_id':39,'company_id':1,'employee_id':2,'name': "Zibby Tiny Lasagna",'unit_amount':'100','untaxed_amount':'100','quantity':'1','analytic_account_id':16,'company_currency_id':14,'account_id':'205','product_uom_id':1,'analytic_tag_ids':[('is_editable','0',[])],'tax_ids': [(6, 0, [5])]})

Remainder: The products are supposed to have a tax setting, but this is bruteforced by the tax_ids command above. So right now, Odoo doesn't follow which tax setting which was set in the product_id.

I found a clue, which got me closer to the solution here:
https://www.odoo.com/es_ES/forum/ayuda-1/question/solved-get-and-set-default-tax-by-python-command-line-82209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants