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

Bug #796570 reported by Eetu Salpaharju
60
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Opinion
Low
OpenERP R&D Addons Team 2
OpenERP Community Backports (Addons)
New
Undecided
Laurent Mignon (Acsone)
Therp Backports (Deprecated)
Status tracked in Addons-6.1
Addons-6.1
Fix Released
Wishlist
Stefan Rijnhart (Opener)
Addons-7.0
New
Undecided
Unassigned

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.
---
addons/purchase/purchase.py:
32a33,34
>
>
667a670
> prod_tpl = self.pool.get('product.template').browse(cr, uid, product)
674a678
> context['company_id'] = self.browse(cr, uid, ids[0], context).company_id
705a710,714
> taxes = prod.supplier_taxes_id or\
> prod_tpl.property_account_expense.tax_ids or\
> prod_tpl.categ_id.property_account_expense_categ.tax_ids
>
>
707c716
< 'taxes_id':map(lambda x: x.id, prod.supplier_taxes_id),
---
> 'taxes_id': taxes,
713d721
< taxes = self.pool.get('account.tax').browse(cr, uid,map(lambda x: x.id, prod.supplier_taxes_id))
798a807
> prod_tpl = self.pool.get('product.template').browse(cr, uid, procurement.product_id.id, context=context)
811c820,822
< 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
---
---
addons/sale/sale.py

1018a1019
> product_tpl = self.pool.get('product.template')
1031a1033
> product_tpl = product_tpl.browse(cr, uid, product, context=context)
1073a1076,1079
> 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

Revision history for this message
Eetu Salpaharju (ex4) wrote :

oh, there seems to be a small bug in my patch. In purchase.py 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)
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
Revision history for this message
Meera Trambadia (OpenERP) (mtr-openerp) wrote :

Hello Eetu Salpaharju,

Its fixed in https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-796570-mtr 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.

Thanks,
mtr

Changed in openobject-addons:
status: In Progress → Fix Committed
status: Fix Committed → Confirmed
Changed in openobject-addons:
milestone: none → 6.1
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) wrote :

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

Thanks.

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
Revision history for this message
Mayur Maheshwari(OpenERP) (mma-openerp) wrote :

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
Revision history for this message
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 feedback.openerp.com

Changed in openobject-addons:
status: Fix Committed → Invalid
Changed in therp-backports:
importance: Undecided → Low
importance: Low → Wishlist
status: New → Fix Committed
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

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 (https://lists.launchpad.net/openerp-expert-accounting/msg01607.html).

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)
Changed in therp-backports:
milestone: 6.1-maintenance → 7.0-maintenance
Revision history for this message
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?

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

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.

Revision history for this message
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  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.