Skip to content

Commit

Permalink
[IMP] Add module to map product taxes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusVMayor committed May 24, 2016
1 parent 2aea27d commit f1633a0
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
4 changes: 4 additions & 0 deletions magentoerpconnect_product_tax/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Comunitea
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
22 changes: 22 additions & 0 deletions magentoerpconnect_product_tax/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# © 2016 Comunitea
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Magento Connector Product Tax',
'version': "8.0.1.0.0",
'category': 'Connector',
'description': """
Maps product taxes based on their magento id
""",
'author': 'Factor Libre S.L., Odoo Community Association (OCA)',
'website': 'http://www.factorlibre.com/',
'license': 'AGPL-3',
'depends': [
'magentoerpconnect',
'account',
],
'data': ['views/account_view.xml'],
'application': False,
'installable': True,
}
5 changes: 5 additions & 0 deletions magentoerpconnect_product_tax/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Comunitea
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account
from . import product
11 changes: 11 additions & 0 deletions magentoerpconnect_product_tax/models/account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# © 2016 Comunitea
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, fields


class AccountTax(models.Model):
_inherit = 'account.tax'

magento_tax_id = fields.Integer('Magento Tax ID')
20 changes: 20 additions & 0 deletions magentoerpconnect_product_tax/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# © 2016 Comunitea
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp.addons.connector.unit.mapper import mapping
from openerp.addons.magentoerpconnect.product import ProductImportMapper
from openerp.addons.magentoerpconnect.backend import magento1700


@magento1700
class TaxProductImportMapper(ProductImportMapper):
_model_name = 'magento.product.product'

@mapping
def tax_id(self, record):
tax_class_id = record.get('tax_class_id', '-1')
tax = self.session.env['account.tax'].search(
[('magento_tax_id', '=', tax_class_id)])
result = {'taxes_id': [(6, 0, tax.ids)]}
return result
17 changes: 17 additions & 0 deletions magentoerpconnect_product_tax/views/account_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Comunitea
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<openerp>
<data>
<record id="account_tax_magento_connector_form_view" model="ir.ui.view">
<field name="name">account.tax.form</field>
<field name="model">account.tax</field>
<field name="inherit_id" ref="account.view_tax_form" />
<field name="arch" type="xml">
<field name="child_depend" position="after">
<field name="magento_tax_id"/>
</field>
</field>
</record>
</data>
</openerp>

0 comments on commit f1633a0

Please sign in to comment.