[future-trunk] tax synchronization error

Bug #1003608 reported by Kyle Waid
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
e-commerce-addons
Confirmed
Undecided
gekko tek

Bug Description

when using external taxes I can have an external tax == 0.0724233983287. OpenERP does not allow this level of configurability. When you try to import exact tax rate matching magento it will round up making it always be off on payment reconciliation.

Related branches

Revision history for this message
Kyle Waid (midwest) wrote :

2012-05-23 16:59:28,045 23270 ERROR ? Midwest Supplies: Error : No tax id found for the rate 0.0724233983287 with the tax include = False

Revision history for this message
Kyle Waid (midwest) wrote :

I solve the error. 2 problems.

1. In account.py of base_sale_multichannels it uses an evaluation of type of tax == sale. However, it should be a list evaluation of either sale, all. If you have the correct tax defined but you choose all it will fail to match the tax and raise exception, also notably fails the order from import.

2. Magento tax precision is higher than OpenERP. The tax does not match exactly and can result in a few pennies discrepancy in the order. I sincerely hope this does not prevent reconciliation of orders. To solve this it should reconcile orders that are within 50 cents, or we should alter the tax amount field and allow greater precision as to match exactly the magento tax.

class account_tax_code(osv.osv):
    _inherit='account.tax'

    def get_tax_from_rate(self, cr, uid, rate, is_tax_included=False, context=None):
        #TODO improve, if tax are not correctly mapped the order should be in exception (integration with sale_execption)
        tax_ids = self.pool.get('account.tax').search(cr, uid, [('price_include', '=', is_tax_included),
                ('type_tax_use', '=', 'sale'), ('amount', '>=', rate - 0.001), ('amount', '<=', rate + 0.001)])
        if tax_ids and len(tax_ids) > 0:
            return tax_ids[0]
        else:
        #try to find a tax with less precision
            tax_ids = self.pool.get('account.tax').search(cr, uid, [('price_include', '=', is_tax_included),
                    ('type_tax_use', '=', 'sale'), ('amount', '>=', rate - 0.01), ('amount', '<=', rate + 0.01)])
            if tax_ids and len(tax_ids) > 0:
                return tax_ids[0]
        return False

Changed in magentoerpconnect:
status: New → Confirmed
assignee: nobody → gekko tek (gekkotek)
Revision history for this message
Kyle Waid (midwest) wrote :

If you reject merge, you should clearly note in "use external taxes" that it will not work unless the tax configured is type sale

affects: magentoerpconnect → e-commerce-addons
Revision history for this message
David (dhecar) wrote :
Download full text (3.3 KiB)

With revision 289 i'm getting the same error:

MERCATO: Login Successful
2014-06-30 15:52:09,542 1674 INFO ? MERCATO: Missing openerp resource for object res.partner with external_id 395. Importing on the fly
2014-06-30 15:52:09,680 1674 INFO ? MERCATO: Calling Method:customer.info,Arguments:[u'395']
2014-06-30 15:52:10,405 1674 INFO ? MERCATO: Query Returned:{'store_id': '0', 'rp_token_created_at': None, 'website_id': '1', 'updated_at': '2014-04-09 07:19:49', 'prefix': None, 'created_in': 'Admin', 'rp_token': None, 'password_hash': '7769a624afa28254c9aa3d0a6b67771f:iSBQ7px7ZErVfZ0ffIKsSxJflMu61EWV', 'taxvat': None, 'increment_id': None, 'default_billing': '395', 'customer_id': '395', 'default_shipping': '395', 'email': '<email address hidden>', 'confirmation': 'FfsbKR', 'firstname': 'Stella', 'middlename': None, 'lastname': 'Oliver', 'suffix': None, 'dob': None, 'gender': None, 'created_at': '2014-04-09 07:19:47', 'disable_auto_group_change': '0', 'group_id': '1'}
2014-06-30 15:52:10,555 1674 WARNING ? openerp.osv.expression: The domain term '('referential_id', '=', [0])' should use the 'in' or 'not in' operator.
2014-06-30 15:52:10,927 1674 INFO ? MERCATO: Created in OpenERP res.partner from External Ref withexternal_id 395 and OpenERP id 22896 successfully
2014-06-30 15:52:11,001 1674 INFO ? MERCATO: Created in OpenERP res.partner.address from External Ref withalternative_keys False and OpenERP id 23707 successfully
2014-06-30 15:52:11,011 1674 INFO ? MERCATO: Updated in OpenERP res.partner.address from External Ref withalternative_keys False and OpenERP id 23707 successfully
2014-06-30 15:52:11,219 1674 ERROR ? MERCATO: Error : No tax id found for the rate 0.434475806452 with the tax include = False
Traceback (most recent call last):
  File "/opt/openerp-ocb/server_launch/openerp/addons/base_external_referentials/decorator.py", line 130, in wrapper
    response = func(self, import_cr, uid, external_session, resource, *args, **kwargs)
  File "/opt/openerp-ocb/server_launch/openerp/addons/base_sale_multichannels/sale.py", line 653, in _record_one_external_resource
    defaults=defaults, mapping=mapping, mapping_id=mapping_id, context=context)
  File "/opt/openerp-ocb/server_launch/openerp/addons/base_external_referentials/external_osv.py", line 727, in _record_one_external_resource
    existing_rec_id = self.oe_create(cr, uid, external_session, vals, resource, defaults, context=context)
  File "/opt/openerp-ocb/server_launch/openerp/addons/base_sale_multichannels/sale.py", line 759, in oe_create
    vals = self._convert_special_fields(cr, uid, vals, external_session.referential_id.id, context=context)
  File "/opt/openerp-ocb/server_launch/openerp/addons/base_sale_multichannels/sale.py", line 908, in _convert_special_fields
    vals = self._add_order_extra_line(cr, uid, vals, option, context=context)
  File "/opt/openerp-ocb/server_launch/openerp/addons/base_sale_multichannels/sale.py", line 983, in _add_order_extra_line
    raise except_osv(_('Error'), _('No tax id found for the rate %s with the tax include = %s')%(tax_rate, context.get('is_tax_included')))
except_osv: (u'Error', u'No tax id found for the rate 0.434475806452 with the...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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