def _compute_l10n_de_template_data(self): self.l10n_de_template_data = [ (_("Invoice No."), 'INV/2021/12345'), (_("Invoice Date"), format_date(self.env, fields.Date.today())), (_("Due Date"), format_date(self.env, fields.Date.add(fields.Date.today(), days=7))), (_("Reference"), 'SO/2021/45678'), ]
def _compute_l10n_de_template_data(self): for record in self: record.l10n_de_template_data = data = [] if record.product_id: data.append((_("Product to Repair"), record.product_id.name)) if record.lot_id: data.append((_("Lot/Serial Number"), record.lot_id.name)) if record.guarantee_limit: data.append((_("Warranty"), format_date(self.env, record.guarantee_limit))) data.append( (_("Printing Date"), format_date(self.env, fields.Date.today())))
def _compute_l10n_de_template_data(self): for record in self: record.l10n_de_template_data = data = [] if record.name: data.append((_("Invoice No."), record.name)) if record.invoice_date: data.append((_("Invoice Date"), format_date(self.env, record.invoice_date))) if record.invoice_date_due: data.append((_("Due Date"), format_date(self.env, record.invoice_date_due))) if record.invoice_origin: data.append((_("Source"), record.invoice_origin)) if record.ref: data.append((_("Reference"), record.ref))
def format_date(env, date, pattern=False): if not date: return '' try: return tools.format_date(env, date, date_format=pattern) except babel.core.UnknownLocaleError: return date
def format_date(env, date, pattern=False, lang_code=False): try: return tools.format_date(env, date, date_format=pattern, lang_code=lang_code) except babel.core.UnknownLocaleError: return date
def _compute_json_popover(self): FloatConverter = self.env['ir.qweb.field.float'] for orderpoint in self: if not orderpoint.product_id or not orderpoint.location_id: orderpoint.json_lead_days_popover = False continue dummy, lead_days_description = orderpoint.rule_ids._get_lead_days( orderpoint.product_id) orderpoint.json_lead_days_popover = dumps({ 'title': _('Replenishment'), 'icon': 'fa-area-chart', 'popoverTemplate': 'stock.leadDaysPopOver', 'lead_days_date': format_date(self.env, orderpoint.lead_days_date), 'lead_days_description': lead_days_description, 'today': format_date(self.env, fields.Date.today()), 'trigger': orderpoint.trigger, 'qty_forecast': FloatConverter.value_to_html( orderpoint.qty_forecast, {'decimal_precision': 'Product Unit of Measure'}), 'qty_to_order': FloatConverter.value_to_html( orderpoint.qty_to_order, {'decimal_precision': 'Product Unit of Measure'}), 'product_min_qty': FloatConverter.value_to_html( orderpoint.product_min_qty, {'decimal_precision': 'Product Unit of Measure'}), 'product_max_qty': FloatConverter.value_to_html( orderpoint.product_max_qty, {'decimal_precision': 'Product Unit of Measure'}), 'product_uom_name': orderpoint.product_uom_name, 'virtual': orderpoint.trigger == 'manual' and orderpoint.create_uid.id == SUPERUSER_ID, })
def _compute_l10n_de_template_data(self): for record in self: record.l10n_de_template_data = data = [] if record.state in ('draft', 'sent'): if record.name: data.append((_("Quotation No."), record.name)) if record.date_order: data.append((_("Quotation Date"), format_date(self.env, record.date_order))) if record.validity_date: data.append((_("Expiration"), format_date(self.env, record.validity_date))) else: if record.name: data.append((_("Order No."), record.name)) if record.date_order: data.append((_("Order Date"), format_date(self.env, record.date_order))) if record.client_order_ref: data.append((_('Customer Reference'), record.client_order_ref)) if record.user_id: data.append((_("Salesperson"), record.user_id.name))
def _compute_l10n_de_template_data(self): for record in self: record.l10n_de_template_data = data = [] if record.state == 'draft': data.append((_("Request for Quotation No."), record.name)) elif record.state in ['sent', 'to approve', 'purchase', 'done']: data.append((_("Purchase Order No."), record.name)) elif record.state == 'cancel': data.append((_("Cancelled Purchase Order No."), record.name)) if record.user_id: data.append((_("Purchase Representative"), record.user_id.name)) if record.partner_ref: data.append((_("Order Reference"), record.partner_ref)) if record.date_order: data.append((_("Order Date"), format_date(self.env, record.date_order))) if record.incoterm_id: data.append((_("Incoterm"), record.incoterm_id.code))
def survey_print(self, survey_token, review=False, answer_token=None, **post): '''Display an survey in printable view; if <answer_token> is set, it will grab the answers of the user_input_id that has <answer_token>.''' access_data = self._get_access_data(survey_token, answer_token, ensure_token=False, check_partner=False) if access_data['validity_code'] is not True and ( access_data['has_survey_access'] or access_data['validity_code'] not in ['token_required', 'survey_closed', 'survey_void']): return self._redirect_with_error(access_data, access_data['validity_code']) survey_sudo, answer_sudo = access_data['survey_sudo'], access_data[ 'answer_sudo'] return request.render( 'survey.survey_page_print', { 'is_html_empty': is_html_empty, 'review': review, 'survey': survey_sudo, 'answer': answer_sudo if survey_sudo.scoring_type != 'scoring_without_answers' else answer_sudo.browse(), 'questions_to_display': answer_sudo._get_print_questions(), 'scoring_display_correction': survey_sudo.scoring_type == 'scoring_with_answers' and answer_sudo, 'format_datetime': lambda dt: format_datetime(request.env, dt, dt_format=False), 'format_date': lambda date: format_date(request.env, date), })
def value_to_html(self, value, options): return format_date(self.env, value, date_format=(options or {}).get('format'))
def _prepare_survey_data(self, survey_sudo, answer_sudo, **post): """ This method prepares all the data needed for template rendering, in function of the survey user input state. :param post: - previous_page_id : come from the breadcrumb or the back button and force the next questions to load to be the previous ones. """ data = { 'is_html_empty': is_html_empty, 'survey': survey_sudo, 'answer': answer_sudo, 'breadcrumb_pages': [{ 'id': page.id, 'title': page.title, } for page in survey_sudo.page_ids], 'format_datetime': lambda dt: format_datetime(request.env, dt, dt_format=False), 'format_date': lambda date: format_date(request.env, date) } if survey_sudo.questions_layout != 'page_per_question': triggering_answer_by_question, triggered_questions_by_answer, selected_answers = answer_sudo._get_conditional_values( ) data.update({ 'triggering_answer_by_question': { question.id: triggering_answer_by_question[question].id for question in triggering_answer_by_question.keys() if triggering_answer_by_question[question] }, 'triggered_questions_by_answer': { answer.id: triggered_questions_by_answer[answer].ids for answer in triggered_questions_by_answer.keys() }, 'selected_answers': selected_answers.ids }) if not answer_sudo.is_session_answer and survey_sudo.is_time_limited and answer_sudo.start_datetime: data.update({ 'server_time': fields.Datetime.now(), 'timer_start': answer_sudo.start_datetime.isoformat(), 'time_limit_minutes': survey_sudo.time_limit }) page_or_question_key = 'question' if survey_sudo.questions_layout == 'page_per_question' else 'page' # Bypass all if page_id is specified (comes from breadcrumb or previous button) if 'previous_page_id' in post: previous_page_or_question_id = int(post['previous_page_id']) new_previous_id = survey_sudo._get_next_page_or_question( answer_sudo, previous_page_or_question_id, go_back=True).id page_or_question = request.env['survey.question'].sudo().browse( previous_page_or_question_id) data.update({ page_or_question_key: page_or_question, 'previous_page_id': new_previous_id, 'has_answered': answer_sudo.user_input_line_ids.filtered( lambda line: line.question_id.id == new_previous_id), 'can_go_back': survey_sudo._can_go_back(answer_sudo, page_or_question), }) return data if answer_sudo.state == 'in_progress': if answer_sudo.is_session_answer: next_page_or_question = survey_sudo.session_question_id else: next_page_or_question = survey_sudo._get_next_page_or_question( answer_sudo, answer_sudo.last_displayed_page_id.id if answer_sudo.last_displayed_page_id else 0) if next_page_or_question: data.update({ 'survey_last': survey_sudo._is_last_page_or_question( answer_sudo, next_page_or_question) }) if answer_sudo.is_session_answer and next_page_or_question.is_time_limited: data.update({ 'timer_start': survey_sudo.session_question_start_time.isoformat(), 'time_limit_minutes': next_page_or_question.time_limit / 60 }) data.update({ page_or_question_key: next_page_or_question, 'has_answered': answer_sudo.user_input_line_ids.filtered( lambda line: line.question_id == next_page_or_question), 'can_go_back': survey_sudo._can_go_back(answer_sudo, next_page_or_question), }) if survey_sudo.questions_layout != 'one_page': data.update({ 'previous_page_id': survey_sudo._get_next_page_or_question( answer_sudo, next_page_or_question.id, go_back=True).id }) elif answer_sudo.state == 'done' or answer_sudo.survey_time_limit_reached: # Display success message return self._prepare_survey_finished_values( survey_sudo, answer_sudo) return data
def _compute_l10n_de_template_data(self): for record in self: record.l10n_de_template_data = data = [] if record.date: data.append((_("Date"), format_date(self.env, record.date)))