Skip to content

Commit

Permalink
[IMP] fix tests because of new required fields
Browse files Browse the repository at this point in the history
  • Loading branch information
damdam-s committed Sep 17, 2015
1 parent a8d6646 commit 6b4b0d3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
14 changes: 13 additions & 1 deletion magentoerpconnect/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,22 @@ def product_type_get(self):
# ('downloadable', 'Downloadable Product'),
]

@api.model
def get_default_magento_tax(self):
mag_tax_obj = self.env['magento.tax.class']
tax_id = False
if self.backend_id:
tax_id = mag_tax_obj.search(
[('backend_id', '=', self.backend_id.id)])[0]
else:
tax_id = mag_tax_obj.search([])[0]
return tax_id

tax_class_id = fields.Many2one(comodel_name='magento.tax.class',
string='Tax class',
required=True,
ondelete='restrict')
ondelete='restrict',
default=get_default_magento_tax)
openerp_id = fields.Many2one(comodel_name='product.product',
string='Product',
required=True,
Expand Down
12 changes: 12 additions & 0 deletions magentoerpconnect/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class SetUpMagentoBase(common.TransactionCase):
def setUp(self):
super(SetUpMagentoBase, self).setUp()
self.backend_model = self.env['magento.backend']
self.mag_tax_class_obj = self.env['magento.tax.class']
self.session = ConnectorSession(self.env.cr, self.env.uid,
context=self.env.context)
warehouse = self.env.ref('stock.warehouse0')
Expand All @@ -200,6 +201,17 @@ def setUp(self):
'warehouse_id': warehouse.id,
'password': '42'}
)
default_tax_list = [
{'name': 'default', 'magento_id': '0'},
{'name': 'Taxable Goods', 'magento_id': '1'},
{'name': 'normal', 'magento_id': '2'},
{'name': 'Shipping', 'magento_id': '3'},
]
if not self.backend.tax_imported:
for tax_dict in default_tax_list:
tax_dict.update(backend_id=self.backend.id)
self.mag_tax_class_obj.create(tax_dict)
self.backend.tax_imported = True
self.backend_id = self.backend.id
# payment method needed to import a sale order
workflow = self.env.ref(
Expand Down
1 change: 1 addition & 0 deletions magentoerpconnect/tests/data_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8487,6 +8487,7 @@
'sku': '1114',
'small_image_label': None,
'status': '1',
'tax_class_id': '2',
'thumbnail_label': None,
'type': 'grouped',
'type_id': 'grouped',
Expand Down
13 changes: 13 additions & 0 deletions magentoerpconnect/tests/test_export_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def setUp(self):
super(TestExportInvoice, self).setUp()
backend_model = self.env['magento.backend']
self.mag_sale_model = self.env['magento.sale.order']
self.mag_tax_class_obj = self.env['magento.tax.class']
self.session = ConnectorSession(self.env.cr, self.env.uid,
context=self.env.context)
warehouse = self.env.ref('stock.warehouse0')
Expand All @@ -50,6 +51,18 @@ def setUp(self):
'username': 'guewen',
'warehouse_id': warehouse.id,
'password': '42'})
# create taxes
default_tax_list = [
{'name': 'default', 'magento_id': '0'},
{'name': 'Taxable Goods', 'magento_id': '1'},
{'name': 'normal', 'magento_id': '2'},
{'name': 'Shipping', 'magento_id': '3'},
]
if not backend.tax_imported:
for tax_dict in default_tax_list:
tax_dict.update(backend_id=backend.id)
self.mag_tax_class_obj.create(tax_dict)
backend.tax_imported = True
# payment method needed to import a sale order
workflow = self.env.ref('sale_automatic_workflow.manual_validation')
journal = self.env.ref('account.check_journal')
Expand Down
12 changes: 12 additions & 0 deletions magentoerpconnect/tests/test_related_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class TestRelatedActionStorage(common.TransactionCase):
def setUp(self):
super(TestRelatedActionStorage, self).setUp()
backend_model = self.env['magento.backend']
self.mag_tax_class_obj = self.env['magento.tax.class']
self.session = ConnectorSession(self.env.cr, self.env.uid,
context=self.env.context)
warehouse = self.env.ref('stock.warehouse0')
Expand All @@ -31,6 +32,17 @@ def setUp(self):
'username': 'username',
'warehouse_id': warehouse.id,
'password': '42'})
default_tax_list = [
{'name': 'default', 'magento_id': '0'},
{'name': 'Taxable Goods', 'magento_id': '1'},
{'name': 'normal', 'magento_id': '2'},
{'name': 'Shipping', 'magento_id': '3'},
]
if not self.backend.tax_imported:
for tax_dict in default_tax_list:
tax_dict.update(backend_id=self.backend.id)
self.mag_tax_class_obj.create(tax_dict)
self.backend.tax_imported = True
# import the base informations
with mock_api(magento_base_responses):
import_batch(self.session, 'magento.website', self.backend.id)
Expand Down

0 comments on commit 6b4b0d3

Please sign in to comment.