Kuldeep Joshi(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-import_quickbooks-backlog-5-new-kjo 
into lp:~openerp-dev/openobject-addons/trunk-import_quickbooks.

Requested reviews:
  Bhumika (OpenERP) (sbh-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-import_quickbooks-backlog-5-new-kjo/+merge/74079

1 Change the Wizard
2 Import all the Data
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-import_quickbooks-backlog-5-new-kjo/+merge/74079
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-import_quickbooks.
=== modified file 'import_base/import_framework.py'
--- import_base/import_framework.py	2011-08-26 05:29:46 +0000
+++ import_base/import_framework.py	2011-09-05 11:22:29 +0000
@@ -135,7 +135,6 @@
             return (0, 'No data in this table')
         mapping['id'] = 'id_new'
         res = []
-        
         self_dependencies = []
         for k in mapping.keys():
             if '_parent' in k:
@@ -150,8 +149,8 @@
         model_obj = self.obj.pool.get(model)
         if not model_obj:
             raise ValueError("%s is not a valid model name" % model)
-        
         (p, r, warning, s) = model_obj.import_data(self.cr, self.uid, fields, res, mode='update', current_module=self.module_name, noupdate=True, context=self.context)
+        print "=====>>>>", (p, r, warning, s), model
         for (field, field_name) in self_dependencies:
             self._import_self_dependencies(model_obj, field, datas)
         return (len(res), warning)
@@ -345,7 +344,9 @@
                     imported.add(table)
             self.cr.commit()
         except Exception, e:
-            pass
+            import traceback,sys
+            info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
+            print "=========>", info
 
         finally:
             self.cr.close()
@@ -379,7 +380,6 @@
         tools.email_send(
                 '[email protected]',
                 self.email,
-
                 self.get_email_subject(result),
                 self.get_email_body(result),
             )

=== modified file 'import_quickbooks/__openerp__.py'
--- import_quickbooks/__openerp__.py	2011-08-11 06:00:46 +0000
+++ import_quickbooks/__openerp__.py	2011-09-05 11:22:29 +0000
@@ -28,7 +28,7 @@
     'description': """ QuickBooks Wordplace / Intuit Partner Platform / Intuit Data Services """,
     'author': 'OpenERP SA',
     'website': 'http://www.openerp.com',
-    'depends': ['base','import_base','account','purchase', 'account_voucher'],
+    'depends': ['base', 'import_base', 'account', 'product', 'purchase', 'hr', 'account_voucher'],
     'init_xml': [],
     'update_xml': [
                 'security/quickbooks_login_service_security.xml',

=== modified file 'import_quickbooks/quickbooks/ippids/service/services.py'
--- import_quickbooks/quickbooks/ippids/service/services.py	2011-08-26 05:29:46 +0000
+++ import_quickbooks/quickbooks/ippids/service/services.py	2011-09-05 11:22:29 +0000
@@ -189,6 +189,132 @@
 
         return response
 
+class EmployeeService(import_quickbooks.quickbooks.ippids.service.abstract.AbstractService):
+
+    def list_all(self, context, realm=None):
+
+        IPP = context._IPP
+
+        if realm is None:
+            realm = context.get_realm()
+
+        type = import_quickbooks.quickbooks.ippids.IPP.REQUEST_IDS
+        url = "https://services.intuit.com/sb/employee/v2/"; + str(realm)
+        action = None
+
+        xml = '''<?xml version="1.0" encoding="UTF-8"?>
+<EmployeeQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://www.intuit.com/sb/cdm/v2";>
+</EmployeeQuery>'''
+
+        response = IPP._request(context, type, url, action, xml)
+
+        return response
+    
+class JobTypeService(import_quickbooks.quickbooks.ippids.service.abstract.AbstractService):
+
+    def list_all(self, context, realm=None):
+
+        IPP = context._IPP
+
+        if realm is None:
+            realm = context.get_realm()
+
+        type = import_quickbooks.quickbooks.ippids.IPP.REQUEST_IDS
+        url = "https://services.intuit.com/sb/jobtype/v2/"; + str(realm)
+        action = None
+
+        xml = '''<?xml version="1.0" encoding="UTF-8"?>
+<JobTypeQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://www.intuit.com/sb/cdm/v2";>
+</JobTypeQuery>'''
+
+        response = IPP._request(context, type, url, action, xml)
+
+        return response
+   
+class BillService(import_quickbooks.quickbooks.ippids.service.abstract.AbstractService):
+
+    def list_all(self, context, realm=None):
+
+        IPP = context._IPP
+
+        if realm is None:
+            realm = context.get_realm()
+
+        type = import_quickbooks.quickbooks.ippids.IPP.REQUEST_IDS
+        url = "https://services.intuit.com/sb/bill/v2/"; + str(realm)
+        action = None
+
+        xml = '''<?xml version="1.0" encoding="UTF-8"?>
+<BillQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://www.intuit.com/sb/cdm/v2";>
+</BillQuery>'''
+
+        response = IPP._request(context, type, url, action, xml)
+
+        return response
+  
+class CustomerTypeService(import_quickbooks.quickbooks.ippids.service.abstract.AbstractService):
+
+    def list_all(self, context, realm=None):
+
+        IPP = context._IPP
+
+        if realm is None:
+            realm = context.get_realm()
+
+        type = import_quickbooks.quickbooks.ippids.IPP.REQUEST_IDS
+        url = "https://services.intuit.com/sb/customertype/v2/"; + str(realm)
+        action = None
+
+        xml = '''<?xml version="1.0" encoding="UTF-8"?>
+<CustomerTypeQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://www.intuit.com/sb/cdm/v2";>
+</CustomerTypeQuery>'''
+
+        response = IPP._request(context, type, url, action, xml)
+
+        return response
+    
+class VendorTypeService(import_quickbooks.quickbooks.ippids.service.abstract.AbstractService):
+
+    def list_all(self, context, realm=None):
+
+        IPP = context._IPP
+
+        if realm is None:
+            realm = context.get_realm()
+
+        type = import_quickbooks.quickbooks.ippids.IPP.REQUEST_IDS
+        url = "https://services.intuit.com/sb/vendortype/v2/"; + str(realm)
+        action = None
+
+        xml = '''<?xml version="1.0" encoding="UTF-8"?>
+<VendorTypeQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://www.intuit.com/sb/cdm/v2";>
+</VendorTypeQuery>'''
+
+        response = IPP._request(context, type, url, action, xml)
+
+        return response
+
+class PaymentService(import_quickbooks.quickbooks.ippids.service.abstract.AbstractService):
+
+    def list_all(self, context, realm=None):
+        IPP = context._IPP
+
+        if realm is None:
+            realm = context.get_realm()
+
+        type = import_quickbooks.quickbooks.ippids.IPP.REQUEST_IDS
+        url = "https://services.intuit.com/sb/payment/v2/"; + str(realm)
+        action = None
+
+        xml = '''<?xml version="1.0" encoding="UTF-8"?>
+<PaymentQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://www.intuit.com/sb/cdm/v2";>
+</PaymentQuery>'''
+
+
+        response = IPP._request(context, type, url, action, xml)
+        
+        return response
+
 class PaymentService(import_quickbooks.quickbooks.ippids.service.abstract.AbstractService):
 
     def list_all(self, context, realm=None):
@@ -290,4 +416,4 @@
 </PaymentQuery>'''
 
         response = IPP._request(context, type, url, action, xml)
-        return response
\ No newline at end of file
+        return response

=== modified file 'import_quickbooks/wizard/import_data_from_quickbook.py'
--- import_quickbooks/wizard/import_data_from_quickbook.py	2011-08-30 11:51:37 +0000
+++ import_quickbooks/wizard/import_data_from_quickbook.py	2011-09-05 11:22:29 +0000
@@ -40,10 +40,17 @@
     TABLE_ACCOUNT_PAYMENT = 'PaymentMethod'
     TABLE_CUSTOMER_INVOICE = 'Invoice'
     TABLE_VENDOR = 'Vendor'
+    TABLE_PURCHASE_INVOICE = 'Bill'
     TABLE_PURCHASE = 'PurchaseOrder'
     TABLE_CUSTOMER_PAYMENT = 'Payment'
     TABLE_SALE_RECEIPT = 'SalesReceipt'
     TABLE_ITEM = 'Item'
+    TABLE_EMPLOYEE_JOB = 'JobType'
+    TABLE_EMPLOYEE = 'Employee'
+    TABLE_PURCHASE_ORDER = 'PurchaseOrder'
+    TABLE_SALE_TAX_CODE = 'SalesTaxCode'
+    TABLE_CUSTOMER_CATEGORY = 'CustomerType'
+    TABLE_VENDOR_CATEGORY = 'VendorType'
     _realm_id = False
     _ticket = False
     parent_id = []
@@ -62,10 +69,16 @@
             self.TABLE_ACCOUNT: AccountService(),
             self.TABLE_ACCOUNT_TAX: AccountService(),
             self.TABLE_ACCOUNT_PAYMENT: AccountService(),
+            self.TABLE_SALE_TAX_CODE: AccountService(),
             self.TABLE_CUSTOMER_INVOICE: InvoiceService(),
             self.TABLE_VENDOR: VendorService(),
-            self.TABLE_PURCHASE: PurchaseOrderService(),
+            self.TABLE_PURCHASE_INVOICE: BillService(),
             self.TABLE_ITEM: ItemService(),
+            self.TABLE_EMPLOYEE: EmployeeService(),
+            self.TABLE_EMPLOYEE_JOB: JobTypeService(),
+            self.TABLE_PURCHASE_ORDER: PurchaseOrderService(),
+            self.TABLE_CUSTOMER_CATEGORY: CustomerTypeService(),
+            self.TABLE_VENDOR_CATEGORY: VendorTypeService(),
             self.TABLE_CUSTOMER_PAYMENT: PaymentService(),
             self.TABLE_SALE_RECEIPT: SalesReceiptService(),
         }
@@ -114,16 +127,35 @@
             table_list.append(table_dic)
         return table_list
 
+    def get_saletax_code(self, table):
+        svc = self.get_service(table)
+        pay_xml = svc.list_all_tax_codes(self._ticket, self._realm_id)
+        pay_dict = xmlreader.xmltodict(pay_xml)
+        table_list = []
+        pay_lst = pay_dict.get('SalesTaxCodes')[0].get('SalesTaxCode')
+        for table_data in pay_lst:
+            table_dic = {}
+            for key, val in table_data.items():
+                table_dic.update({key: val[0]})
+            table_list.append(table_dic)
+        return table_list
+
     def get_data(self, table):
         vals = {
             self.TABLE_CUSTOMER: self.get_values('Customer'),
             self.TABLE_ACCOUNT: self.get_values('Account'),
             self.TABLE_ACCOUNT_TAX: self.get_salesTax('ItemSalesTax'),
             self.TABLE_ACCOUNT_PAYMENT: self.get_paymentTerm('PaymentMethod'),
+            self.TABLE_SALE_TAX_CODE: self.get_saletax_code('SalesTaxCode'),
             self.TABLE_CUSTOMER_INVOICE: self.get_values('Invoice'),
             self.TABLE_VENDOR: self.get_values('Vendor'),
-            self.TABLE_PURCHASE: self.get_values('PurchaseOrder'),
+            self.TABLE_PURCHASE_INVOICE: self.get_values('Bill'),
             self.TABLE_ITEM: self.get_values('Item'),
+            self.TABLE_EMPLOYEE: self.get_values('Employee'),
+            self.TABLE_EMPLOYEE_JOB: self.get_values('JobType'),
+            self.TABLE_PURCHASE_ORDER: self.get_values('PurchaseOrder'),
+            self.TABLE_CUSTOMER_CATEGORY: self.get_values('CustomerType'),
+            self.TABLE_VENDOR_CATEGORY: self.get_values('VendorType'),
             self.TABLE_CUSTOMER_PAYMENT: self.get_values('Payment'),
             self.TABLE_SALE_RECEIPT: self.get_values('SalesReceipt'),
         }
@@ -137,8 +169,14 @@
             self.TABLE_ACCOUNT_PAYMENT: self.get_account_payment_term_mapping(),
             self.TABLE_CUSTOMER_INVOICE: self.get_customer_invoice_mapping(),
             self.TABLE_VENDOR: self.get_vendor_mapping(),
-            self.TABLE_PURCHASE: self.get_purchase_order_mapping(),
+            self.TABLE_PURCHASE_INVOICE: self.get_purchase_invoice_mapping(),
             self.TABLE_ITEM: self.get_item_mapping(),
+            self.TABLE_EMPLOYEE: self.get_employee_mapping(),
+            self.TABLE_EMPLOYEE_JOB: self.get_employee_job_mapping(),
+            self.TABLE_PURCHASE_ORDER: self.get_purchase_order_mapping(),
+            self.TABLE_SALE_TAX_CODE: self.get_saletax_code_mapping(),
+            self.TABLE_CUSTOMER_CATEGORY: self.get_partner_category_mapping(),
+            self.TABLE_VENDOR_CATEGORY: self.get_vendor_category_mapping(),
             self.TABLE_CUSTOMER_PAYMENT: self.get_customer_payment_mapping(),
             self.TABLE_SALE_RECEIPT: self.get_sales_receipt_mapping(),
     }
@@ -257,6 +295,11 @@
                 if address.get('Tag')[0] == 'Shipping':
                     address_id.append(self.get_address_type(vals, address, 'delivery'))
         return ','.join(address_id)
+    
+    def get_partner_category(self, vals, field1, field2):
+        if vals.get(field1):
+            return self.mapped_id_if_exist('res.partner.category', [('name', '=', vals.get(field1))], 'res_partner_category', vals.get(field2))
+        return False
 
     def account_receivable(self,val):
         receivable_id = self.mapped_id_if_exist('account.account', [('name', '=', 'Accounts Receivable')], 'receivalble_account', 'id')
@@ -273,19 +316,29 @@
     def get_customer_mapping(self):
         return {
             'model': 'res.partner',
-            'dependencies': [self.TABLE_ACCOUNT],
+            'dependencies': [self.TABLE_ACCOUNT, self.TABLE_CUSTOMER_CATEGORY],
             'map': {
                     'id': 'Id',
                     'name': 'Name',
                     'customer': const("1"),
                     'supplier': const("0"),
                     'address/id': self.get_partner_address,
+                    'category_id/id': call(self.get_partner_category, 'CustomerTypeName', 'CustomerTypeId'),
                     'comment': ppconcat('TaxName', 'OpenBalanceDate', 'MiddleName', 'FamilyName'),
                     'property_account_receivable/id': self.account_receivable,
                     'property_account_payable/id': self.account_payable, 
                     'property_payment_term/id': self.customer_payment_term,
                     }
                 }
+                
+    def get_partner_category_mapping(self):
+        return {
+                'model': 'res.partner.category',
+                'map': {
+                        'id': 'id',
+                        'name': 'Name',
+                        }
+                }
 
     def account_code(self, val):
         if val.get('AcctNum'):
@@ -293,12 +346,10 @@
         return 'QB0' + val.get('Id')
 
     def user_type(self, val, subtype):
-        ids = []
         fields = ['name', 'code', 'report_type', 'close_method']
         data = [subtype, subtype, 'asset', 'balance']
         name = val.get('Id')
-        ids.append(self.import_object(fields, data, 'account.account.type', 'account_type', name, [('name', '=', subtype), ('code', '=', subtype)]))
-        return ','.join(ids)
+        return self.import_object(fields, data, 'account.account.type', 'account_type', name, [('name', '=', subtype), ('code', '=', subtype)])
 
     def set_base_account(self):
         account_type = self.mapped_id_if_exist('account.account.type', [('name', '=', 'Liability')], 'account_account_type', 'Liability')
@@ -323,6 +374,7 @@
         'Cost of Goods Sold': 'other',
         'Other Current Liability': 'liquidity',
         'Bank': 'liquidity',
+        'Cost of Goods Sold': 'other',
         'Other Expense': 'other',
         'Equity': 'other',
         'Accounts Payable': 'payable',
@@ -333,7 +385,7 @@
 
     def set_parent_account(self, val):
         if val.get('AccountParentName'):
-            account_parent_id = self.mapped_id_if_exist('account.account', [('name', '=', val.get('AccountParentName'))], self.TABLE_ACCOUNT, val.get('AccountParentId'))
+            account_parent_id = self.mapped_id_if_exist('account.account', [('name', '=', val.get('AccountParentName'))], self.TABLE_ACCOUNT, 'QB'+val.get('AccountParentId'))
             if not account_parent_id:
                 account_type = self.mapped_id_if_exist('account.account.type', [('name', '=', val.get('Subtype'))], 'account_type', val.get('Id'))
                 fields = ['name', 'code', 'type', 'user_type/id']
@@ -361,14 +413,14 @@
             self.not_account_type(val)
         if val.get('Id') in self.parent_id:
             val['Type'] = 'View'
-            return val
+            return val         
         val['Type'] = val.get('Subtype')
         return val
 
     def get_account_mapping(self):
         return {
             'model': 'account.account',
-            'dependencies': [self.TABLE_ACCOUNT_TAX, self.TABLE_ACCOUNT_PAYMENT],
+            'dependencies': [self.TABLE_ACCOUNT_TAX, self.TABLE_ACCOUNT_PAYMENT, self.TABLE_SALE_TAX_CODE],
             'hook': self.set_account_type,
             'map': {
                     'id': 'Id',
@@ -376,7 +428,7 @@
                     'code': self.account_code,
                     'user_type/id': call(self.user_type, value('Subtype')),
                     'parent_id/id': self.set_parent_account,
-                    'type': map_val('Type', self.type_dict, 'view'),
+                    'type': map_val('Type', self.type_dict, 'other'),
                     'note': ppconcat('CurrentBalance', 'Subtype'),
                     'reconcile': const("1"),
                     }
@@ -415,6 +467,16 @@
                     'payment_id/id': self.get_account_payment,
                     }
                }
+               
+    def get_saletax_code_mapping(self):
+        return {
+                'model': 'account.tax.code',
+                'map': {
+                        'id': 'Id',
+                        'name': 'Name',
+                        'info': ppconcat('Desc','Taxable'),
+                        }
+                }
 
     def get_value(self, val, field1, field2):
         if val.get(field1):
@@ -430,7 +492,7 @@
         return False
 
     def get_partner_id(self, val, field1, field2):
-        partner_id = self.mapped_id_if_exist('res.partner', [('name', '=', self.get_value(val, 'Header', field1))], self.TABLE_CUSTOMER, self.get_value(val, 'Header', field2))
+        partner_id = self.mapped_id_if_exist('res.partner', [('name', '=', self.get_value(val, 'Header', field1))], 'res_partner', self.get_value(val, 'Header', field2))
         if not partner_id:
             return False
         return partner_id
@@ -465,9 +527,9 @@
         account_id = self.mapped_id_if_exist('account.account', [('name', '=', self.get_value(val, 'Header', field1))], self.TABLE_ACCOUNT, self.get_value(val, 'Header', field2))
         return account_id
 
-    def get_invoice_line(self, vals):
+    def get_invoice_line(self, vals, field1, field2):
         if vals.get('Line'):
-            account_id = self.get_account_id(vals, 'ARAccountName', 'ARAccountId')
+            account_id = self.get_account_id(vals, field1, field2)
             return self.get_line(vals, account_id)
         return False
 
@@ -508,7 +570,7 @@
                     'address_contact_id/id': call(self.get_partner_address_id, 'RemitToId'),
                     'date_due': call(self.get_fieldvalue, value('Header'), 'DueDate'),
                     'comment': call(self.get_fieldvalue, value('Header'), 'Msg'),
-                    'invoice_line/id': self.get_invoice_line,
+                    'invoice_line/id': call(self.get_invoice_line, 'ARAccountName', 'ARAccountId'),
                     'payment_term/id': self.get_payment_term,
                     'tax_line/id': self.get_tax_line,
                     'type': const('out_invoice'),
@@ -518,16 +580,27 @@
     def get_vendor_mapping(self):
         return {
             'model': 'res.partner',
+            'dependencies': [self.TABLE_VENDOR_CATEGORY],
             'map': {
                     'id': 'Id',
                     'name': 'Name',
                     'customer': const("0"),
                     'supplier': const("1"),
                     'address/id': self.get_partner_address,
+                    'category_id/id': call(self.get_partner_category, 'VendorTypeName', 'VendorTypeId'),
                     'comment': ppconcat('OpenBalanceDate', 'MiddleName', 'FamilyName'),
                     }
                 }
 
+    def get_vendor_category_mapping(self):
+        return {
+               'model': 'res.partner.category',
+               'map': {
+                        'id': 'Id',
+                        'name': 'Name',        
+                      } 
+                }
+
     def get_category(self, val, category):
         category_id = []
         fields = ['name']
@@ -613,14 +686,65 @@
         for val in vals.get('Line'):
             if val.get('ItemId'):
                 product_id = self.mapped_id_if_exist('product.product', [('name', '=', val.get('ItemName'))], self.TABLE_ITEM, val.get('ItemId')[0])
+                tax_id = False
+                if vals.get('Header', {}).get('TaxName'):
+                    tax_id = self.mapped_id_if_exist('account.tax', [('name', '=', vals.get('Header', {}).get('TaxName')[0])], self.TABLE_ACCOUNT_TAX, vals.get('Header', {}).get('TaxId')[0])
                 date = self.get_value(vals, 'Header', 'TxnDate')
                 uom_id = self.mapped_id_if_exist('product.uom', [('name', '=', 'PCE')], 'product_uom', 'PCE')
-                fields = ['name', 'product_qty', 'price_unit', 'product_id/id', 'date_planned', 'product_uom/id', 'order_id/id']
-                data = [val.get('Desc', 'test')[0], val.get('Qty') and val.get('Qty')[0], val.get('UnitPrice') and val.get('UnitPrice')[0], product_id, date, uom_id, purchase_id]
+                fields = ['name', 'product_qty', 'price_unit', 'product_id/id', 'date_planned', 'product_uom/id', 'order_id/id', 'invoice_line_tax_id/id']
+                data = [val.get('Desc', 'test')[0], val.get('Qty') and val.get('Qty')[0], val.get('UnitPrice') and val.get('UnitPrice')[0], product_id, date, uom_id, purchase_id, tax_id]
                 name = 'Line' + val.get('Id')[0]
                 line_ids.append(self.import_object(fields, data, 'purchase.order.line', 'purchase_order_line', name, False))
         return ','.join(line_ids)
 
+    def get_journal_id(self, val, field1, field2, field3):
+        journal_id = self.mapped_id_if_exist('account.journal', [('name', '=', field1), ('code', '=', field2)], 'account_journal', field2)
+        if not journal_id:
+            view_id = self.mapped_id_if_exist('account.journal.view', [('name', '=', 'Sale/Purchase Journal View')], 'account_journal_view', 'id')
+            sequence_id = self.mapped_id_if_exist('ir.sequence', [('name', '=', field1)], 'sequence', 'id')
+            fields = ['name', 'code', 'type', 'view_id/id', 'sequence_id/id']
+            data = [field1, field2, field3, view_id, sequence_id]
+            name = field2
+            journal_id = self.import_object(fields, data, 'account.journal', 'account_journal', name)
+        return journal_id
+
+    def get_purchase_line(self, val):
+        account_id = self.mapped_id_if_exist('account.account', [('name', '=', 'Accounts Payable')], 'account_account', 'id')
+        return self.get_line(val, account_id)
+
+    def get_total(self, vals):
+        vals['Total'] = vals.get('Header', {}).get('TotalAmt')[0]
+        vals['Type'] = vals.get('Header', {}).get('Status')[0]
+        return vals
+
+    payment_state = {
+        'Payable': 'open',
+        'Paid': 'paid',
+    }
+    
+    def get_payment_term(self, val):
+        term_id = self.mapped_id_if_exist('account.payment.term', [('name', '=', self.get_value(val, 'Header', 'SalesTermName'))], self.TABLE_ACCOUNT_PAYMENT, self.get_value(val, 'Header', 'SalesTermId'))
+        return term_id
+    
+    def get_purchase_invoice_mapping(self):
+        return {
+            'model': 'account.invoice',
+            'dependencies': [self.TABLE_ITEM],
+            'map': {
+                    'id': 'Id',
+                    'partner_id/id': call(self.get_partner_id, 'VendorName', 'VendorId'),
+                    'journal_id/id': call(self.get_journal_id, 'Purchase Journal', 'EXJ', 'purchase'),
+                    'account_id/id': call(self.get_account_id, 'APAccountName', 'APAccountId'),
+                    'address_invoice_id/id': call(self.get_partner_address_id, 'VendorId'),
+                    'date_invoice': call(self.get_fieldvalue, value('Header'), 'TxnDate'),
+                    'address_contact_id/id': call(self.get_partner_address_id, 'VendorId'),
+                    'date_due': call(self.get_fieldvalue, value('Header'), 'DueDate'),
+                    'comment': call(self.get_fieldvalue, value('Header'), 'Note'),
+                    'invoice_line/id': call(self.get_invoice_line, 'APAccountName', 'APAccountId'),
+                    'payment_term/id': self.get_payment_term,
+                    'type': const('in_invoice'),
+                    }
+                }
     def set_purchase_order(self, val):
         partner_id = self.get_partner_id(val, 'VendorName', 'VendorId')
         partner_address_id = self.get_partner_address_id(val, 'VendorId')
@@ -628,7 +752,6 @@
         date = self.get_value(val, 'Header', 'TxnDate')
         due_date = self.get_value(val, 'Header', 'DueDate')
         location_id = self.get_location(val)
-        currency_id = self.get_currency(val, 'EUR', 'EUR')
         field = ['date_order', 'partner_id/id', 'partner_address_id/id', 'pricelist_id/id', 'invoice_method', 'id', 'minimum_planned_date', 'location_id/id']
         dic = [date, partner_id, partner_address_id, pricelist_id, 'manual', val.get('Id'), due_date, location_id]
         name = val.get('Id')
@@ -660,10 +783,10 @@
         partner_id = self.get_partner_id(val, 'CustomerName', 'CustomerId')
         amount = self.get_value(val, 'Header', 'TotalAmt')
         val['Type'] = val.get('Header', {}).get('Status')[0]
-        journal_id = self.get_journal_id(val, 'Cash', 'BNK3', 'cash')
+        journal_id = self.get_journal_id(val, 'Cash', 'BNK2', 'cash')
         date = self.get_value(val, 'Header', 'TxnDate')
         currency_id = self.get_currency(val, 'EUR', 'EUR')
-        account_id = self.mapped_id_if_exist('account.account', [('name', '=', val.get('Header', {}).get('DepositToAccountName')[0])], self.TABLE_ACCOUNT, val.get('Header', {}).get('DepositToAccountId')[0])#        currency_id = self.get_currency(val, 'EUR', 'EUR')
+        account_id = self.mapped_id_if_exist('account.account', [('name', '=', val.get('Header', {}).get('DepositToAccountName')[0])], self.TABLE_ACCOUNT, val.get('Header', {}).get('DepositToAccountId')[0])
         field = ['partner_id/id', 'journal_id/id', 'amount', 'date', 'account_id/id', 'currency_id/id', 'id', 'type']
         dic = [partner_id, journal_id, amount, date, account_id, currency_id, val.get('Id'), 'receipt']
         name = val.get('Id')
@@ -675,7 +798,7 @@
     def get_customer_payment_mapping(self):
         return {
             'model': 'account.voucher',
-#            'dependencies': [self.TABLE_CUSTOMER_INVOICE],
+            'dependencies': [self.TABLE_CUSTOMER_INVOICE],
             'map': {
                     'line_ids/id': self.get_voucher_line,
                     }
@@ -684,24 +807,88 @@
     def get_sale_tax_line(self, val):
         sale_tax_id = self.mapped_id_if_exist('account.tax', [('name' , '=', self.get_value(val, 'TaxLine', 'TaxName'))], self.TABLE_ACCOUNT_TAX, self.get_value(val, 'TaxLine', 'TaxId'))
         return sale_tax_id
+    
+    def get_receipt_line(self, vals):
+        val = self.get_sale_receipt(vals)
+        voucher_line = []
+        voucher_id = self.mapped_id_if_exist('account.voucher', [('tax_amount', '=', self.get_value(val, 'TaxLine', 'Amount'))], self.TABLE_SALE_RECEIPT, vals.get('Id'))
+        account_id = self.get_account_id(val, 'DepositToAccountName', 'DepositToAccountId')
+        partner_id = self.get_partner_id(val, 'CustomerName', 'CustomerId')
+        for val in vals.get('Line'):
+            field = ['name', 'account_id/id', 'partner_id/id', 'amount', 'type', 'voucher_id/id']
+            data = [self.get_value(vals, 'Header', 'CustomerName'), account_id, partner_id, val.get('Amount')[0], 'cr', voucher_id]
+            name = 'receipt_'+ val.get('Id')[0]
+            voucher_line.append(self.import_object(field, data, 'account.voucher.line', 'account_voucher_line', name))
+        return ','.join(voucher_line)
 
+    def get_sale_receipt(self,val):
+        partner_id = self.get_partner_id(val, 'CustomerName', 'CustomerId')
+        amount = self.get_value(val, 'Header', 'TotalAmt')
+        journal_id = self.get_journal_id(val, 'Sales Journal', 'SAJ', 'sale')
+        date = self.get_value(val, 'Header', 'TxnDate')
+        currency_id = self.get_currency(val, 'EUR', 'EUR')
+        tax_amount = self.get_value(val, 'TaxLine', 'Amount')
+        account_id = self.get_account_id(val, 'DepositToAccountName', 'DepositToAccountId')
+        field = ['partner_id/id', 'journal_id/id', 'amount', 'date', 'account_id/id', 'currency_id/id', 'id', 'type', 'tax_amount']
+        dic = [partner_id, journal_id, amount, date, account_id, currency_id, val.get('Id'), 'sale', tax_amount]
+        name = val.get('Id')
+        self.import_object(field, dic, 'account.voucher', self.TABLE_SALE_RECEIPT, name)
+        return val
+    
     def get_sales_receipt_mapping(self):
         return {
             'model': 'account.voucher',
             'dependencies': [self.TABLE_ACCOUNT, self.TABLE_CUSTOMER],
             'map': {
-                    'id': 'Id',
-                    'partner_id/id': call(self.get_partner_id, 'CustomerName', 'CustomerId'),
-                    'journal_id/id': call(self.get_journal_id, 'Sales Journal', 'SAJ', 'sale'),
-                    'account_id/id': call(self.get_account_id, 'DepositToAccountName', 'DepositToAccountId'),
-                    'date': call(self.get_fieldvalue, value('Header'), 'TxnDate'),
                     'tax_id/id': self.get_sale_tax_line,
-                    'tax_amount': call(self.get_value, 'TaxLine', 'Amount'),
-                    'type': const('sale'),
-                    'amount': call(self.get_value, 'Header', 'TotalAmt'),
-                    'currency_id/id': call(self.get_currency, 'EUR', 'EUR'),
-                    }
-                }
+                    'line_ids/id': self.get_receipt_line,
+                    }
+                }
+        
+    def get_country(self, val):
+        for vals in val.get('Address'):
+            country_id = self.mapped_id_if_exist('res.country', [('code', '=', vals.get('CountrySubDivisionCode')[0])], 'res_country', 'id')
+        return country_id
+
+    def get_employee_category(self,val):
+        category_id = self.mapped_id_if_exist('hr.employee.category', [('name', '=', val.get('EmployeeType'))], 'employee_category', val.get('Id'))
+        if not category_id:
+            return self.import_object(['name'], [val.get('EmployeeType')], 'hr.employee.category', 'employee_category', val.get('Id'))
+        return category_id
+    
+    def set_user_group(self, val):
+        group_id =  self.mapped_id_if_exist('res.groups', [('name', '=', 'QuickBook / User')], 'res_groups', 'id')
+        return group_id
+
+    def get_user(self, val):
+        field = ['name', 'login', 'password', 'groups_id/id']
+        data = [val.get('Name'), val.get('GivenName'), val.get('GivenName'), self.set_user_group(val)]
+        user_id = self.import_object(field, data, 'res.users', 'res_users', val.get('Id'))
+        return user_id
+        
+    def get_employee_mapping(self):
+        return {
+            'model': 'hr.employee',
+            'map': {
+                    'id': 'Id',
+                    'name': 'Name',
+                    'user_id/id': self.get_user,
+                    'address_home_id/id': self.get_partner_address,
+                    'country_id/id': self.get_country,
+                    'category_ids/id': self.get_employee_category,
+                    'work_phone': call(self.get_value, 'Phone', 'FreeFormNumber'),
+                    }
+                }
+        
+    def get_employee_job_mapping(self):
+        return {
+            'model': 'hr.job',
+            'map': {
+                    'id': 'Id',
+                    'name': 'Name',
+                    }
+                }
+               
 
 class import_quickbooks(osv.osv_memory):
 
@@ -716,15 +903,23 @@
         'vendor': fields.boolean('Vendors', help="Import vendors."),
         'item': fields.boolean('Items & Services', help="Import items."),
 #        'sale': fields.boolean('Sale Orders', help="Not implement yet.",readonly=True),
+        'account': fields.boolean('Accounts', help="Import accounts."),
+        'customer_invoice': fields.boolean('Customer Invoices', help="Import Customer Invoices."),
+        'purchase': fields.boolean('Purchase Orders', help="Import purchase"),
+        'customer_payment': fields.boolean('Purchase Payment', help="Import Customer Payment"),
+        'employee': fields.boolean('Employees', help="Import Employees"),
+        'department': fields.boolean('Department', help="Import Department"),
         'account': fields.boolean('Accounts', help="Import Accounts."),
-        'invoice': fields.boolean('Customer Invoices', help="Import Customer Invoices."),
-        'payment': fields.boolean('Customer Payment', hep="Import Customer Payment"),
         'purchase': fields.boolean('Purchase Orders', help="Import Purchase Orders"),
         'sale_receipt': fields.boolean('Sales Receipt', help="Import Sales Receipt"),
-#        'employee': fields.boolean('Employees', help="Not implement yet.",readonly=True),
+        'invoice': fields.boolean('Purchase Invoice', help="Import Purchase Invoice"),
         'email': fields.char('Notify end of import to', size=64, help="Email address of the user to be notified when the import is complete."),
 
-        'name': fields.char('Instance Name', size=50, help="For Multiple Instance Import"),
+        'name': fields.char('Instance Name', size=50, required=True, help="For Multiple Instance Import"),
+        }
+        
+    _defaults = {
+        'name': "Quickbook",
         }
 
     def _get_nodes(self, cr, uid, ids, context=None):
@@ -738,14 +933,20 @@
             if current.vendor:
                 nodes.append('Vendor')
             if current.account:
-                nodes.extend(['Account', 'ItemSalesTax', 'PaymentMethod']) 
+                nodes.extend(['Account', 'ItemSalesTax', 'PaymentMethod','SalesTaxCode'])
             if current.item:
                 nodes.append('Item')
+            if current.customer_invoice:
+                nodes.append('Invoice')
             if current.invoice:
-                nodes.append('Invoice')
+                nodes.append('Bill')
             if current.purchase:
                 nodes.append('PurchaseOrder')
-            if current.payment:
+            if current.employee:
+                nodes.append('Employee')
+            if current.department:
+                nodes.append('JobType')
+            if current.customer_payment:
                 nodes.append('Payment')
             if current.sale_receipt:
                 nodes.append('SalesReceipt')

=== modified file 'import_quickbooks/wizard/import_data_from_quickbook.xml'
--- import_quickbooks/wizard/import_data_from_quickbook.xml	2011-08-09 12:40:43 +0000
+++ import_quickbooks/wizard/import_data_from_quickbook.xml	2011-09-05 11:22:29 +0000
@@ -14,54 +14,57 @@
                         <group colspan="2">
                             <label align="1.0" string="The Module bridges the Quickbooks on-line version and OpenERP."/>
                         </group>
-                        <separator string="" orientation="vertical" colspan="1" rowspan="15"/>
+                        <separator string="" orientation="vertical" colspan="1" rowspan="23"/>
                     </group>
                     <group colspan="6" col="2">
-
                         <group colspan="5" col="4">
-         		            <separator string="Authentication Detail" colspan="8"/>
                             <field name="login" colspan="2"/>
                             <field name="password" password="True" colspan="2"/>
                             <field name="token" colspan="2"/>
                             <field name="realm_id" colspan="2"/>
                      	</group>
-                        <group colspan="6" col="10">
+                     	<separator string=""  colspan="4"/>
+                        <group colspan="6" col="8"> 
                             <group colspan="2" col="2">
                                 <newline/>
-                                <separator string="Address Book" colspan="4"/>
                                 <field name="customer"/>
                                 <field name="vendor"/>
                             </group>
                             <group colspan="2" col="2">
-                                <separator string="Account" colspan="4"/>
                                 <field name="account" />
                             </group>
                             <group colspan="2" col="2">
-                                <separator string="Customer" colspan="4"/> 
-                                <field name="invoice"/>
-                                <field name="payment"/>
+                                <field name="customer_invoice"/>
+                                <field name="customer_payment"/>
                                 <field name="sale_receipt"/>
                             </group>
                             <group colspan="2" col="2">
-                                <separator string="Purchase" colspan="4"/>
                                 <field name="purchase" />
+                                <field name="invoice"/>
                             </group>
+                            <separator string=""  colspan="8"/>
+                            <newline/>
                             <group colspan="2" col="2">
-                                <separator string="Product" colspan="4"/>
+                                <field name="employee"/>
+                                <field name="department"/>
+                            </group>
+                            <group colspan="6" col="2">
                                 <field name="item"/>
                             </group>
                         </group>
-                        <group colspan="4" col="4">
-                            <separator string="Email Notification" colspan="4"/>
-                            <field name="email" colspan="4"/>
-        <!--                    <separator string="Multi Instance" colspan="4"/>-->
-                            <field name="name" colspan="4" invisible="True"/>
+                        <group colspan="6" col="2">
+                            <separator string="Email Notification:" colspan="4"/>
+                            <field name="email" colspan="2"/>
+                        </group>
+                        <group colspan="4" col="2" groups="base.group_no_one"> 
+                            <separator string="Multi Instance Management:" colspan="4"/>
+                            <field name="name" colspan="2"/>
                         </group>
                     </group>
-                    <separator string="" colspan="6"/>
-         	        <group colspan="6" col="4">
-                        <group colspan="2"/>
-                        <group colspan="2">
+                    <separator string="" colspan="8"/>
+         	        <group colspan="8" col="6">
+                        <group colspan="3"/>
+                        <group colspan="3">
                             <button icon="gtk-cancel" special="cancel" string="_Close"/>
                             <button icon="gtk-new" string="_Schedule" name="create_lst" type="object"/>
                             <button icon="gtk-go-forward" string="_Import" name="import_alldata" type="object"/>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to