Sale and purchase taxes are not get from account.accout default tax

Bug #796570 reported by Eetu Salpaharju on 2011-06-13
This bug affects 10 people
Affects Status Importance Assigned to Milestone
OpenERP R&D Addons Team 2
OpenERP Community Backports (Addons)
Laurent Mignon (Acsone)
Therp Backports (Deprecated)
Status tracked in Addons-6.1
Stefan Rijnhart (Opener)

Bug Description

Default taxes defined in product's income or expense account (product_template.property_income_account and product_template.property_expense_account) does not work in sale orders or purchase orders.

The situation can be generated like this:

1) create product. Define income account bot does not define any taxes direct to the product.
2) Define default tax to income- and expense accounts related to the product
3) Create SO and select the product you created. There is on taxes on that SO.

Expected behavior would be that if there is no taxes defined in product, default taxes from income account should be used.

There is same situation with purchase orders as well.

This is a tricky situation when you are working with multi-company database since product tax definition is not property.

Proposed fix:

With following path taxes seems to be added as they should (in my point of view). There is fix for procurement process as well.
> prod_tpl = self.pool.get('product.template').browse(cr, uid, product)
> context['company_id'] = self.browse(cr, uid, ids[0], context).company_id
> taxes = prod.supplier_taxes_id or\
> prod_tpl.property_account_expense.tax_ids or\
> prod_tpl.categ_id.property_account_expense_categ.tax_ids
< 'taxes_id':map(lambda x:, prod.supplier_taxes_id),
> 'taxes_id': taxes,
< taxes = self.pool.get('').browse(cr, uid,map(lambda x:, prod.supplier_taxes_id))
> prod_tpl = self.pool.get('product.template').browse(cr, uid,, context=context)
< taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id
> taxes_ids = prod_tpl.supplier_taxes_id or\
> prod_tpl.property_account_expense.tax_ids or\
> prod_tpl.property_account_expense_categ.tax_ids

> product_tpl = self.pool.get('product.template')
> product_tpl = product_tpl.browse(cr, uid, product, context=context)
> if not result['tax_id']:
> result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, product_tpl.property_account_income.tax_ids)
> if not result['tax_id']:
> result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, product_tpl.categ_id.property_account_income_categ.tax_ids)

Related branches

Eetu Salpaharju (ex4) wrote :

oh, there seems to be a small bug in my patch. In line
context['company_id'] = self.browse(cr, uid, ids[0], context).company_id
seems to raise list index out of range exception. Better line might be like
context['company_id'] = self.browse(cr, uid, ids, context)[0].company_id

But I'm not sure if that line is needed anyway.

Amit Parik (amit-parik) on 2011-07-01
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress

Hello Eetu Salpaharju,

Its fixed in branch.
Revision ID: mtr@mtr-20110708053218-nlxqoyc8mpe8j380
Revision no: 4858

It will be merged soon with main addons.

Thanks for your contribution.

@community team:-In order to fix it in purchase module it should be assigned to the respective team.


Changed in openobject-addons:
status: In Progress → Fix Committed
status: Fix Committed → Confirmed
Changed in openobject-addons:
milestone: none → 6.1

@RD Addons2: Would you please check addons3 related changes and fix the same for purchase also.


Changed in openobject-addons:
assignee: OpenERP R&D Addons Team 3 (openerp-dev-addons3) → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
Changed in openobject-addons:
status: Confirmed → In Progress

Hello Eetu Salpaharju,

Thanks for Reporting.
It has been fixed in lp:~openerp-dev/openobject-addons/trunk-bug-796570-mma
Revision ID: <email address hidden>
Revision num: 4863.

It will be available in trunk soon.

Changed in openobject-addons:
status: In Progress → Fix Committed
Fabien (Open ERP) (fp-tinyerp) wrote :

If there is not tax on the product, it means that there should be no tax in sale or purchase.
This is the current behaviour, so it's not a bug.

But your suggestion is a good idea, but not a bug. As it requires changes in several locations (invoices, so, po, pos, touchscreen pos...) I propose to not change this for now on. I would suggest to create a feedback on

Changed in openobject-addons:
status: Fix Committed → Invalid
Changed in therp-backports:
importance: Undecided → Low
importance: Low → Wishlist
status: New → Fix Committed

Setting to 'opinion' instead of 'invalid', as it seems more appropriate. @Fabien, please note that the invoice already implements this behaviour.

I would like to see this fixed, and have asked the accounting experts for backing (

Changed in openobject-addons:
status: Invalid → Opinion
milestone: 6.1 → 6.2
Changed in therp-backports:
assignee: nobody → Stefan Rijnhart (Therp) (stefan-therp)
Changed in therp-backports:
status: Fix Committed → Fix Released
milestone: none → 6.1-maintenance
Lara (Therp) (lfreeke) on 2013-01-23
Changed in therp-backports:
milestone: 6.1-maintenance → 7.0-maintenance
Stéphane Bidoul (Acsone) (sbi) wrote :

I linked this bug to ocb-addons as the fix has not been ported to 7.0.

I see it is marked Opinion for official.

I my opinion, the patch is a valuable addition to ocb 7.0.

What do you think?

As Fabien indicates, the fallback on account taxes should be implemented in all of OpenERP for consistency. A quick grep reveals that the following modules are affected: account, delivery, mrp_repair, hr_expense, point_of_sale, purchase, sale & stock. To strictly fit the goals of OCB, we should accomodate the vision of upstream OpenERP so the proposed patch should adapt the behaviour in all of these modules.

Stéphane Bidoul (Acsone) (sbi) wrote :

Here is the current status in 7.0:

Account default tax used if product has no tax
- invoice
- hr_expense
- hr_timesheet_invoice

Account default tax ignored:
- sale order
- purchase order
- delivery
- mrp_repair
- pos
- purchase_requisition
- stock

Changed in ocb-addons:
assignee: nobody → Muschang Anthony (Acsone) (anthony-muschang)
Changed in ocb-addons:
assignee: Muschang Anthony (Acsone) (anthony-muschang) → Laurent Mignon (Acsone) (lmi)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers