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

[IMP] Add module to map product taxes. #213

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
19 changes: 19 additions & 0 deletions magentoerpconnect_product_tax/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- 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 magento

@magento(replacing=ProductImportMapper)
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>