Kuldeep Joshi(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-import_quickbooks-estimate-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-estimate-kjo/+merge/74085

Import the Estimate Data in Purchase Order (Draft State)
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-import_quickbooks-estimate-kjo/+merge/74085
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-import_quickbooks.
=== 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:52:27 +0000
@@ -28,7 +28,11 @@
     'description': """ QuickBooks Wordplace / Intuit Partner Platform / Intuit Data Services """,
     'author': 'OpenERP SA',
     'website': 'http://www.openerp.com',
+<<<<<<< TREE
     'depends': ['base','import_base','account','purchase', 'account_voucher'],
+=======
+    'depends': ['base','import_base','account','product', 'purchase'],
+>>>>>>> MERGE-SOURCE
     '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:52:27 +0000
@@ -167,8 +167,8 @@
         response = IPP._request(context, type, url, action, xml)
 
         return response
-
-class PurchaseOrderService(import_quickbooks.quickbooks.ippids.service.abstract.AbstractService):
+   
+class EstimateService(import_quickbooks.quickbooks.ippids.service.abstract.AbstractService):
 
     def list_all(self, context, realm=None):
 
@@ -178,12 +178,12 @@
             realm = context.get_realm()
 
         type = import_quickbooks.quickbooks.ippids.IPP.REQUEST_IDS
-        url = "https://services.intuit.com/sb/purchaseorder/v2/"; + str(realm)
+        url = "https://services.intuit.com/sb/estimate/v2/"; + str(realm)
         action = None
 
         xml = '''<?xml version="1.0" encoding="UTF-8"?>
-<PurchaseOrderQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://www.intuit.com/sb/cdm/v2";>
-</PurchaseOrderQuery>'''
+<EstimateQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://www.intuit.com/sb/cdm/v2";>
+</EstimateQuery>'''
 
         response = IPP._request(context, type, url, action, xml)
 

=== 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:52:27 +0000
@@ -29,8 +29,12 @@
 from import_quickbooks.quickbooks.ippids.service.services import *
 from import_base.import_framework import *
 from import_base.mapper import *
+<<<<<<< TREE
 from datetime import date
 
+=======
+from datetime import date
+>>>>>>> MERGE-SOURCE
 
 class quickbook_import(import_framework):
 
@@ -40,9 +44,13 @@
     TABLE_ACCOUNT_PAYMENT = 'PaymentMethod'
     TABLE_CUSTOMER_INVOICE = 'Invoice'
     TABLE_VENDOR = 'Vendor'
+<<<<<<< TREE
     TABLE_PURCHASE = 'PurchaseOrder'
     TABLE_CUSTOMER_PAYMENT = 'Payment'
     TABLE_SALE_RECEIPT = 'SalesReceipt'
+=======
+    TABLE_ESTIMATE = 'Estimate'
+>>>>>>> MERGE-SOURCE
     TABLE_ITEM = 'Item'
     _realm_id = False
     _ticket = False
@@ -64,7 +72,7 @@
             self.TABLE_ACCOUNT_PAYMENT: AccountService(),
             self.TABLE_CUSTOMER_INVOICE: InvoiceService(),
             self.TABLE_VENDOR: VendorService(),
-            self.TABLE_PURCHASE: PurchaseOrderService(),
+            self.TABLE_ESTIMATE: EstimateService(),
             self.TABLE_ITEM: ItemService(),
             self.TABLE_CUSTOMER_PAYMENT: PaymentService(),
             self.TABLE_SALE_RECEIPT: SalesReceiptService(),
@@ -122,7 +130,7 @@
             self.TABLE_ACCOUNT_PAYMENT: self.get_paymentTerm('PaymentMethod'),
             self.TABLE_CUSTOMER_INVOICE: self.get_values('Invoice'),
             self.TABLE_VENDOR: self.get_values('Vendor'),
-            self.TABLE_PURCHASE: self.get_values('PurchaseOrder'),
+            self.TABLE_ESTIMATE: self.get_values('Estimate'),
             self.TABLE_ITEM: self.get_values('Item'),
             self.TABLE_CUSTOMER_PAYMENT: self.get_values('Payment'),
             self.TABLE_SALE_RECEIPT: self.get_values('SalesReceipt'),
@@ -137,7 +145,11 @@
             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(),
+<<<<<<< TREE
             self.TABLE_PURCHASE: self.get_purchase_order_mapping(),
+=======
+            self.TABLE_ESTIMATE: self.get_estimate_mapping(),
+>>>>>>> MERGE-SOURCE
             self.TABLE_ITEM: self.get_item_mapping(),
             self.TABLE_CUSTOMER_PAYMENT: self.get_customer_payment_mapping(),
             self.TABLE_SALE_RECEIPT: self.get_sales_receipt_mapping(),
@@ -318,9 +330,14 @@
         'Non-Posting': 'other',
         'Long Term Liability': 'liquidity',
         'Other Current Asset': 'other',
-        'Cost of Goods Sold': 'other',
-        'Other Asset': 'other',
-        'Cost of Goods Sold': 'other',
+<<<<<<< TREE
+        'Cost of Goods Sold': 'other',
+        'Other Asset': 'other',
+        'Cost of Goods Sold': 'other',
+=======
+        'Cost of Goods Sold': 'other',
+        'Other Asset': 'other',
+>>>>>>> MERGE-SOURCE
         'Other Current Liability': 'liquidity',
         'Bank': 'liquidity',
         'Other Expense': 'other',
@@ -396,6 +413,7 @@
                     }
                 }
 
+<<<<<<< TREE
     
     #Account Payment Line had paymnet_id required so using reverse import (line to payment)
     def get_account_payment(self,val):
@@ -404,6 +422,14 @@
         name =  val.get('Name') +  val.get('Id')
         return self.import_object(field, data, 'account.payment.term', self.TABLE_ACCOUNT_PAYMENT, name)
     
+=======
+    def get_account_payment(self,val):
+        field = ['id', 'name']
+        data = [val.get('Id'), val.get('Name')]
+        name =  val.get('Name') +  val.get('Id')
+        return self.import_object(field, data, 'account.payment.term', self.TABLE_ACCOUNT_PAYMENT, name)
+    
+>>>>>>> MERGE-SOURCE
     def get_account_payment_term_mapping(self):
         return {
             'model': 'account.payment.term.line',
@@ -461,6 +487,7 @@
             journal_id = self.import_object(fields, data, 'account.journal', 'account_journal', name)
         return journal_id
 
+<<<<<<< TREE
     def get_account_id(self, val, field1, field2):
         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
@@ -495,6 +522,37 @@
         return val
 
     def get_customer_invoice_mapping(self):
+=======
+    def get_account_id(self, val, field1, field2):
+        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):
+        if vals.get('Line'):
+            account_id = self.get_account_id(vals, 'ARAccountName', 'ARAccountId')
+            return self.get_line(vals, account_id)
+        return False
+
+    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_tax_line(self, val):
+        account_id = self.get_account_id(val, 'ARAccountName', 'ARAccountId')
+        field = ['name', 'account_id/id', 'amount']
+        data = [self.get_value(val, 'Header', 'TaxName'), account_id, self.get_value(val, 'Header', 'TaxAmt')]
+        return self.import_object(field, data, 'account.invoice.tax', 'account_invoice_tax', val.get('Id'))
+    
+    def get_account_move(self, val):
+        journal_id = self.get_journal_id(val, 'Sales Journal', 'SAJ', 'sale')
+        period_id = self.mapped_id_if_exist('account.period', [('date_stop', '>', date.today())] , 'account_period', 'id')
+        field = ['name', 'ref', 'period_id/id', 'journal_id/id',  'date']
+        data =[val.get('Id'), val.get('Id'), period_id, journal_id, date.today()]
+        return self.import_object(field, data, 'account.move', 'account_move', val.get('Id'))
+    
+
+    def get_customer_invoice_mapping(self):
+>>>>>>> MERGE-SOURCE
         return {
             'model': 'account.invoice',
             'dependencies': [self.TABLE_ITEM, self.TABLE_CUSTOMER],
@@ -509,9 +567,15 @@
                     'date_due': call(self.get_fieldvalue, value('Header'), 'DueDate'),
                     'comment': call(self.get_fieldvalue, value('Header'), 'Msg'),
                     'invoice_line/id': self.get_invoice_line,
+<<<<<<< TREE
                     'payment_term/id': self.get_payment_term,
                     'tax_line/id': self.get_tax_line,
                     'type': const('out_invoice'),
+=======
+                    'payment_term/id': self.get_payment_term,
+                    'tax_line/id': self.get_tax_line,
+                    'type': const('out_invoice'),   
+>>>>>>> MERGE-SOURCE
                     }
                 }
 
@@ -588,6 +652,7 @@
                     }
                 }
 
+<<<<<<< TREE
     def get_currency(self, val, field1, field2):
         currency_id = self.mapped_id_if_exist('res.currency', [('name', '=', field1)], 'res_currency', field2)
         return currency_id
@@ -701,8 +766,72 @@
                     'amount': call(self.get_value, 'Header', 'TotalAmt'),
                     'currency_id/id': call(self.get_currency, 'EUR', 'EUR'),
                     }
+=======
+    def get_currency(self, val, field1, field2):
+        currency_id = self.mapped_id_if_exist('res.currency', [('name', '=', field1)], 'res_currency', field2)
+        return currency_id
+
+    def get_pricelist(self, val):
+        pricelist_id = self.mapped_id_if_exist('product.pricelist', [('name', '=', 'QB Purchase Pricelist')], 'product_pricelist', 'id')
+        if not pricelist_id:
+            field = ['name', 'type', 'active', 'currency_id/id']
+            data = ['QB Purchase Pricelist', 'purchase', '1', self.get_currency(val, 'EUR', 'EUR')]
+            name = 'id'
+            pricelist_id = self.import_object(field, data, 'product.pricelist', 'product_pricelist', name)
+        return pricelist_id
+
+    def get_location(self, val):
+        # Need To Check in QuickBook for Destination Location
+        location_id = self.mapped_id_if_exist('stock.location', [('name', '=', 'Stock')], 'stock_location', 'STOCK')
+        return location_id
+
+    def set_purchase_order(self, val):
+        partner_id = self.get_partner_id(val, 'CustomerName', 'CustomerId')
+        partner_address_id = self.get_partner_address_id(val, 'CustomerId')
+        pricelist_id = self.get_pricelist(val)
+        date = self.get_value(val, 'Header', 'TxnDate')
+        due_date = self.get_value(val, 'Header', 'TxnDate')
+        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')
+        self.import_object(field, dic, 'purchase.order', self.TABLE_ESTIMATE, name, False)
+        return val
+
+    def get_purchase_order_line(self, vals):
+        val = self.set_purchase_order(vals)
+        line_ids = []
+        purchase_id = self.mapped_id_if_exist('purchase.order', [('invoice_method', '=', 'manual')], self.TABLE_ESTIMATE, vals.get('Id'))
+        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'))
+        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])
+                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', 'taxes_id/id']
+                data = [val.get('Desc', 'test')[0], val.get('Qty','0')[0], val.get('UnitPrice','0')[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_estimate_mapping(self):
+        return {
+                'model': 'purchase.order',
+                'dependencies': [self.TABLE_ITEM, self.TABLE_CUSTOMER],
+                'map': {
+                        'notes': call(self.get_fieldvalue, value('Header'), 'TotalAmt'),
+                        'order_line/id': self.get_purchase_order_line,
+                        'state': const('draft'),
+                       }
+>>>>>>> MERGE-SOURCE
                 }
-
+<<<<<<< TREE
+
+=======
+        
+
+>>>>>>> MERGE-SOURCE
 class import_quickbooks(osv.osv_memory):
 
     _name = 'import.quickbooks'
@@ -716,11 +845,17 @@
         '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),
+<<<<<<< TREE
         '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"),
+=======
+        'account': fields.boolean('Accounts', help="Import Accounts."),
+        'invoice': fields.boolean('Customer Invoices', help="Import Customer Invoices."),
+        'purchase': fields.boolean('Purchase Orders', help="Import Purchase Orders"),
+>>>>>>> MERGE-SOURCE
 #        'employee': fields.boolean('Employees', help="Not implement yet.",readonly=True),
         'email': fields.char('Notify end of import to', size=64, help="Email address of the user to be notified when the import is complete."),
 
@@ -738,17 +873,25 @@
             if current.vendor:
                 nodes.append('Vendor')
             if current.account:
+<<<<<<< TREE
                 nodes.extend(['Account', 'ItemSalesTax', 'PaymentMethod']) 
+=======
+                nodes.extend(['ItemSalesTax', 'Account', 'PaymentMethod'])
+>>>>>>> MERGE-SOURCE
             if current.item:
                 nodes.append('Item')
             if current.invoice:
                 nodes.append('Invoice')
             if current.purchase:
+<<<<<<< TREE
                 nodes.append('PurchaseOrder')
             if current.payment:
                 nodes.append('Payment')
             if current.sale_receipt:
                 nodes.append('SalesReceipt')
+=======
+                nodes.append('Estimate')
+>>>>>>> MERGE-SOURCE
         return nodes
 
     def import_alldata(self, cr, uid, ids, context=None):

_______________________________________________
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