예제 #1
0
	def action_update_products(self):
		product_pool = self.env['product.template']

		res = get_bookeo_vals('settings/products')
		for curr in res:
			product_objs = product_pool.sudo().search([('bookeo_code', '=', curr['productId'])])

			if not product_objs.exists():
				create_vals = {

					'bookeo_code': curr['productId'],
					'name': curr['name'],
					'default_code': curr['productCode'],

				}
				new_product = product_pool.sudo().create(create_vals)

				attr_age = self.env.ref('btc.tour_product_attribute1')

				attr_val_price_adult = self.env.ref('btc.tour_product_age_adult')
				attr_val_price_child4 = self.env.ref('btc.tour_product_age_child4')
				attr_val_price_child0 = self.env.ref('btc.tour_product_age_child0')

				ids = [attr_val_price_adult.id, attr_val_price_child4.id, attr_val_price_child0.id]
				# Create product.attribute.line
				attr_vals = {'product_tmpl_id': new_product.id,
							 'attribute_id': attr_age.id,
							 'value_ids': [(6, 0, ids)],
							 }
				att_age_obj = new_product.attribute_line_ids.create(attr_vals)

				new_product.create_variant_ids()

		return True
예제 #2
0
	def action_import(self):
		# self.action_update_products()
		#

		mask = '%Y-%m-%dT%H:%M:%S+00:00'
		days_diff = 27

		now = datetime.now()
		endTime = now.strftime(mask)
		startTime = (now - timedelta(days=days_diff)).strftime(mask)

		vals = {'startTime': startTime, 'endTime': endTime}

		res = get_bookeo_vals('bookings', vals)

		self.procc_booking(res)

		return True
예제 #3
0
	def action_get_customer_id(self, code):
		_logger.warn(' action_get_customer_id %s' % str(code))

		partner_pool = self.env['res.partner']

		partner_objs = partner_pool.sudo().search([('bookeo_code', '=', code)])

		if not partner_pool.exists():
			curr = get_bookeo_vals('customers/%s' % code)

			_logger.warn('curr %s' % str(curr))

			create_vals = {

				'bookeo_code': code,
				'name': curr['firstName'],
				'email': curr['emailAddress'],

			}

			if curr.has_key('lastName'):
				create_vals['name'] = create_vals['name'] + ' ' + curr['lastName']

			for cc in curr['phoneNumbers']:

				if cc['type'] == 'mobile':
					create_vals['mobile'] = cc['number']

				if cc['type'] == 'home':
					create_vals['phone'] = cc['number']


			new_partner = partner_pool.sudo().create(create_vals)

			return new_partner.id

		else:
			return partner_objs[0].id