def _process_field(self, form, getter): if form.xmlns == OPERATEUR_XMLNSES[1]: for item in form.get_data('form/products/item'): if 'is-relevant' not in item: continue item = item['is-relevant'] val = numeric_value(getter(item)) yield { 'date': real_date(form), "value": val, "group_by": [item['product_name'], get_product_id(item['product_name'], get_domain(form))] } else: if 'products' not in form.form: return if 'num_products' in form.form and int(form.form['num_products']) > 1: for product in form.form['products']: if 'real_date' in form.form and form.form['real_date'] and 'product_name' in product: val = numeric_value(getter(product)) yield { 'date': real_date(form), "value": val, "group_by": [product['product_name'], get_product_id(product['product_name'], get_domain(form))] } elif 'real_date' in form.form and form.form['real_date'] and 'product_name' in form.form['products']: yield { 'date': real_date(form), 'value': getter(form.form['products']), 'group_by': [form.form['products']['product_name'], get_product_id(form.form['products']['product_name'], get_domain(form))] }
def _process_v1_form(self, form): num_products = numeric_value(form.get_data('form/num_products')) if num_products > 1: for product in (form.get_data('form/products') or []): received_month_inner = product.get('receivedMonthInner') amount_ordered = numeric_value(product.get(self.property_name)) product_name = product.get('productName') if received_month_inner and amount_ordered is not None and product_name: yield { 'date': received_month_inner, 'value': amount_ordered, 'group_by': [ product_name, get_product_id(product_name, get_domain(form)) ] } else: received_month_inner = form.get_data( 'form/products/receivedMonthInner') amount_ordered = numeric_value( form.get_data('form/products/{}}'.format(self.property_name))) product_name = form.get_data('form/products/productName') if received_month_inner and amount_ordered and product_name: yield { 'date': received_month_inner, 'value': amount_ordered, 'group_by': [ product_name, get_product_id(product_name, get_domain(form)) ] }
def _process_v1_form(self, form): if 'products' not in form.form: return if 'num_products' in form.form and numeric_value( form.form['num_products']) > 1: for product in form.form['products']: if 'real_date' in form.form and form.form[ 'real_date'] and 'product_name' in product: yield { 'date': real_date(form), 'value': product[self.field], 'group_by': [ product['product_name'], get_product_id(product['product_name'], get_domain(form)) ] } elif 'real_date' in form.form and form.form[ 'real_date'] and 'product_name' in form.form['products']: yield { 'date': real_date(form), 'value': form.form['products'][self.field], 'group_by': [ form.get_data('form/products/product_name'), get_product_id(form.get_data('form/products/product_name'), get_domain(form)) ] }
def _process_v1_form(self, form): num_products = numeric_value(form.get_data('form/num_products')) if num_products > 1: for product in (form.get_data('form/products') or []): received_month_inner = product.get('receivedMonthInner') amount_ordered = numeric_value(product.get(self.property_name)) product_name = product.get('productName') if received_month_inner and amount_ordered is not None and product_name: yield { 'date': received_month_inner, 'value': amount_ordered, 'group_by': [product_name, get_product_id(product_name, get_domain(form))] } else: received_month_inner = form.get_data('form/products/receivedMonthInner') amount_ordered = numeric_value(form.get_data('form/products/{}}'.format(self.property_name))) product_name = form.get_data('form/products/productName') if received_month_inner and amount_ordered and product_name: yield { 'date': received_month_inner, 'value': amount_ordered, 'group_by': [product_name, get_product_id(product_name, get_domain(form))] }
def total(self, form): for k, v in six.iteritems(form.form): if re.match("^rupture.*hv$", k): if 'date_rapportage' in form.form and form.form['date_rapportage']: product_name = PRODUCT_NAMES.get(PRODUCT_MAPPING[k[8:-3]].lower()) if product_name is not None: try: prd = SQLProduct.active_objects.get(name__iexact=product_name, domain=get_domain(form)) yield { 'date': form.form['date_rapportage'], 'value': v, 'group_by': [PRODUCT_MAPPING[k[8:-3]], prd.product_id] } except SQLProduct.DoesNotExist: pass
def total(self, form): for k, v in form.form.iteritems(): if re.match("^rupture.*hv$", k): if 'date_rapportage' in form.form and form.form['date_rapportage']: product_name = PRODUCT_NAMES.get(PRODUCT_MAPPING[k[8:-3]].lower()) if product_name is not None: try: prd = SQLProduct.active_objects.get(name__iexact=product_name, domain=get_domain(form)) yield { 'date': form.form['date_rapportage'], 'value': v, 'group_by': [PRODUCT_MAPPING[k[8:-3]], prd.product_id] } except SQLProduct.DoesNotExist: pass
def _process_v1_form(self, form): if 'products' not in form.form: return if 'num_products' in form.form and numeric_value(form.form['num_products']) > 1: for product in form.form['products']: if 'real_date' in form.form and form.form['real_date'] and 'product_name' in product: yield { 'date': real_date(form), 'value': product[self.field], 'group_by': [product['product_name'], get_product_id(product['product_name'], get_domain(form))] } elif 'real_date' in form.form and form.form['real_date'] and 'product_name' in form.form['products']: yield { 'date': real_date(form), 'value': form.form['products'][self.field], 'group_by': [form.get_data('form/products/product_name'), get_product_id(form.get_data('form/products/product_name'), get_domain(form))] }