Пример #1
0
 def create(self, vals):
     # if context is None:
     # context = {}
     if self._context.has_key('prestashop'):
         if vals.has_key('name'):
             vals['name'] = _unescape(vals['name'])
         if vals.has_key('street'):
             vals['street'] = _unescape(vals['street'])
         if vals.has_key('street2'):
             vals['street2'] = _unescape(vals['street2'])
         if vals.has_key('city'):
             vals['city'] = _unescape(vals['city'])
         partner_id = super(ResPartner, self).create(vals)
         if partner_id:
             self.env['prestashop.customer'].create({
                 'customer_name':
                 partner_id.id,
                 'erp_customer_id':
                 partner_id.id,
                 'presta_customer_id':
                 self._context.get('customer_id'),
                 'presta_address_id':
                 self._context.get('address_id')
             })
         return partner_id
     return super(ResPartner, self).create(vals)
Пример #2
0
 def create(self, vals):
     if self._context.has_key('prestashop'):
         if vals.has_key('name'):
             vals['name'] = _unescape(vals['name'])
         if vals.has_key('description'):
             vals['description'] = _unescape(vals['description'])
         if vals.has_key('description_sale'):
             vals['description_sale'] = _unescape(vals['description_sale'])
     template_id = super(ProductTemplate, self).create(vals)
     return template_id
Пример #3
0
 def write(self, vals):
     map_obj = self.env['prestashop.product.template']
     if self._context.has_key('prestashop'):
         if vals.has_key('name'):
             vals['name'] = _unescape(vals['name'])
         if vals.has_key('description'):
             vals['description'] = _unescape(vals['description'])
         if vals.has_key('description_sale'):
             vals['description_sale'] = _unescape(vals['description_sale'])
     return super(ProductTemplate, self).write(vals)
	def create(self, cr, uid, vals, context=None):
		if context is None:
			context = {}
		if context.has_key('prestashop'):
			if vals.has_key('name'):
				vals['name'] = _unescape(vals['name'])
			if vals.has_key('street'):
				vals['street'] = _unescape(vals['street'])
			if vals.has_key('street2'):
				vals['street2'] = _unescape(vals['street2'])
			if vals.has_key('city'):
				vals['city'] = _unescape(vals['city'])
		return super(res_partner, self).create(cr, uid, vals, context=context)
	def write(self,cr,uid,ids,vals,context=None):
		if context is None:
			context = {}
		map_obj = self.pool.get('prestashop.product')
		if not context.has_key('prestashop'):
			if ids:
				if type(ids) == list:
					erp_id=ids[0]
				else:
					erp_id=ids
				map_ids = map_obj.search(cr, uid, [('erp_product_id', '=',erp_id)])
				if map_ids:
					map_obj.write(cr, uid, map_ids[0], {'need_sync':'yes'})
		elif context.has_key('prestashop_variant'):
			if type(ids) == list:
				erp_id=ids[0]
			else:
				erp_id=ids
			template_obj = self.pool.get('product.product').browse(cr,uid,erp_id).product_tmpl_id
			# template_obj = self.pool.get('product.template').browse(cr,uid,'product_tmpl_id')
			vals['name'] = template_obj.name
			vals['description'] = template_obj.description
			vals['description_sale'] = template_obj.description_sale
			vals['type'] = template_obj.type
			vals['categ_id'] = template_obj.categ_id.id
			vals['uom_id'] = template_obj.uom_id.id
			vals['uom_po_id'] = template_obj.uom_po_id.id
			vals['default_code'] = _unescape(vals['default_code'])
			if vals.has_key('ps_attributes'):
				vals['attribute_value_ids']=self.check_for_new_attrs(cr,uid,template_obj.id,vals['ps_attributes'])
		return super(product_product,self).write(cr,uid,ids,vals,context=context)
Пример #6
0
 def write(self, vals):
     # if context is None:
     # context = {}
     if self._context.has_key('prestashop'):
         if vals.has_key('name'):
             vals['name'] = _unescape(vals['name'])
     return super(ProductAttribute, self).write(vals)
	def write(self,cr,uid,ids,vals,context=None):
		if context is None:
			context = {}						
		if context.has_key('prestashop'):
			if vals.has_key('name'):
				vals['name'] = _unescape(vals['name'])
		return super(product_attribute,self).write(cr,uid,ids,vals,context=context)
	def create(self, cr, uid, vals, context=None):
		if context is None:
			context = {}
		if context.has_key('prestashop'):
			if vals.has_key('name'):
				vals['name'] = _unescape(vals['name'])
		return super(product_category, self).create(cr, uid, vals, context=context)
Пример #9
0
 def create(self, vals):
     # if context is None:
     # context = {}
     if self._context.has_key('prestashop'):
         if vals.has_key('name'):
             vals['name'] = _unescape(vals['name'])
     return super(ProductCategory, self).create(vals)
	def create(self, cr, uid, vals, context=None):
		if context is None:
			context = {}
		if context.has_key('prestashop_variant'):
			template_obj = self.pool.get('product.template').browse(cr,uid,vals['product_tmpl_id'])
			vals['name'] = template_obj.name
			vals['description'] = template_obj.description
			vals['description_sale'] = template_obj.description_sale
			vals['type'] = template_obj.type
			vals['categ_id'] = template_obj.categ_id.id
			vals['uom_id'] = template_obj.uom_id.id
			vals['uom_po_id'] = template_obj.uom_po_id.id
			vals['default_code'] = _unescape(vals['default_code'])
			if vals.has_key('ps_attributes'):
				vals['attribute_value_ids']=self.check_for_new_attrs(cr,uid,template_obj.id,vals['ps_attributes'])
		erp_id =  super(product_product, self).create(cr, uid, vals, context=context)
		if context.has_key('prestashop_variant'):
			prestashop_product = self.pool.get('prestashop.product')
			exists = prestashop_product.search(cr,uid,[('erp_template_id','=',vals['product_tmpl_id']),('presta_product_attr_id','=',0)])
			if exists:
				pp_map = prestashop_product.browse(cr,uid,exists[0])
				if pp_map.product_name:
					self.write(cr,uid,pp_map.product_name.id,{'active':False})
				prestashop_product.unlink(cr,uid,exists)
			prestashop_product.create(cr,uid,{'product_name':erp_id,'erp_template_id':template_obj.id,'presta_product_id':context['presta_id'],'erp_product_id':erp_id,'presta_product_attr_id':context['presta_attr_id']})
		return erp_id
	def write(self, cr, uid, ids, vals, context=None):
		if context is None:
			context = {}
		if context.has_key('prestashop'):
			vals['name'] = _unescape(vals['name'])
			vals['partner_id'] = uid
			vals['product_id'] = self.pool.get('force.done')._get_virtual_product_id(cr,uid,{'name':'Shipping'})
		return super(delivery_carrier, self).write(cr, uid, ids, vals, context=context)	
	def create(self, cr, uid, vals, context=None):
		if context is None:
			context = {}
		if context.has_key('prestashop'):
			vals['name'] = _unescape(vals['name'])
			vals['partner_id'] = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
			vals['product_id'] = self.pool.get('force.done')._get_virtual_product_id(cr,uid,{'name':'Shipping'})
		return super(delivery_carrier, self).create(cr, uid, vals, context=context)	
Пример #13
0
 def create(self, vals):
     if self._context.has_key('prestashop'):
         vals['name'] = _unescape(vals['name'])
         temp = self.env['res.users'].browse(self._uid)
         vals['partner_id'] = temp.company_id
         vals['product_type'] = 'service'
         vals['taxes_id'] = False
         vals['supplier_taxes_id'] = False
     return super(DeliveryCarrier, self).create(vals)
Пример #14
0
    def write(self, vals):
        # if context is None:
        # context = {}
        map_obj = self.env['prestashop.customer']
        if self._context.has_key('prestashop'):
            if vals.has_key('name'):
                vals['name'] = _unescape(vals['name'])
            if vals.has_key('street'):
                vals['street'] = _unescape(vals['street'])
            if vals.has_key('street2'):
                vals['street2'] = _unescape(vals['street2'])
            if vals.has_key('city'):
                vals['city'] = _unescape(vals['city'])
        if not self._context.has_key('prestashop'):
            record = self.env['prestashop.customer'].search([
                ('erp_customer_id', '=', self.id)
            ])
            record.write({'need_sync': 'yes'})

        return super(ResPartner, self).write(vals)
	def write(self,cr,uid,ids,vals,context=None):
		if context is None:
			context = {}
		map_obj = self.pool.get('prestashop.product.template')
		if context.has_key('prestashop'):
			if vals.has_key('name'):
				vals['name'] = _unescape(vals['name'])
			if vals.has_key('description'):
				vals['description'] = _unescape(vals['description'])
			if vals.has_key('description_sale'):
				vals['description_sale'] = _unescape(vals['description_sale'])
		# else:
		# 	if ids:
		# 		if type(ids) == list:
		# 			erp_id=ids[0]
		# 		else:
		# 			erp_id=ids
		# 		map_ids = map_obj.search(cr, uid, [('erp_template_id', '=',erp_id)])
		# 		if map_ids:
		# 			map_obj.write(cr, uid, map_ids[0], {'need_sync':'yes'})
		return super(product_template,self).write(cr,uid,ids,vals,context=context)
	def export_all_customers(self,cr,uid,cus_data,add_data,presta_user,context=None):
		if context is None:
			context = {}
		cus={}
		add={}
		cus_merge=[]
		add_merge=[]
		cus_synch_merge=[]
		add_synch_merge=[]
	
		for i in range(len(cus_data)):
			cus['name']=_unescape(cus_data[i]['firstname']+' '+cus_data[i]['lastname'])
			cus['email']=cus_data[i]['email']
			cus['is_company']=True
			if int(cus_data[i]['is_synch']):
				if self.pool.get('res.partner').exists(cr,uid,int(cus_data[i]['erp_customer_id'])):
					self.pool.get('res.partner').write(cr,uid,int(cus_data[i]['erp_customer_id']),cus)
					cus_synch_merge.append(cus_data[i]['id_customer'])
					erp_customer_id=cus_data[i]['erp_customer_id']
			else:
				erp_customer_id=self.pool.get('res.partner').create(cr,uid,cus)
				cus_merge.append({'erp_customer_id':erp_customer_id,'prestashop_customer_id':cus_data[i]['id_customer'],'created_by':presta_user})
				self.pool.get('prestashop.customer').create(cr,uid,{'customer_name':erp_customer_id,'erp_customer_id':erp_customer_id,'presta_customer_id':cus_data[i]['id_customer'],'presta_address_id':'-'})
			for data in filter(lambda x: x['id_customer']==cus_data[i]['id_customer'], add_data):
				if data['country'] and data['country_iso']:
					erp_country_id=self._get_country_id(cr,uid,{'name':_unescape(data['country']),'iso':data['country_iso']})
					if data['state'] and data['state_iso']:
						erp_state_id=self._get_state_id(cr,uid,{'name':_unescape(data['state']),'iso':data['state_iso'],'country_id':erp_country_id})
					else:
						erp_state_id=False
				else:
					erp_country_id=False
				add.update({'parent_id':erp_customer_id,
							'name':_unescape(data['firstname']+' '+data['lastname']),
							'email':cus['email'],
							'street':_unescape(data['address1']),
							'street2':_unescape(data['address2']),
							'phone':data['phone'],
							'mobile':data['phone_mobile'],
							'zip':data['postcode'],
							'city':_unescape(data['city']),
							'country_id':erp_country_id,
							'state_id':erp_state_id,
							'customer':False,
							'use_parent_address':False,
							})
				if int(data['is_synch']):
					if self.pool.get('res.partner').exists(cr,uid,int(data['erp_address_id'])):
						self.pool.get('res.partner').write(cr,uid,int(data['erp_address_id']),add)
						add_synch_merge.append(data['id_address'])
				else:
					erp_address_id=self.pool.get('res.partner').create(cr,uid,add)
					add_merge.append({'erp_address_id':erp_address_id,'prestashop_address_id':data['id_address'],'id_customer':cus_data[i]['id_customer'],'created_by':presta_user})
					self.pool.get('prestashop.customer').create(cr,uid,{'customer_name':erp_address_id,'erp_customer_id':erp_address_id,'presta_customer_id':cus_data[i]['id_customer'],'presta_address_id':data['id_address']})
		return [cus_merge,add_merge,cus_synch_merge,add_synch_merge]
	def create(self, cr, uid, vals, context=None):
		if context is None:
			context = {}
		if context.has_key('prestashop'):
			if vals.has_key('name'):
				vals['name'] = _unescape(vals['name'])
			if vals.has_key('description'):
				vals['description'] = _unescape(vals['description'])
			if vals.has_key('description_sale'):
				vals['description_sale'] = _unescape(vals['description_sale'])
		template_id = super(product_template, self).create(cr, uid, vals, context=context)
		if context.has_key('prestashop'):
			variant_ids_ids = self.browse(cr,uid,template_id).product_variant_ids
			temp = {'template_id':template_id}
			if len(variant_ids_ids)==1:
				temp['product_id'] = variant_ids_ids[0].id
			else:
				temp['product_id'] = -1
			self.pool.get('prestashop.product.template').create(cr,uid,{'template_name':template_id,'erp_template_id':template_id,'presta_product_id':context['presta_id']})
			self.pool.get('prestashop.product').create(cr,uid,{'product_name':temp['product_id'],'erp_template_id':template_id,'presta_product_id':context['presta_id'],'erp_product_id':temp['product_id']})
			return temp
		return template_id
	def create_attribute_value(self,cr,uid,data,context=None):
		if context is None:
			context = {}
		check = self.pool.get('product.attribute.value').search(cr,uid,[('attribute_id','=',data['erp_attribute_id']),('name','=',data['name'])])
		if check:
			erp_id = check[0]
		else:
			temp={}
			temp['name']=_unescape(data['name'])
			temp['attribute_id']=data['erp_attribute_id']
			temp['sequence']=data['sequence']
			erp_id = self.pool.get('product.attribute.value').create(cr,uid,temp)
		self.pool.get('prestashop.product.attribute.value').create(cr,uid,{'name':erp_id,'erp_id':erp_id,'presta_id':data['presta_attribute_value_id'],'erp_attr_id':data['erp_attribute_id'],'presta_attr_id':data['presta_attribute_id']})
		return erp_id
	def write(self,cr,uid,ids,vals,context=None):
		if context is None:
			context = {}
		map_obj = self.pool.get('prestashop.customer')
		if not context.has_key('prestashop'):
			if ids:
				if type(ids) == list :
					if ids:
						erp_id=ids[0]
				else:
					erp_id=ids
				map_ids = map_obj.search(cr, uid, [('erp_customer_id', '=',erp_id)])
				if map_ids:
					map_obj.write(cr, uid, map_ids[0], {'need_sync':'yes'})
		else:
			if vals.has_key('name'):
				vals['name'] = _unescape(vals['name'])
			if vals.has_key('street'):
				vals['street'] = _unescape(vals['street'])
			if vals.has_key('street2'):
				vals['street2'] = _unescape(vals['street2'])
			if vals.has_key('city'):
				vals['city'] = _unescape(vals['city'])
		return super(res_partner,self).write(cr,uid,ids,vals,context=context)
Пример #20
0
 def write(self, vals):
     # if context is None:
     # context = {}
     map_obj = self.env['prestashop.category']
     if not self._context.has_key('prestashop'):
         if self._ids:
             if type(self._ids) == list:
                 erp_id = self._ids[0]
             else:
                 erp_id = self._ids
             map_ids = map_obj.search([('erp_category_id', '=', erp_id)])
             if map_ids:
                 map_ids[0].write({'need_sync': 'yes'})
     else:
         if vals.has_key('name'):
             vals['name'] = _unescape(vals['name'])
     return super(ProductCategory, self).write(vals)
	def write(self,cr,uid,ids,vals,context=None):
		if context is None:
			context = {}
		map_obj = self.pool.get('prestashop.category')
		# raise osv.except_osv(_('Error!'),_('context=%s')%(context))		
		if not context.has_key('prestashop'):
			if ids:
				if type(ids) == list:
					erp_id=ids[0]
				else:
					erp_id=ids
				map_ids = map_obj.search(cr, uid, [('erp_category_id', '=',erp_id)])
				if map_ids:
					map_obj.write(cr, uid, map_ids[0], {'need_sync':'yes'})
		else:
			if vals.has_key('name'):
				vals['name'] = _unescape(vals['name'])
		return super(product_category,self).write(cr,uid,ids,vals,context=context)
Пример #22
0
 def create(self, vals):
     if self._context.has_key('prestashop_variant'):
         template_obj = self.env['product.template'].sudo().browse(
             vals['product_tmpl_id'])
         vals['name'] = template_obj.name
         vals['description'] = template_obj.description
         vals['description_sale'] = template_obj.description_sale
         vals['type'] = template_obj.type
         vals['categ_id'] = template_obj.categ_id.id
         vals['uom_id'] = template_obj.uom_id.id
         vals['uom_po_id'] = template_obj.uom_po_id.id
         vals['default_code'] = _unescape(vals['default_code'])
         if vals.has_key('ps_attributes'):
             vals['attribute_value_ids'] = self.sudo().check_for_new_attrs(
                 template_obj.id, vals['ps_attributes'])
     erp_id = super(ProductProduct, self).create(vals)
     if self._context.has_key('prestashop_variant'):
         prestashop_product = self.env['prestashop.product']
         exists = prestashop_product.search([
             ('erp_template_id', '=', vals['product_tmpl_id']),
             ('presta_product_attr_id', '=', 0)
         ])
         if exists:
             pp_map = prestashop_product.browse(exists[0].id)
             if pp_map.product_name:
                 pp_map.product_name.write({'active': False})
             exists.unlink()
         prestashop_product.sudo().create({
             'product_name':
             erp_id.id,
             'erp_template_id':
             template_obj.id,
             'presta_product_id':
             self._context['presta_id'],
             'erp_product_id':
             erp_id.id,
             'presta_product_attr_id':
             self._context['presta_attr_id']
         })
     return erp_id
Пример #23
0
 def create_attribute_value(self, cr, uid, data, context=None):
     if context is None:
         context = {}
     check = self.pool.get('product.attribute.value').search(
         cr, uid, [('attribute_id', '=', data['erp_attribute_id']),
                   ('name', '=', data['name'])])
     if check:
         erp_id = check[0]
     else:
         temp = {}
         temp['name'] = _unescape(data['name'])
         temp['attribute_id'] = data['erp_attribute_id']
         temp['sequence'] = data['sequence']
         erp_id = self.pool.get('product.attribute.value').create(
             cr, uid, temp)
     self.pool.get('prestashop.product.attribute.value').create(
         cr, uid, {
             'name': erp_id,
             'erp_id': erp_id,
             'presta_id': data['presta_attribute_value_id'],
             'erp_attr_id': data['erp_attribute_id'],
             'presta_attr_id': data['presta_attribute_id']
         })
     return erp_id
Пример #24
0
 def write(self, vals):
     if self._context.has_key('prestashop'):
         vals['name'] = _unescape(vals['name'])
     return super(DeliveryCarrier, self).write(vals)
Пример #25
0
    def export_all_customers(self,
                             cr,
                             uid,
                             cus_data,
                             add_data,
                             presta_user,
                             context=None):
        if context is None:
            context = {}
        cus = {}
        add = {}
        cus_merge = []
        add_merge = []
        cus_synch_merge = []
        add_synch_merge = []

        for i in range(len(cus_data)):
            cus['name'] = _unescape(cus_data[i]['firstname'] + ' ' +
                                    cus_data[i]['lastname'])
            cus['email'] = cus_data[i]['email']
            cus['is_company'] = True
            if int(cus_data[i]['is_synch']):
                if self.pool.get('res.partner').exists(
                        cr, uid, int(cus_data[i]['erp_customer_id'])):
                    self.pool.get('res.partner').write(
                        cr, uid, int(cus_data[i]['erp_customer_id']), cus)
                    cus_synch_merge.append(cus_data[i]['id_customer'])
                    erp_customer_id = cus_data[i]['erp_customer_id']
            else:
                erp_customer_id = self.pool.get('res.partner').create(
                    cr, uid, cus)
                cus_merge.append({
                    'erp_customer_id':
                    erp_customer_id,
                    'prestashop_customer_id':
                    cus_data[i]['id_customer'],
                    'created_by':
                    presta_user
                })
                self.pool.get('prestashop.customer').create(
                    cr, uid, {
                        'customer_name': erp_customer_id,
                        'erp_customer_id': erp_customer_id,
                        'presta_customer_id': cus_data[i]['id_customer'],
                        'presta_address_id': '-'
                    })
            for data in filter(
                    lambda x: x['id_customer'] == cus_data[i]['id_customer'],
                    add_data):
                if data['country'] and data['country_iso']:
                    erp_country_id = self._get_country_id(
                        cr, uid, {
                            'name': _unescape(data['country']),
                            'iso': data['country_iso']
                        })
                    if data['state'] and data['state_iso']:
                        erp_state_id = self._get_state_id(
                            cr, uid, {
                                'name': _unescape(data['state']),
                                'iso': data['state_iso'],
                                'country_id': erp_country_id
                            })
                    else:
                        erp_state_id = False
                else:
                    erp_country_id = False
                add.update({
                    'parent_id':
                    erp_customer_id,
                    'name':
                    _unescape(data['firstname'] + ' ' + data['lastname']),
                    'email':
                    cus['email'],
                    'street':
                    _unescape(data['address1']),
                    'street2':
                    _unescape(data['address2']),
                    'phone':
                    data['phone'],
                    'mobile':
                    data['phone_mobile'],
                    'zip':
                    data['postcode'],
                    'city':
                    _unescape(data['city']),
                    'country_id':
                    erp_country_id,
                    'state_id':
                    erp_state_id,
                    'customer':
                    False,
                    'use_parent_address':
                    False,
                })
                if int(data['is_synch']):
                    if self.pool.get('res.partner').exists(
                            cr, uid, int(data['erp_address_id'])):
                        self.pool.get('res.partner').write(
                            cr, uid, int(data['erp_address_id']), add)
                        add_synch_merge.append(data['id_address'])
                else:
                    erp_address_id = self.pool.get('res.partner').create(
                        cr, uid, add)
                    add_merge.append({
                        'erp_address_id':
                        erp_address_id,
                        'prestashop_address_id':
                        data['id_address'],
                        'id_customer':
                        cus_data[i]['id_customer'],
                        'created_by':
                        presta_user
                    })
                    self.pool.get('prestashop.customer').create(
                        cr, uid, {
                            'customer_name': erp_address_id,
                            'erp_customer_id': erp_address_id,
                            'presta_customer_id': cus_data[i]['id_customer'],
                            'presta_address_id': data['id_address']
                        })
        return [cus_merge, add_merge, cus_synch_merge, add_synch_merge]
Пример #26
0
    def create_n_confirm_order(self,
                               cr,
                               uid,
                               order_data,
                               line_data,
                               context=None):
        if context is None:
            context = {}
        return_array = {}
        if order_data and line_data:
            order_dic = {
                'partner_id':
                order_data['partner_id'],
                'partner_invoice_id':
                order_data['partner_invoice_id'],
                'partner_shipping_id':
                order_data['partner_shipping_id'],
                'pricelist_id':
                order_data['pricelist_id'],
                'carrier_id':
                order_data['carrier_id'],
                'order_policy':
                'manual',
                'origin':
                'PrestaShop' + '(' + order_data['presta_order_reference'] +
                ')',
                'channel':
                'prestashop',
            }
            # if order_data.has_key('invoice_date'):

            # context['invoice_date']=order_data.get('invoice_date',False)
            if order_data.has_key('date_add'):
                order_dic['date_order'] = order_data.get('date_add', False)
                # order_dic['date_confirm']=order_data.get('date_upd',False)
                order_dic['date_confirm'] = order_data.get('date_add', False)
                context['invoice_date'] = order_data.get('date_add', False)
            if order_data.get('shop_id'):
                order_dic.update({'shop_id': order_data['shop_id']})
            order_id = self.pool.get('sale.order').create(cr, uid, order_dic)
            if order_id:
                for line in line_data:
                    if line.get('type').startswith('S'):
                        erp_product_id = self._get_virtual_product_id(
                            cr, uid, {'name': 'Shipping'})
                    if line.get('type').startswith('V'):
                        erp_product_id = self._get_virtual_product_id(
                            cr, uid, {'name': 'Discount'})
                    if line.get('type').startswith('P'):
                        erp_product_id = line['product_id']
                    line_dic = {
                        'order_id': order_id,
                        'product_id': erp_product_id,
                        'price_unit': line['price_unit'],
                        'product_uom_qty': line['product_uom_qty'],
                        'name': _unescape(line['name']),
                        'discount': line.get('discount', False),
                    }
                    if line.get('tax_id') and int(line.get('tax_id')) != -1:
                        line_dic['tax_id'] = [(6, 0, [line.get('tax_id')])]
                    else:
                        line_dic['tax_id'] = False
                    line_id = self.pool.get('sale.order.line').create(
                        cr, uid, line_dic)
                    erp_product_id = False

                order_erp = self.pool.get('sale.order').read(
                    cr, uid, order_id, ['name', 'amount_total'])
                order_name = order_erp['name']
                erp_total = order_erp['amount_total']
                cr.execute(
                    "INSERT INTO prestashop_order (erp_id, presta_id, object_name,name) VALUES (%s, %s, %s, %s)",
                    (order_id, order_data['presta_order_id'], 'order',
                     order_name + '(' + order_data['presta_order_reference'] +
                     ')'))
                cr.commit()
                # invoice_id='0'
                # if int(round(float(erp_total)))==int(round(float(order_data['ps_total']))):
                # workflow.trg_validate(uid, 'sale.order',order_id, 'order_confirm', cr)
                # invoice_id=self.create_order_invoice(cr,uid,order_id,context)
            return [{
                'erp_order_id': order_id,
                'prst_order_id': order_data['presta_order_id'],
                'erp_order_name': order_name,
                'erp_total': erp_total,
                'ps_total': order_data['ps_total']
            }]
	def create_n_confirm_order(self,cr,uid,order_data,line_data,context=None):
		if context is None:
			context = {}
		return_array={}
		if order_data and line_data:
			order_dic={
				'partner_id'			:order_data['partner_id'],
				'partner_invoice_id'	:order_data['partner_invoice_id'],
				'partner_shipping_id'	:order_data['partner_shipping_id'],
				'pricelist_id'			:order_data['pricelist_id'],
				'carrier_id'			:order_data['carrier_id'],
                'order_policy'          :'manual',     
				'origin'				:'PrestaShop'+'('+order_data['presta_order_reference']+')',
				'channel'				:'prestashop',
				'module'				:order_data['ps_module'],
				'grupo_defecto'			:order_data['grupo_defecto'],
				}
			# if order_data.has_key('invoice_date'):

				# context['invoice_date']=order_data.get('invoice_date',False)
			if order_data.has_key('date_add'):	
				order_dic['date_order']=order_data.get('date_add',False)
				# order_dic['date_confirm']=order_data.get('date_upd',False)
				order_dic['date_confirm']=order_data.get('date_add',False)
				context['invoice_date']=order_data.get('date_add',False)
			if order_data.get('shop_id'):
				order_dic.update({'shop_id':order_data['shop_id']})
			order_id=self.pool.get('sale.order').create(cr,uid,order_dic)
			if order_id:
				for line in line_data:
					if line.get('type').startswith('F'):
						erp_product_id=self._get_virtual_product_id(cr,uid,{'name':'Fee'})
					if line.get('type').startswith('S'):
						erp_product_id=self._get_virtual_product_id(cr,uid,{'name':'Shipping'})
					if line.get('type').startswith('V'):
						erp_product_id=self._get_virtual_product_id(cr,uid,{'name':'Discount'})
					if line.get('type').startswith('P'):
						erp_product_id=line['product_id']
					line_dic={
					'order_id'				:order_id,
					'product_id'			:erp_product_id,
					'price_unit'			:line['price_unit'],
					'product_uom_qty'		:line['product_uom_qty'],
					'name'					:_unescape(line['name']),
					'discount'				:line.get('discount',False),
					}
					if line.get('tax_id') and int(line.get('tax_id'))!=-1:
						line_dic['tax_id']=[(6,0,[line.get('tax_id')])]
					else:
						line_dic['tax_id'] = False
					line_id=self.pool.get('sale.order.line').create(cr,uid,line_dic)
					erp_product_id=False
				
				order_erp=self.pool.get('sale.order').read(cr,uid,order_id,['name','amount_total'])
				order_name=order_erp['name']
				erp_total=order_erp['amount_total']
				cr.execute("INSERT INTO prestashop_order (erp_id, presta_id, object_name,name) VALUES (%s, %s, %s, %s)", (order_id, order_data['presta_order_id'], 'order',order_name+'('+order_data['presta_order_reference']+')'))
				cr.commit()
				# invoice_id='0'
				# if int(round(float(erp_total)))==int(round(float(order_data['ps_total']))):
					# workflow.trg_validate(uid, 'sale.order',order_id, 'order_confirm', cr)
					# invoice_id=self.create_order_invoice(cr,uid,order_id,context)
			return [{'erp_order_id':order_id,'prst_order_id':order_data['presta_order_id'],'erp_order_name':order_name,'erp_total':erp_total,'ps_total':order_data['ps_total']}]